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 /> - Add tags: + + + Sound level: + + How noisy is it? + {#each volumeTags as volumeTag (volumeTag)} + {volumeTag} + {/each} + + + + Power outlets: + + Power outlets? + {#each powerOutletTags as powerOutletTag (powerOutletTag)} + {powerOutletTag} + {/each} + + + + Wifi: + + How's the wifi? + {#each wifiTags as wifiTag (wifiTag)} + {wifiTag} + {/each} + + + + + Additional tags: {#each studySpaceData.tags as tagName (tagName)} @@ -184,7 +221,9 @@ type="submit" disabled={(spaceImgs?.length || 0) === 0 || !studySpaceData.location || - studySpaceData.tags.length === 0 || + !studySpaceData.wifi || + !studySpaceData.volume || + !studySpaceData.power || !studySpaceData.building_location || uploading} > @@ -294,4 +333,40 @@ .avaliableTag:last-child { padding-bottom: 0.6rem; } + + .compulsoryTags { + display: grid; + gap: 0.4rem; + border-radius: 0.5rem; + background-color: none; + width: 100%; + font-size: 1rem; + grid-template-columns: repeat(3, 1fr); + } + + .compulsoryContainer { + display: flex; + flex-direction: column; + align-items: left; + justify-content: top; + border-radius: 0.5rem; + background-color: none; + } + + .compulsoryTagSelect { + width: 100%; + height: 100%; + padding: 0.5rem; + border-radius: 0.5rem; + border: 2px solid #eaffeb; + background: none; + color: #eaffeb; + font-size: 0.9rem; + text-align: left; + } + + .compulsoryTagSelect option { + background-color: #2e4653; + color: #eaffeb; + } diff --git a/src/routes/space/[id]/+page.svelte b/src/routes/space/[id]/+page.svelte index 0c099dd..cf793a5 100644 --- a/src/routes/space/[id]/+page.svelte +++ b/src/routes/space/[id]/+page.svelte @@ -3,6 +3,7 @@ import crossUrl from "$lib/assets/cross.svg"; import placeholder from "$lib/assets/study_space.png"; import Carousel from "$lib/components/Carousel.svelte"; + import CompulsoryTags from "$lib/components/CompulsoryTags.svelte"; const { data } = $props(); const { space, supabase } = $derived(data); @@ -35,13 +36,16 @@ {/if} - - {#each space.tags as tag (tag)} - - {tag} - - {/each} - + + {#if space.tags.length > 0} + + {#each space.tags as tag (tag)} + + {tag} + + {/each} + + {/if} Where it is: @@ -128,4 +132,13 @@ cursor: pointer; padding: 0.2rem 0.6rem; } + + .compulsoryContainer { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 0.5rem; + padding: 1.4rem; + font-size: 1.3rem; + padding-bottom: 0; + } diff --git a/supabase/migrations/20250609142130_add-compulsory-tags.sql b/supabase/migrations/20250609142130_add-compulsory-tags.sql new file mode 100644 index 0000000..5355520 --- /dev/null +++ b/supabase/migrations/20250609142130_add-compulsory-tags.sql @@ -0,0 +1,11 @@ +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 "volume" = 'Quiet' where "volume" is null; +update "public"."study_spaces" set "wifi" = 'Good' 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; +alter table "public"."study_spaces" alter column "wifi" set not null; \ No newline at end of file diff --git a/supabase/schemas/0001_study_spaces.sql b/supabase/schemas/0001_study_spaces.sql index 64291e3..9d97101 100644 --- a/supabase/schemas/0001_study_spaces.sql +++ b/supabase/schemas/0001_study_spaces.sql @@ -13,7 +13,6 @@ 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,
@@ -128,4 +132,13 @@ cursor: pointer; padding: 0.2rem 0.6rem; } + + .compulsoryContainer { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 0.5rem; + padding: 1.4rem; + font-size: 1.3rem; + padding-bottom: 0; + } diff --git a/supabase/migrations/20250609142130_add-compulsory-tags.sql b/supabase/migrations/20250609142130_add-compulsory-tags.sql new file mode 100644 index 0000000..5355520 --- /dev/null +++ b/supabase/migrations/20250609142130_add-compulsory-tags.sql @@ -0,0 +1,11 @@ +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 "volume" = 'Quiet' where "volume" is null; +update "public"."study_spaces" set "wifi" = 'Good' 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; +alter table "public"."study_spaces" alter column "wifi" set not null; \ No newline at end of file diff --git a/supabase/schemas/0001_study_spaces.sql b/supabase/schemas/0001_study_spaces.sql index 64291e3..9d97101 100644 --- a/supabase/schemas/0001_study_spaces.sql +++ b/supabase/schemas/0001_study_spaces.sql @@ -13,7 +13,6 @@ 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,