Skip to content

Commit

Permalink
Merge pull request #160 from ITPNYU/feature/email_template
Browse files Browse the repository at this point in the history
Feature/email template
  • Loading branch information
rlho authored Apr 4, 2024
2 parents d151e36 + a24d06e commit cbfe67e
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<!DOCTYPE html>
<html>
<head>
<style>
.container {
width: 100%;
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}

.button {
cursor: pointer;
outline: 0;
display: inline-block;
font-weight: 400;
line-height: 1.5;
text-align: center;
background-color: transparent;
border: 1px solid transparent;
padding: 6px 12px;
font-size: 1rem;
border-radius: 0.25rem;
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
color: #0d6efd;
border-color: #0d6efd;
:hover {
color: #fff;
background-color: #0d6efd;
border-color: #0d6efd;
}
}

.button:active {
background-color: #3e8e41;
box-shadow: 0 5px #666;
transform: translateY(4px);
}

.button-red {
padding: 8px 12px;
border: 1px solid #ed2939;
border-radius: 2px;
font-family: Helvetica, Arial, sans-serif;
font-size: 14px;
color: #ffffff;
text-decoration: none;
font-weight: bold;
display: inline-block;
}

.button-red:active {
background-color: #8b0000;
}
</style>
</head>
<body>
<div id="index"></div>
<div class="container"></div>
<div class="container">
<p><?= headerMessage ?></p>
<p>
Room Number:
<?= roomId ?>
</p>

<p>
Email:
<?= email ?>
</p>
<p>
Start date:
<?= startDate ?>
</p>
<p>
End date:
<?= endDate ?>
</p>
<p>
Secondary Point of Contact:
<?= secondaryName ?>
</p>
<p>
NYU N-number:
<?= nNumber ?>
</p>
<p>
Net Id:
<?= netId ?>
</p>
<p>
Phone Number:
<?= phoneNumber ?>
</p>
<p>
Department:
<?= department ?>
</p>
<p>
Requestor's Role:
<?= role?>
</p>
<p>
Sponsor First Name:
<?= sponsorFirstName ?>
</p>
<p>
Sponsor Last Name:
<?= sponsorLastName ?>
</p>
<p>
Sponsor Email:
<?= sponsorEmail ?>
</p>
<p>
Reservation Title:
<?= title ?>
</p>
<p>
Reservation Description:
<?= description ?>
</p>
<p>
Expected Attendance:
<?= expectedAttendance ?>
</p>
<p>
Attendee Affiliations:
<?= attendeeAffiliation ?>
</p>
<p>
Room setup needed?:
<?= roomSetup ?>
<?= setupDetails ?>
</p>
<p>
Chartfield for Room setup?:
<?= chartFieldForRoomSetup ?>
</p>
<p>
Media Services:
<?= mediaServices ?>
<?= mediaServicesDetails ?>
</p>
<p>
Catering:
<?= catering ?>
</p>
<p>
Catering Details:
<?= cateringService ?>
</p>
<p>
Chartfield for Catering?:
<?= chartFieldForCatering ?>
</p>
<p>
Hire Security:
<?= hireSecurity ?>
</p>
<p>
Chartfield for Hiring Security?:
<?= chartFieldForSecurity ?>
</p>
</div>
</body>
</html>
16 changes: 15 additions & 1 deletion media_commons_booking_app/src/server/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export const approveBooking = (id: string) => {
//TODO: send email to user
updateEventPrefix(id, BookingStatusLabel.PRE_APPROVED);

const subject = 'Second Approval Request';
const contents = bookingContents(id);
const recipient = getSecondApproverEmail(process.env.BRANCH_NAME);
sendHTMLEmail(
Expand All @@ -80,6 +79,18 @@ export const approveBooking = (id: string) => {
}
};

export const bookingTitle = (id: string) =>
getActiveSheetValueById(TableNames.BOOKING, id, 16);

export const sendConfirmationEmail = (id, status) => {
const email = getSecondApproverEmail(process.env.BRANCH_NAME);
const title = bookingTitle(id);
const contents = bookingContents(id);
contents.headerMessage = 'This is confirmation email.';
console.log('contents', contents);
sendHTMLEmail('booking_detail', contents, email, status, title, '');
};

export const approveEvent = (id: string) => {
const guestEmail = getActiveSheetValueById(
TableNames.BOOKING_STATUS,
Expand All @@ -93,6 +104,7 @@ export const approveEvent = (id: string) => {
eventTitle,
'Your reservation request for Media Commons is approved.'
);
sendConfirmationEmail(id, BookingStatusLabel.APPROVED);

updateEventPrefix(id, BookingStatusLabel.APPROVED);
inviteUserToCalendarEvent(id, guestEmail);
Expand Down Expand Up @@ -142,6 +154,7 @@ export const cancel = (id: string) => {
eventTitle,
'Your reservation request for Media Commons has been cancelled. For detailed reasons regarding this decision, please contact us at [email protected].'
);
sendConfirmationEmail(id, BookingStatusLabel.CANCELED);
updateEventPrefix(id, BookingStatusLabel.CANCELED);
};

Expand Down Expand Up @@ -188,6 +201,7 @@ export const noShow = (id: string) => {
eventTitle,
'You did not check-in for your Media Commons Reservation and have been marked as a no-show.'
);
sendConfirmationEmail(id, BookingStatusLabel.NO_SHOW);
updateEventPrefix(id, BookingStatusLabel.NO_SHOW);
};

Expand Down
5 changes: 5 additions & 0 deletions media_commons_booking_app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const serverEntry = './src/server/index.ts';
// define appsscript.json file path
const copyAppscriptEntry = './appsscript.json';
const copyEmailTemplate = './src/client/routes/booking/approval_email.html';
const BookinDetailTemplate = './src/client/routes/booking/booking_detail.html';

const copyApprovalEntry = './src/client/routes/approval.html';
const copyRejectedEntry = './src/client/routes/reject.html';
Expand Down Expand Up @@ -85,6 +86,10 @@ const copyFilesConfig = {
from: copyAppscriptEntry,
to: destination,
},
{
from: BookinDetailTemplate,
to: destination,
},
{
from: copyEmailTemplate,
to: destination,
Expand Down

0 comments on commit cbfe67e

Please sign in to comment.