{space.building_location}
+ + diff --git a/supabase/migrations/20250609142130_add-compulsory-tags.sql b/supabase/migrations/20250609142130_add-compulsory-tags.sql index 5355520..485144c 100644 --- a/supabase/migrations/20250609142130_add-compulsory-tags.sql +++ b/supabase/migrations/20250609142130_add-compulsory-tags.sql @@ -2,9 +2,9 @@ alter table "public"."study_spaces" add column "power" text; alter table "public"."study_spaces" add column "volume" text; alter table "public"."study_spaces" add column "wifi" text; -update "public"."study_spaces" set "power" = 'Many' where "power" is null; +update "public"."study_spaces" set "power" = 'Many Outlets' where "power" is null; update "public"."study_spaces" set "volume" = 'Quiet' where "volume" is null; -update "public"."study_spaces" set "wifi" = 'Good' where "wifi" is null; +update "public"."study_spaces" set "wifi" = 'Good WiFi' where "wifi" is null; alter table "public"."study_spaces" alter column "power" set not null; alter table "public"."study_spaces" alter column "volume" set not null; diff --git a/supabase/migrations/20250610163930_add_report_table.sql b/supabase/migrations/20250610163930_add_report_table.sql new file mode 100644 index 0000000..0ac16d0 --- /dev/null +++ b/supabase/migrations/20250610163930_add_report_table.sql @@ -0,0 +1,12 @@ +CREATE TABLE reports ( + id uuid PRIMARY KEY DEFAULT gen_random_uuid(), + study_space_id uuid REFERENCES study_spaces(id) ON DELETE CASCADE, + created_at timestamp with time zone DEFAULT now(), + updated_at timestamp with time zone DEFAULT now(), + type text NOT NULL, + content text +); + +CREATE TRIGGER reports_updated_at +AFTER UPDATE ON reports +FOR EACH ROW EXECUTE FUNCTION handle_updated_at(); diff --git a/supabase/schemas/0001_study_spaces.sql b/supabase/schemas/0001_study_spaces.sql index 9d97101..5269ceb 100644 --- a/supabase/schemas/0001_study_spaces.sql +++ b/supabase/schemas/0001_study_spaces.sql @@ -28,6 +28,14 @@ CREATE TABLE study_space_images ( PRIMARY KEY (study_space_id, image_path) ); +CREATE TABLE reports ( + id uuid PRIMARY KEY DEFAULT gen_random_uuid(), + study_space_id uuid REFERENCES study_spaces(id) ON DELETE CASCADE, + created_at timestamp with time zone DEFAULT now(), + updated_at timestamp with time zone DEFAULT now(), + type text NOT NULL, + content text +); -- Triggers CREATE TRIGGER study_spaces_updated_at @@ -37,3 +45,7 @@ FOR EACH ROW EXECUTE FUNCTION handle_updated_at(); CREATE TRIGGER study_space_images_updated_at AFTER UPDATE ON study_space_images FOR EACH ROW EXECUTE FUNCTION handle_updated_at(); + +CREATE TRIGGER reports_updated_at +AFTER UPDATE ON reports +FOR EACH ROW EXECUTE FUNCTION handle_updated_at(); From 4d8cffc72605c4c4c88aef366cf900d6a785b725 Mon Sep 17 00:00:00 2001 From: Barf-Vader <47476490+Barf-Vader@users.noreply.github.com> Date: Tue, 10 Jun 2025 18:30:09 +0100 Subject: [PATCH 2/3] fix: cant submit report while uploading --- src/lib/components/Report.svelte | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/components/Report.svelte b/src/lib/components/Report.svelte index 38e3ced..a2cf295 100644 --- a/src/lib/components/Report.svelte +++ b/src/lib/components/Report.svelte @@ -15,7 +15,7 @@ }); async function uploadReport() { - const { data: studySpaceInsert, error: reportUploadError } = await supabase + const { error: reportUploadError } = await supabase .from("reports") .insert(reportData) .select() @@ -53,8 +53,9 @@ rows={2} bind:value={reportData.content} /> - Submit Date: Wed, 11 Jun 2025 00:03:29 +0100 Subject: [PATCH 3/3] refactor: added typing for props, fixed overflow --- src/lib/components/CompulsoryTags.svelte | 6 +++--- src/lib/components/Report.svelte | 10 +++++++++- src/lib/components/SpaceCard.svelte | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/lib/components/CompulsoryTags.svelte b/src/lib/components/CompulsoryTags.svelte index e6a1228..ba5a23b 100644 --- a/src/lib/components/CompulsoryTags.svelte +++ b/src/lib/components/CompulsoryTags.svelte @@ -33,7 +33,7 @@ background-color: #eaffeb; color: #2e4653; cursor: pointer; - padding: 0.2rem 0.6rem; + padding: 0.2rem 0.2rem; } .compulsoryTagYellow { display: flex; @@ -45,7 +45,7 @@ background-color: #ffffd4; color: #534b2e; cursor: pointer; - padding: 0.2rem 0.6rem; + padding: 0.2rem 0.2rem; } .compulsoryTagRed { display: flex; @@ -57,6 +57,6 @@ background-color: #ffcece; color: #532e2e; cursor: pointer; - padding: 0.2rem 0.6rem; + padding: 0.2rem 0.2rem; } diff --git a/src/lib/components/Report.svelte b/src/lib/components/Report.svelte index a2cf295..ff2b498 100644 --- a/src/lib/components/Report.svelte +++ b/src/lib/components/Report.svelte @@ -3,8 +3,16 @@ import crossUrl from "$lib/assets/cross.svg"; import Textarea from "./inputs/Textarea.svelte"; import type { Table } from "$lib"; + import type { SupabaseClient } from "@supabase/supabase-js"; + import type { Database } from "$lib/database.d.ts"; - const { data, studySpaceId, hideFunc } = $props(); + interface Props { + data: { supabase: SupabaseClient