feat: added migration for a study_space_hours table and allowed for the user to make time inputs when submitting a new space
Co-Authored-By: Tadios Temesgen <tt2022@ic.ac.uk>
This commit is contained in:
@@ -8,6 +8,12 @@ type StudySpaceData = Omit<
|
||||
> & {
|
||||
id?: string;
|
||||
building_location?: google.maps.places.PlaceResult;
|
||||
opening_times?: {
|
||||
day_of_week: number;
|
||||
opens_at: string;
|
||||
closes_at: string;
|
||||
is_24_7: boolean;
|
||||
}[];
|
||||
};
|
||||
|
||||
export const load: PageServerLoad = async ({ params, locals: { supabase } }) => {
|
||||
@@ -34,6 +40,13 @@ export const load: PageServerLoad = async ({ params, locals: { supabase } }) =>
|
||||
const studySpaceData = space as StudySpaceData & Partial<typeof space>;
|
||||
|
||||
const images = studySpaceData.study_space_images || [];
|
||||
const { data: hours, error: hoursErr } = await supabase
|
||||
.from("study_space_hours")
|
||||
.select("day_of_week, opens_at, closes_at, is_24_7")
|
||||
.eq("study_space_id", params.id)
|
||||
.order("day_of_week", { ascending: true });
|
||||
if (hoursErr) error(500, "Failed to load opening times");
|
||||
studySpaceData.opening_times = hours;
|
||||
|
||||
delete studySpaceData.created_at;
|
||||
delete studySpaceData.updated_at;
|
||||
|
||||
Reference in New Issue
Block a user