fix: disallow duplicate creation

Contributes to #25
This commit is contained in:
2025-06-06 03:26:15 +01:00
parent cf8d4725f7
commit 022d9089e0

View File

@@ -12,6 +12,7 @@
const { supabase } = $derived(data); const { supabase } = $derived(data);
let spaceImgs = $state<FileList>(); let spaceImgs = $state<FileList>();
let uploading = $state(false);
let studySpaceData = $state<Omit<Table<"study_spaces">, "id" | "created_at" | "updated_at">>({ let studySpaceData = $state<Omit<Table<"study_spaces">, "id" | "created_at" | "updated_at">>({
description: "", description: "",
building_location: "", building_location: "",
@@ -73,7 +74,9 @@
<form <form
onsubmit={async (event) => { onsubmit={async (event) => {
event.preventDefault(); event.preventDefault();
uploading = true;
await uploadStudySpace(); await uploadStudySpace();
uploading = false;
}} }}
> >
<Images name="study-space-image" minHeight="16rem" bind:files={spaceImgs} required /> <Images name="study-space-image" minHeight="16rem" bind:files={spaceImgs} required />
@@ -109,7 +112,8 @@
disabled={(spaceImgs?.length || 0) === 0 || disabled={(spaceImgs?.length || 0) === 0 ||
!studySpaceData.location || !studySpaceData.location ||
!studySpaceData.description || !studySpaceData.description ||
!studySpaceData.building_location} !studySpaceData.building_location ||
uploading}
> >
Share this study space! Share this study space!
</Button> </Button>