From f6f09c84923b9d74b5c0c43635040250e2b93455 Mon Sep 17 00:00:00 2001 From: Barf-Vader <47476490+Barf-Vader@users.noreply.github.com> Date: Mon, 9 Jun 2025 14:53:56 +0100 Subject: [PATCH 1/4] Added compulsory tags in db table --- README.md | 2 +- supabase/schemas/0001_study_spaces.sql | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b4188f..d7b7262 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ - `npx supabase stop` will stop the local dev database (data is persisted unless you do a reset). - `npx supabase db push --local` will apply migrations to your local dev database. Useful if someone else has made new SQL migrations. - `npx supabase db reset` will completely reset the local dev database. -- `npx supabase diff db -f ` will generate a new migration file based on the current state of the database. This isn't 100% foolproof, so don't use it blindly. +- `npx supabase db diff -f ` will generate a new migration file based on the current state of the database. This isn't 100% foolproof, so don't use it blindly. ### What's where? diff --git a/supabase/schemas/0001_study_spaces.sql b/supabase/schemas/0001_study_spaces.sql index 57ec924..64291e3 100644 --- a/supabase/schemas/0001_study_spaces.sql +++ b/supabase/schemas/0001_study_spaces.sql @@ -13,6 +13,10 @@ CREATE TABLE study_spaces ( location text, building_location text, tags text[] NOT NULL DEFAULT array[]::text[], + timing text NOT NULL, + volume text NOT NULL, + wifi text NOT NULL, + power text NOT NULL, created_at timestamp with time zone DEFAULT now(), updated_at timestamp with time zone DEFAULT now() ); -- 2.49.1 From 3cec4981927440a8aa93d8c79c58567249e60881 Mon Sep 17 00:00:00 2001 From: Barf-Vader <47476490+Barf-Vader@users.noreply.github.com> Date: Mon, 9 Jun 2025 17:25:12 +0100 Subject: [PATCH 2/4] feat: added compulsory tags --- src/lib/components/CompulsoryTags.svelte | 62 ++++++++++++++ src/lib/components/SpaceCard.svelte | 24 ++++-- src/lib/database.d.ts | 9 ++ src/lib/index.ts | 16 ++-- src/routes/space/+page.svelte | 83 ++++++++++++++++++- src/routes/space/[id]/+page.svelte | 27 ++++-- .../20250609142130_add-compulsory-tags.sql | 11 +++ supabase/schemas/0001_study_spaces.sql | 1 - 8 files changed, 206 insertions(+), 27 deletions(-) create mode 100644 src/lib/components/CompulsoryTags.svelte create mode 100644 supabase/migrations/20250609142130_add-compulsory-tags.sql diff --git a/src/lib/components/CompulsoryTags.svelte b/src/lib/components/CompulsoryTags.svelte new file mode 100644 index 0000000..e36a0d8 --- /dev/null +++ b/src/lib/components/CompulsoryTags.svelte @@ -0,0 +1,62 @@ + + +{space.volume} +{space.power} +{space.wifi} + + diff --git a/src/lib/components/SpaceCard.svelte b/src/lib/components/SpaceCard.svelte index 0b1626b..851ed16 100644 --- a/src/lib/components/SpaceCard.svelte +++ b/src/lib/components/SpaceCard.svelte @@ -9,17 +9,21 @@ } const { space, alt, imgSrc, href }: Props = $props(); + import CompulsoryTags from "./CompulsoryTags.svelte";

{space.location}

-
- {#each space.tags as tag (tag)} - {tag} - {/each} -
+
+ {#if space.tags.length > 0} +
+ {#each space.tags as tag (tag)} + {tag} + {/each} +
+ {/if}
@@ -55,11 +59,14 @@ gap: 0.4rem; border-radius: 0.5rem; background: none; + padding-top: 0.5rem; } .tag { display: flex; align-items: center; + justify-content: center; + text-align: center; border-radius: 0.25rem; background-color: #2e4653; color: #eaffeb; @@ -67,4 +74,11 @@ cursor: pointer; padding: 0.2rem 0.6rem; } + + .compulsoryContainer { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 0.5rem; + font-size: 0.875rem; + } diff --git a/src/lib/database.d.ts b/src/lib/database.d.ts index ba2f1c3..3a3aedd 100644 --- a/src/lib/database.d.ts +++ b/src/lib/database.d.ts @@ -70,8 +70,11 @@ export type Database = { description: string | null id: string location: string | null + power: string tags: string[] updated_at: string | null + volume: string + wifi: string } Insert: { building_location?: string | null @@ -79,8 +82,11 @@ export type Database = { description?: string | null id?: string location?: string | null + power: string tags?: string[] updated_at?: string | null + volume: string + wifi: string } Update: { building_location?: string | null @@ -88,8 +94,11 @@ export type Database = { description?: string | null id?: string location?: string | null + power?: string tags?: string[] updated_at?: string | null + volume?: string + wifi?: string } Relationships: [] } diff --git a/src/lib/index.ts b/src/lib/index.ts index 6a9dac8..2e36564 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -5,26 +5,22 @@ export type Table = export type Enum = Database["public"]["Enums"][T]; export const availableStudySpaceTags = [ - "Quiet", - "Loud", - "Silent", "Crowded", "Group study", - "Power outlets", - "No power outlets", "24/7", "Food allowed", "No food allowed", "Well lit", "Poorly lit", - "Good wifi", - "Bad wifi", - "No wifi", "Whiteboard", "Restricted access", "Hot", "Air conditioned", "Cold", - "Cringe", - "PCs" + "PCs", + "Cringe" ]; + +export const volumeTags = ["Silent", "Quiet", "Some Noise", "Loud"]; +export const wifiTags = ["Good WiFi", "Moderate WiFi", "Bad WiFi", "No WiFi"]; +export const powerOutletTags = ["Many Outlets", "Some Outlets", "No Outlets"]; diff --git a/src/routes/space/+page.svelte b/src/routes/space/+page.svelte index 4b0f21c..75766a6 100644 --- a/src/routes/space/+page.svelte +++ b/src/routes/space/+page.svelte @@ -7,7 +7,7 @@ import Button from "$lib/components/Button.svelte"; import Images from "$lib/components/inputs/Images.svelte"; import type { Table } from "$lib"; - import { availableStudySpaceTags } from "$lib"; + import { availableStudySpaceTags, wifiTags, powerOutletTags, volumeTags } from "$lib"; const { data } = $props(); const { supabase } = $derived(data); @@ -17,7 +17,10 @@ description: "", building_location: "", location: "", - tags: [] + tags: [], + volume: "", + power: "", + wifi: "" }); async function uploadStudySpace() { @@ -115,7 +118,41 @@ required /> - +
+
+ + +
+
+ + +
+
+ + +
+
+ +
{#each studySpaceData.tags as tagName (tagName)}