Skip to content

Commit

Permalink
change approver emails subject line
Browse files Browse the repository at this point in the history
  • Loading branch information
lucia-gomez committed Apr 3, 2024
1 parent f50a5be commit 8bb06fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export default function useSubmitBooking(): [
'approval_email',
contents,
recipient,
subject,
BookingStatusLabel.REQUESTED,
contents.title,
''
)
);
Expand Down
9 changes: 8 additions & 1 deletion media_commons_booking_app/src/server/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ export const approveBooking = (id: string) => {
const subject = 'Second Approval Request';
const contents = bookingContents(id);
const recipient = getSecondApproverEmail(process.env.BRANCH_NAME);
sendHTMLEmail('approval_email', contents, recipient, subject, '');
sendHTMLEmail(
'approval_email',
contents,
recipient,
BookingStatusLabel.PRE_APPROVED,
contents.title,
''
);
}
};

Expand Down
10 changes: 6 additions & 4 deletions media_commons_booking_app/src/server/emails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@ import { Booking, BookingStatusLabel } from '../types';
export const sendTextEmail = (
targetEmail: string,
status: BookingStatusLabel,
title: string,
eventTitle: string,
body: string
) => {
const subj = `${status}: Media Commons request for \"${title}\"`;
const subj = `${status}: Media Commons request for \"${eventTitle}\"`;
GmailApp.sendEmail(targetEmail, subj, body);
};

export const sendHTMLEmail = (
templateName: string,
contents: Booking,
targetEmail: string,
title: string,
status: BookingStatusLabel,
eventTitle: string,
body
) => {
console.log('contents', contents);
const subj = `${status}: Media Commons request for \"${eventTitle}\"`;
const htmlTemplate = HtmlService.createTemplateFromFile(templateName);
for (const key in contents) {
htmlTemplate[key] = contents[key] || '';
Expand All @@ -26,5 +28,5 @@ export const sendHTMLEmail = (
const options = {
htmlBody,
};
GmailApp.sendEmail(targetEmail, title, body, options);
GmailApp.sendEmail(targetEmail, subj, body, options);
};

1 comment on commit 8bb06fb

@lucia-gomez
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.