fix: timing
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<script lang="ts">
|
||||
import CompulsoryTags from "./CompulsoryTags.svelte";
|
||||
import OpeningTimes from "./OpeningTimes.svelte";
|
||||
import Favourite from "./Favourite.svelte";
|
||||
import type { Table } from "$lib";
|
||||
|
||||
@@ -17,8 +16,6 @@
|
||||
|
||||
const { space, alt, imgSrc, href, isFavourite, onToggleFavourite, isAvailable, footer }: Props =
|
||||
$props();
|
||||
|
||||
console.log(isAvailable);
|
||||
</script>
|
||||
|
||||
<a class="card {isAvailable ? 'green' : 'grey'}" {href}>
|
||||
|
||||
@@ -148,12 +148,15 @@
|
||||
} else {
|
||||
const opensFor = timeUntilClosing(timing.opens_at, timing.closes_at, time);
|
||||
if (opensFor) {
|
||||
return { isOpen: true, message: `Open now for: ${minsToReadableHours}` };
|
||||
return {
|
||||
isOpen: true,
|
||||
message: `Open now for: ${minsToReadableHours(timeToMins(time))}`
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { isOpen: false, message: "Closed today" };
|
||||
return { isOpen: false, message: "Closed right now" };
|
||||
}
|
||||
|
||||
function timeUntilClosing(openingTime: string, closingTime: string, currentTime: string) {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import Report from "$lib/components/Report.svelte";
|
||||
import Feedback from "$lib/components/Feedback.svelte";
|
||||
import { onMount } from "svelte";
|
||||
import { gmapsLoader, daysOfWeek, formatTime, collectTimings, type Table } from "$lib";
|
||||
import { gmapsLoader, daysOfWeek, formatTime, collectTimings } from "$lib";
|
||||
import Button from "$lib/components/Button.svelte";
|
||||
import Favourite from "$lib/components/Favourite.svelte";
|
||||
|
||||
|
||||
@@ -101,8 +101,8 @@
|
||||
return fullDayOfWeek.map((day) => ({
|
||||
study_space_id: studySpaceId,
|
||||
day_of_week: day,
|
||||
opens_at: allDays.open_today_status == null ? allDays.opens_at : "00:00",
|
||||
closes_at: allDays.open_today_status == null ? allDays.closes_at : "00:00",
|
||||
opens_at: allDays.open_today_status !== null ? allDays.opens_at : "00:00",
|
||||
closes_at: allDays.open_today_status !== null ? allDays.closes_at : "00:01",
|
||||
open_today_status: allDays.open_today_status
|
||||
}));
|
||||
}
|
||||
@@ -114,16 +114,16 @@
|
||||
.map((h) => ({
|
||||
study_space_id: studySpaceId,
|
||||
day_of_week: h.day_of_week,
|
||||
opens_at: h.opens_at,
|
||||
closes_at: h.closes_at,
|
||||
opens_at: h.open_today_status === null ? h.opens_at : "00:00",
|
||||
closes_at: h.open_today_status === null ? h.closes_at : "00:01",
|
||||
open_today_status: h.open_today_status
|
||||
}))
|
||||
.concat(
|
||||
nonDefinedDays.map((day) => ({
|
||||
study_space_id: studySpaceId,
|
||||
day_of_week: day,
|
||||
opens_at: allDays.opens_at,
|
||||
closes_at: allDays.closes_at,
|
||||
opens_at: allDays.open_today_status === null ? allDays.opens_at : "00:00",
|
||||
closes_at: allDays.open_today_status === null ? allDays.closes_at : "00:01",
|
||||
open_today_status: allDays.open_today_status
|
||||
}))
|
||||
);
|
||||
@@ -134,10 +134,8 @@
|
||||
if (!spaceImgs || spaceImgs.length < 1) return alert("Please select an image file.");
|
||||
if (!studySpaceData.building_location) return alert("Please select a building location.");
|
||||
|
||||
const { opening_times, ...spacePayload } = studySpaceData;
|
||||
|
||||
// explicitly mark opening_times as used to avoid unused warning
|
||||
void opening_times;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { opening_times: _, ...spacePayload } = studySpaceData;
|
||||
|
||||
const { data: studySpaceInsert, error: studySpaceError } = await supabase
|
||||
.from("study_spaces")
|
||||
|
||||
Reference in New Issue
Block a user