Skip to content

Commit

Permalink
email links to Google Site booking tool deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
lucia-gomez committed Jun 2, 2024
1 parent 485acf8 commit 6c5e95a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export default function useSubmitBooking(): [
} else {
const getApprovalUrl = serverFunctions.approvalUrl(calendarEventId);
const getRejectedUrl = serverFunctions.rejectUrl(calendarEventId);
const getBookingToolUrl = serverFunctions.scriptURL();
const getBookingToolUrl = serverFunctions.getBookingToolDeployUrl();
Promise.all([getApprovalUrl, getRejectedUrl, getBookingToolUrl]).then(
(values) => {
const userEventInputs: BookingFormDetails = {
Expand Down
4 changes: 2 additions & 2 deletions media_commons_booking_app/src/server/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
getSecondApproverEmail,
} from '../policy';
import { BookingFormDetails, BookingStatusLabel } from '../types';
import { approvalUrl, rejectUrl, scriptURL } from './ui';
import { approvalUrl, getBookingToolDeployUrl, rejectUrl } from './ui';
import {
fetchById,
fetchIndexByUniqueValue,
Expand All @@ -20,7 +20,7 @@ export const bookingContents = (id: string): BookingFormDetails => {
const bookingObj = fetchById(TableNames.BOOKING, id);
bookingObj.approvalUrl = approvalUrl(id);
bookingObj.rejectedUrl = rejectUrl(id);
bookingObj.bookingToolUrl = scriptURL();
bookingObj.bookingToolUrl = getBookingToolDeployUrl();
return bookingObj;
};

Expand Down
6 changes: 4 additions & 2 deletions media_commons_booking_app/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import {
approvalUrl,
doGet,
getActiveUserEmail,
getBookingToolDeployUrl,
rejectUrl,
scriptURL,
scriptUrl,
} from './ui';
import {
approveBooking,
Expand Down Expand Up @@ -45,7 +46,8 @@ export {
getOldSafetyTrainingEmails,

// ui
scriptURL,
getBookingToolDeployUrl,
scriptUrl,
approvalUrl,
rejectUrl,
doGet,
Expand Down
15 changes: 14 additions & 1 deletion media_commons_booking_app/src/server/ui.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import { approveBooking, reject } from './admin';

export const scriptURL = () => {
import { DevBranch } from '../types';

export const scriptUrl = () => {
const url = ScriptApp.getService().getUrl();
return url;
};

export const getBookingToolDeployUrl = () => {
switch (process.env.BRANCH_NAME as DevBranch) {
case 'development':
return 'https://sites.google.com/nyu.edu/media-commons-dev/';
case 'staging':
return 'https://sites.google.com/nyu.edu/media-commons-staging/';
default:
return 'https://sites.google.com/nyu.edu/media-commons-prod/';
}
};

export const approvalUrl = (calendarEventId: string) => {
const url = ScriptApp.getService().getUrl();
return `${url}?action=approve&page=admin&calendarEventId=${calendarEventId}`;
Expand Down

0 comments on commit 6c5e95a

Please sign in to comment.