From 7d33a4324a60f3ebff0eb86322eedda2e05ffc0d Mon Sep 17 00:00:00 2001 From: Justin Xue <67207128+jxmoose@users.noreply.github.com> Date: Sat, 9 Nov 2024 20:13:08 -0800 Subject: [PATCH] Justinxue/bre 21 implement dynamic routing for event descriptions (#19) --- api/supabase/queries/events.ts | 14 ++ api/supabase/queries/facilities.ts | 15 ++ app/discover/[event_id]/page.tsx | 130 +++++++++++++++++ app/discover/[event_id]/styles.ts | 138 ++++++++++++++++++ app/{activeEvents => discover}/page.tsx | 3 +- app/{activeEvents => discover}/styles.ts | 0 .../EventListingCard/EventListingCard.tsx | 9 +- public/images/help.svg | 5 + public/images/location_pin.svg | 8 + public/images/star.svg | 5 + styles/colors.ts | 1 + 11 files changed, 326 insertions(+), 2 deletions(-) create mode 100644 api/supabase/queries/facilities.ts create mode 100644 app/discover/[event_id]/page.tsx create mode 100644 app/discover/[event_id]/styles.ts rename app/{activeEvents => discover}/page.tsx (95%) rename app/{activeEvents => discover}/styles.ts (100%) create mode 100644 public/images/help.svg create mode 100644 public/images/location_pin.svg create mode 100644 public/images/star.svg diff --git a/api/supabase/queries/events.ts b/api/supabase/queries/events.ts index adad031..c2dafef 100644 --- a/api/supabase/queries/events.ts +++ b/api/supabase/queries/events.ts @@ -52,3 +52,17 @@ export async function fetchAllActiveEvents() { return data; } + +// fetches an event by its event_id +export async function fetchEventById(event_id: string) { + const { data, error } = await supabase + .from('events') + .select('*') + .eq('event_id', event_id) + .single(); + if (error) { + throw new Error(error.message); + } + + return data; +} diff --git a/api/supabase/queries/facilities.ts b/api/supabase/queries/facilities.ts new file mode 100644 index 0000000..5a279c2 --- /dev/null +++ b/api/supabase/queries/facilities.ts @@ -0,0 +1,15 @@ +import supabase from '../createClient'; + +// fetches an event by its event_id +export async function fetchFacilityById(facility_id: string) { + const { data, error } = await supabase + .from('facilities') + .select('*') + .eq('facility_id', facility_id) + .single(); + if (error) { + throw new Error(error.message); + } + + return data; +} diff --git a/app/discover/[event_id]/page.tsx b/app/discover/[event_id]/page.tsx new file mode 100644 index 0000000..2546e86 --- /dev/null +++ b/app/discover/[event_id]/page.tsx @@ -0,0 +1,130 @@ +'use client'; + +import React, { useEffect, useState } from 'react'; +import { useRouter } from 'next/navigation'; +import { fetchEventById } from '@/api/supabase/queries/events'; +import { fetchFacilityById } from '@/api/supabase/queries/facilities'; +import Back from '@/public/images/back.svg'; +import LocationPin from '@/public/images/location_pin.svg'; +import COLORS from '@/styles/colors'; +import { SMALL } from '@/styles/text'; +import { Event, Facilities } from '@/types/schema'; +import { + About, + AboutText, + BackButton, + Body, + Bullet, + Container, + FacilityName, + HostWarningTitle, + Image, + IndividualTag, + InterestBlock, + InterestTitle, + Location, + Select, + ShowInterest, + SignUp, + TagDiv, + TextWithIcon, + Time, + Title, +} from './styles'; + +function InterestBlockGen(title: string, about: string, icon: string) { + return ( + + {' '} +