Skip to content

Commit

Permalink
Merge pull request #163 from ITPNYU/feature/update_email_header_message
Browse files Browse the repository at this point in the history
update
  • Loading branch information
rlho authored Apr 11, 2024
2 parents 4e1adc3 + 35605b8 commit fc8eecc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export default function useSubmitBooking(): [
endDate: bookingCalendarInfo?.endStr,
approvalUrl: values[0],
rejectedUrl: values[1],
headerMessage: 'This is a request email for first approval.',
...data,
};
sendApprovalEmail(firstApprovers, userEventInputs);
Expand Down
30 changes: 24 additions & 6 deletions media_commons_booking_app/src/server/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ export const approveBooking = (id: string) => {
updateEventPrefix(id, BookingStatusLabel.PRE_APPROVED);

const contents = bookingContents(id);
const emailContents = {
headerMessage: 'This is a request email for final approval.',
...contents,
};
const recipient = getSecondApproverEmail(process.env.BRANCH_NAME);
sendHTMLEmail(
'approval_email',
contents,
emailContents,
recipient,
BookingStatusLabel.PRE_APPROVED,
contents.title,
Expand All @@ -79,10 +83,10 @@ export const approveBooking = (id: string) => {

export const sendConfirmationEmail = (
calendarEventId: string,
status: BookingStatusLabel
status: BookingStatusLabel,
headerMessage
) => {
const email = getSecondApproverEmail(process.env.BRANCH_NAME);
const headerMessage = 'This is a confirmation email.';
sendBookingDetailEmail(calendarEventId, email, headerMessage, status);
};

Expand All @@ -104,6 +108,7 @@ export const approveEvent = (id: string) => {
ActiveSheetBookingStatusColumns.EMAIL
);

// for user
const headerMessage =
'Your reservation request for Media Commons is approved.';
console.log('sending booking detail email...');
Expand All @@ -113,7 +118,12 @@ export const approveEvent = (id: string) => {
headerMessage,
BookingStatusLabel.APPROVED
);
sendConfirmationEmail(id, BookingStatusLabel.APPROVED);
// for second approver
sendConfirmationEmail(
id,
BookingStatusLabel.APPROVED,
`This is a confirmation email.`
);

updateEventPrefix(id, BookingStatusLabel.APPROVED);
inviteUserToCalendarEvent(id, guestEmail);
Expand Down Expand Up @@ -163,7 +173,11 @@ export const cancel = (id: string) => {
headerMessage,
BookingStatusLabel.CANCELED
);
sendConfirmationEmail(id, BookingStatusLabel.CANCELED);
sendConfirmationEmail(
id,
BookingStatusLabel.CANCELED,
`This is a cancelation email.`
);
updateEventPrefix(id, BookingStatusLabel.CANCELED);
};

Expand Down Expand Up @@ -212,7 +226,11 @@ export const noShow = (id: string) => {
headerMessage,
BookingStatusLabel.NO_SHOW
);
sendConfirmationEmail(id, BookingStatusLabel.NO_SHOW);
sendConfirmationEmail(
id,
BookingStatusLabel.NO_SHOW,
`This is a no show email.`
);
updateEventPrefix(id, BookingStatusLabel.NO_SHOW);
};

Expand Down

0 comments on commit fc8eecc

Please sign in to comment.