From efe70660f5b4b8f30ed2a1d09df35232641bfb3a Mon Sep 17 00:00:00 2001 From: "riho.takagi" Date: Wed, 15 Jan 2025 14:34:48 -0500 Subject: [PATCH 1/2] Update languages --- booking-app/app/api/syncCalendars/route.ts | 8 ++-- .../api/syncSemesterPregameBookings/route.ts | 45 ++++++++++--------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/booking-app/app/api/syncCalendars/route.ts b/booking-app/app/api/syncCalendars/route.ts index 1c13b530..d11f5011 100644 --- a/booking-app/app/api/syncCalendars/route.ts +++ b/booking-app/app/api/syncCalendars/route.ts @@ -139,10 +139,10 @@ export async function POST(request: Request) { let targetBookings = 0; const now = new Date(); - const threeMonthsAgo = new Date(now.getFullYear(), now.getMonth() - 1, 1); - const threeMonthsLater = new Date(now.getFullYear(), now.getMonth() + 4, 0); - const timeMin = threeMonthsAgo.toISOString(); - const timeMax = threeMonthsLater.toISOString(); + const startTimeMax = new Date(now.getFullYear(), now.getMonth() - 1, 1); + const endTimeMax = new Date(now.getFullYear(), now.getMonth() + 12, 0); + const timeMin = startTimeMax.toISOString(); + const timeMax = endTimeMax.toISOString(); for (const resource of resources) { try { diff --git a/booking-app/app/api/syncSemesterPregameBookings/route.ts b/booking-app/app/api/syncSemesterPregameBookings/route.ts index a6bc5e19..24cbcfbb 100644 --- a/booking-app/app/api/syncSemesterPregameBookings/route.ts +++ b/booking-app/app/api/syncSemesterPregameBookings/route.ts @@ -1,4 +1,5 @@ import { toFirebaseTimestampFromString } from "@/components/src/client/utils/serverDate"; +import { TableNames } from "@/components/src/policy"; import { Booking, BookingStatusLabel, @@ -310,28 +311,28 @@ export async function POST(request: Request) { console.log("newBooking", newBooking); const newTitle = `[${BookingStatusLabel.PENDING}] ${event.summary}`; - //const bookingDocRef = await db - // .collection(TableNames.BOOKING) - // .add({ - // ...newBooking, - // requestedAt: admin.firestore.FieldValue.serverTimestamp(), - // firstApprovedAt: - // admin.firestore.FieldValue.serverTimestamp(), - // }); - - ////Add all requesters as guests to the calendar event - //if (event.id) { - // await calendar.events.patch({ - // calendarId: resource.calendarId, - // eventId: event.id, - // requestBody: { - // summary: newTitle, - // }, - // }); - //} - - //console.log(`New Booking created with ID: ${bookingDocRef.id}`); - //totalNewBookings++; + const bookingDocRef = await db + .collection(TableNames.BOOKING) + .add({ + ...newBooking, + requestedAt: admin.firestore.FieldValue.serverTimestamp(), + firstApprovedAt: + admin.firestore.FieldValue.serverTimestamp(), + }); + + //Add all requesters as guests to the calendar event + if (event.id) { + await calendar.events.patch({ + calendarId: resource.calendarId, + eventId: event.id, + requestBody: { + summary: newTitle, + }, + }); + } + + console.log(`New Booking created with ID: ${bookingDocRef.id}`); + totalNewBookings++; } } } From 21e060269b2d8e32769ddd751573a12d0c9db0f2 Mon Sep 17 00:00:00 2001 From: "riho.takagi" Date: Wed, 15 Jan 2025 14:36:07 -0500 Subject: [PATCH 2/2] Update text on sync page --- .../routes/admin/components/SyncCalendars.tsx | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/booking-app/components/src/client/routes/admin/components/SyncCalendars.tsx b/booking-app/components/src/client/routes/admin/components/SyncCalendars.tsx index 7b31d601..6f468edd 100644 --- a/booking-app/components/src/client/routes/admin/components/SyncCalendars.tsx +++ b/booking-app/components/src/client/routes/admin/components/SyncCalendars.tsx @@ -58,17 +58,14 @@ const SyncCalendars = () => { return ( - - {" "} - Sync Current Semester Calendar Events - + Import Manual Calendar Events

- This function saves existing events from the current semester's calendar - to the database. + This function imports existing manually entered events from Production + Google Calendars to the Booking Tool database.

{ handleClose={() => setShowAlert(false)} /> - - {" "} - Sync Pregame Calendar Events to Database - + Import Pregame Calendar Events

- This function saves existing pregame events from the calendar to the - database. + This function imports existing pregame events from Production Google + Calendars to the Booking Tool database.