fix: timing

This commit is contained in:
Barf-Vader
2025-06-13 13:51:15 +01:00
parent 268392deed
commit 37665bcb3a
4 changed files with 14 additions and 16 deletions

View File

@@ -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}>

View File

@@ -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) {

View File

@@ -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";

View File

@@ -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")