diff --git a/src/lib/components/OpeningTimes.svelte b/src/lib/components/OpeningTimes.svelte new file mode 100644 index 0000000..fbd3242 --- /dev/null +++ b/src/lib/components/OpeningTimes.svelte @@ -0,0 +1,40 @@ + + +
{#if place.name}
@@ -220,4 +243,24 @@
text-decoration: none;
text-align: center;
}
+
+ .opening-entry {
+ display: grid;
+ grid-template-columns: auto 1fr;
+ gap: 0.75rem;
+ padding: 0.5rem 1.4rem;
+ align-items: center;
+ }
+ .opening-entry .day {
+ font-weight: bold;
+ color: #ffffff;
+ white-space: nowrap;
+ }
+ .opening-entry .times {
+ font-family: monospace;
+ background-color: rgba(255, 255, 255, 0.1);
+ padding: 0.25rem 0.5rem;
+ border-radius: 0.25rem;
+ color: #eaffeb;
+ }
diff --git a/src/routes/space/[id]/edit/+page.svelte b/src/routes/space/[id]/edit/+page.svelte
index bcf02ac..5302a2c 100644
--- a/src/routes/space/[id]/edit/+page.svelte
+++ b/src/routes/space/[id]/edit/+page.svelte
@@ -11,7 +11,8 @@
wifiTags,
powerOutletTags,
volumeTags,
- gmapsLoader
+ gmapsLoader,
+ daysOfWeek
} from "$lib";
import { onMount } from "svelte";
import type { Json } from "$lib/database.js";
@@ -20,16 +21,6 @@
const { supabase } = $derived(data);
const { space, images } = $derived(data);
- // Days of week for opening times
- const daysOfWeek = [
- "Sunday",
- "Monday",
- "Tuesday",
- "Wednesday",
- "Thursday",
- "Friday",
- "Saturday"
- ];
const studySpaceData = $state({
opening_times: daysOfWeek.map((_, index) => ({
day_of_week: index,
@@ -205,6 +196,20 @@
});
spaceImgs = dt.files;
});
+
+ // --- Helper functions for opening times ---
+ function toggle247(index: number) {
+ const ot = studySpaceData.opening_times[index];
+ if (ot.is_24_7) {
+ ot.opens_at = "00:00";
+ ot.closes_at = "00:00";
+ }
+ }
+
+ function updateTimes(index: number) {
+ const ot = studySpaceData.opening_times[index];
+ ot.is_24_7 = ot.opens_at === "00:00" && ot.closes_at === "00:00";
+ }