Skip to content

Commit

Permalink
Update automatic approval logics
Browse files Browse the repository at this point in the history
  • Loading branch information
rlho committed Mar 27, 2024
1 parent aedd639 commit ca3395f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion media_commons_booking_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"deploy:staging": "rimraf dist && npm run build:staging && npx clasp push",
"deploy": "rimraf dist && npm run build && npx clasp push",
"serve": "cross-env NODE_ENV=development CALENDAR_ENV=development webpack serve",
"start": "npm run deploy:dev && npm run serve"
"start": "npm run deploy:local && npm run serve"
},
"keywords": [
"react",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,17 @@ export default function useSubmitBooking(): [(any) => Promise<void>, boolean] {
formatDate(new Date()),
]);

// TODO full auto approval logic
const isAutoApproval = selectedRoomIds.every((r) =>
INSTANT_APPROVAL_ROOMS.includes(r)
);

if (isAutoApproval) {
const isAutoApproval = (selectedRoomIds, data) => {
// 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 (
selectedRoomIds.every((r) => INSTANT_APPROVAL_ROOMS.includes(r)) &&
data['catering'] === 'no' &&
data['hireSecurity'] === 'no' &&
data['roomSetup'] === 'no'
);
};

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

0 comments on commit ca3395f

Please sign in to comment.