From 376a94edc3dcddbd7389a7fb9b935bd68a755562 Mon Sep 17 00:00:00 2001 From: "Edward Tirado Jr." Date: Thu, 3 Jul 2025 00:16:46 -0500 Subject: [PATCH] updated schedule date to use local time --- src/components/admin/lists.vue | 5 ++++- src/components/forms/ScheduleMovie.vue | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/admin/lists.vue b/src/components/admin/lists.vue index 6925bcb..7ca4463 100644 --- a/src/components/admin/lists.vue +++ b/src/components/admin/lists.vue @@ -86,7 +86,10 @@ const getLists = function () { const config = useRuntimeConfig(); $fetch(`${config.public.apiURL}/lists`, { method: "GET", - headers: { "Content-type": "application/json" }, + headers: { + "Content-type": "application/json", + Authorization: `Token ${useCookie("token").value}`, + }, }) .then((data) => (lists.value = data)) .catch((err) => console.log(err)); diff --git a/src/components/forms/ScheduleMovie.vue b/src/components/forms/ScheduleMovie.vue index b2bf788..60cf7c2 100644 --- a/src/components/forms/ScheduleMovie.vue +++ b/src/components/forms/ScheduleMovie.vue @@ -43,7 +43,8 @@ const schedule = function (e: Event) { return false; } - const date = new Date(`${showtime_input}T00:00:00`); + let date = new Date(`${showtime_input}T23:00:00`); + convertToUserTimezone(date); fetch(`${config.public.apiURL}/showings/`, { method: "POST", @@ -58,12 +59,16 @@ const schedule = function (e: Event) { Authorization: `Token ${useCookie("token").value}`, }, }) - .then((response) => response.json()) - .then((_json) => { + .then((_resp) => { emits("closeModal"); }) .catch((err) => alert("Unable to schedule movie. Error:\n" + err)); }; + +// @todo pull the timezone from a user setting +const convertToUserTimezone = function (date: Date) { + date.toLocaleString("en-US", { timeZone: "America/Chicago" }); +};