Skip to content

Commit

Permalink
Use bookingCalendarInfo for getting startTime and endTime
Browse files Browse the repository at this point in the history
  • Loading branch information
rlho committed Apr 16, 2024
1 parent cc1dec6 commit 38d71cd
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,13 @@ export default function useSubmitBooking(): [
formatDate(new Date()),
]);

const isAutoApproval = (selectedRoomIds: string[], data: Booking) => {
const startDate = new Date(data.startDate);
const endDate = new Date(data.endDate);
const isAutoApproval = (
selectedRoomIds: string[],
data: Booking,
bookingCalendarInfo
) => {
const startDate = new Date(bookingCalendarInfo?.startStr);
const endDate = new Date(bookingCalendarInfo?.endStr);
const duration = endDate.getTime() - startDate.getTime();
// If the selected rooms are all instant approval rooms and the user does not need catering, and hire security, and room setup, then it is auto-approval.
return (
Expand All @@ -141,7 +145,7 @@ export default function useSubmitBooking(): [
);
};

if (isAutoApproval(selectedRoomIds, data)) {
if (isAutoApproval(selectedRoomIds, data, bookingCalendarInfo)) {
serverFunctions.approveInstantBooking(calendarEventId);
} else {
const getApprovalUrl = serverFunctions.approvalUrl(calendarEventId);
Expand Down

0 comments on commit 38d71cd

Please sign in to comment.