Skip to content

Commit

Permalink
Merge pull request #559 from ITPNYU/main
Browse files Browse the repository at this point in the history
Add [PENDING] prefix to the title of pregame calendar events
  • Loading branch information
rlho authored Jan 15, 2025
2 parents 020fdd8 + e903543 commit a2f7513
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 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 @@ -270,7 +271,6 @@ export async function POST(request: Request) {
) as Timestamp;
const title = event.summary;
const sanitizedTitle = title.replace(/^\[.*?\]\s*/, ""); // `[PENDING]` を削除
console.log("sanitizedTitle", sanitizedTitle);

const existingBookingSnapshot = await db
.collection("bookings")
Expand All @@ -293,13 +293,13 @@ export async function POST(request: Request) {
`Renaming existing event title from "${title}" to "${newTitle}".`,
);

//await calendar.events.patch({
// calendarId: resource.calendarId,
// eventId: event.id!,
// requestBody: {
// summary: newTitle,
// },
//});
await calendar.events.patch({
calendarId: resource.calendarId,
eventId: event.id!,
requestBody: {
summary: newTitle,
},
});
}
continue;
}
Expand Down Expand Up @@ -329,28 +329,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

0 comments on commit a2f7513

Please sign in to comment.