Skip to content

Commit

Permalink
Merge pull request #557 from ITPNYU/main
Browse files Browse the repository at this point in the history
Update languages
  • Loading branch information
rlho authored Jan 15, 2025
2 parents d8e6dd5 + 21e0602 commit 671d7d3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 40 deletions.
8 changes: 4 additions & 4 deletions booking-app/app/api/syncCalendars/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
45 changes: 23 additions & 22 deletions booking-app/app/api/syncSemesterPregameBookings/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { toFirebaseTimestampFromString } from "@/components/src/client/utils/serverDate";
import { TableNames } from "@/components/src/policy";
import {
Booking,
BookingStatusLabel,
Expand Down Expand Up @@ -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++;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,14 @@ const SyncCalendars = () => {

return (
<Box>
<Typography variant="h6">
{" "}
Sync Current Semester Calendar Events
</Typography>
<Typography variant="h6"> Import Manual Calendar Events</Typography>
<p>
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.
</p>
<Box sx={{ marginTop: 2 }}>
<Button onClick={handleSync} variant="contained" disabled={loading}>
Sync Calendar Events
IMPORT MANUAL CALENDAR EVENTS
</Button>
</Box>
<AlertToast
Expand All @@ -78,21 +75,18 @@ const SyncCalendars = () => {
handleClose={() => setShowAlert(false)}
/>
<Box sx={{ marginTop: 4 }}>
<Typography variant="h6">
{" "}
Sync Pregame Calendar Events to Database
</Typography>
<Typography variant="h6"> Import Pregame Calendar Events</Typography>
<p>
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.
</p>
<Box sx={{ marginTop: 2 }}>
<Button
onClick={handlePregameSync}
variant="contained"
disabled={loading}
>
Sync Pregame Events
IMPORT PREGAME CALENDAR EVENTS
</Button>
</Box>
<AlertToast
Expand Down

0 comments on commit 671d7d3

Please sign in to comment.