Skip to content

Commit

Permalink
Include booking details in the request email
Browse files Browse the repository at this point in the history
  • Loading branch information
rlho committed Apr 4, 2024
1 parent cbfe67e commit 257d773
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,15 @@ export default function useSubmitBooking(): [
alert('Your request has been sent.');
navigate('/');

serverFunctions.sendTextEmail(
const headerMessage =
'Your reservation is not yet confirmed. The coordinator will review and finalize your reservation within a few days.';
serverFunctions.sendBookingDetailEmail(
calendarEventId,
email,
BookingStatusLabel.REQUESTED,
data.title,
'Your reservation is not yet confirmed. The coordinator will review and finalize your reservation within a few days.'
headerMessage,
BookingStatusLabel.REQUESTED
);

setLoading(false);
reloadBookings();
reloadBookingStatuses();
Expand Down
66 changes: 37 additions & 29 deletions media_commons_booking_app/src/server/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export const approveBooking = (id: string) => {
} else {
firstApprove(id);

//TODO: send email to user
updateEventPrefix(id, BookingStatusLabel.PRE_APPROVED);

const contents = bookingContents(id);
Expand All @@ -84,9 +83,14 @@ export const bookingTitle = (id: string) =>

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

export const sendBookingDetailEmail = (id, email, headerMessage, status) => {
const title = bookingTitle(id);
const contents = bookingContents(id);
contents.headerMessage = 'This is confirmation email.';
contents.headerMessage = headerMessage;
console.log('contents', contents);
sendHTMLEmail('booking_detail', contents, email, status, title, '');
};
Expand All @@ -97,12 +101,14 @@ export const approveEvent = (id: string) => {
id,
ActiveSheetBookingStatusColumns.EMAIL
);
const eventTitle = getActiveSheetValueById(TableNames.BOOKING, id, 16);
sendTextEmail(

const headerMessage =
'Your reservation request for Media Commons is approved.';
sendBookingDetailEmail(
id,
guestEmail,
BookingStatusLabel.APPROVED,
eventTitle,
'Your reservation request for Media Commons is approved.'
headerMessage,
BookingStatusLabel.APPROVED
);
sendConfirmationEmail(id, BookingStatusLabel.APPROVED);

Expand All @@ -123,13 +129,13 @@ export const reject = (id: string) => {
id,
ActiveSheetBookingStatusColumns.EMAIL
);
const eventTitle = getActiveSheetValueById(TableNames.BOOKING, id, 16);

sendTextEmail(
const headerMessage =
'Your reservation request for Media Commons has been rejected. For detailed reasons regarding this decision, please contact us at [email protected].';
sendBookingDetailEmail(
id,
guestEmail,
BookingStatusLabel.REJECTED,
eventTitle,
'Your reservation request for Media Commons has been rejected. For detailed reasons regarding this decision, please contact us at [email protected].'
headerMessage,
BookingStatusLabel.REJECTED
);
updateEventPrefix(id, BookingStatusLabel.REJECTED);
};
Expand All @@ -146,13 +152,13 @@ export const cancel = (id: string) => {
id,
ActiveSheetBookingStatusColumns.EMAIL
);
const eventTitle = getActiveSheetValueById(TableNames.BOOKING, id, 16);

sendTextEmail(
const headerMessage =
'Your reservation request for Media Commons has been cancelled. For detailed reasons regarding this decision, please contact us at [email protected].';
sendBookingDetailEmail(
id,
guestEmail,
BookingStatusLabel.CANCELED,
eventTitle,
'Your reservation request for Media Commons has been cancelled. For detailed reasons regarding this decision, please contact us at [email protected].'
headerMessage,
BookingStatusLabel.CANCELED
);
sendConfirmationEmail(id, BookingStatusLabel.CANCELED);
updateEventPrefix(id, BookingStatusLabel.CANCELED);
Expand All @@ -170,13 +176,14 @@ export const checkin = (id: string) => {
id,
ActiveSheetBookingStatusColumns.EMAIL
);
const eventTitle = getActiveSheetValueById(TableNames.BOOKING, id, 16);

sendTextEmail(
const headerMessage =
'Your reservation request for Media Commons has been checked in. Thank you for choosing Media Commons.';
sendBookingDetailEmail(
id,
guestEmail,
BookingStatusLabel.CHECKED_IN,
eventTitle,
'Your reservation request for Media Commons has been checked in. Thank you for choosing Media Commons.'
headerMessage,
BookingStatusLabel.CHECKED_IN
);
updateEventPrefix(id, BookingStatusLabel.CHECKED_IN);
};
Expand All @@ -193,13 +200,14 @@ export const noShow = (id: string) => {
id,
ActiveSheetBookingStatusColumns.EMAIL
);
const eventTitle = getActiveSheetValueById(TableNames.BOOKING, id, 16);

sendTextEmail(
const headerMessage =
'You did not check-in for your Media Commons Reservation and have been marked as a no-show.';
sendBookingDetailEmail(
id,
guestEmail,
BookingStatusLabel.NO_SHOW,
eventTitle,
'You did not check-in for your Media Commons Reservation and have been marked as a no-show.'
headerMessage,
BookingStatusLabel.NO_SHOW
);
sendConfirmationEmail(id, BookingStatusLabel.NO_SHOW);
updateEventPrefix(id, BookingStatusLabel.NO_SHOW);
Expand Down
3 changes: 2 additions & 1 deletion media_commons_booking_app/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
noShow,
reject,
removeFromListByEmail,
sendBookingDetailEmail,
} from './admin';
import { sendHTMLEmail, sendTextEmail } from './emails';

Expand Down Expand Up @@ -53,7 +54,6 @@ export {
// email
sendHTMLEmail,
sendTextEmail,

// admin
approveBooking,
reject,
Expand All @@ -62,4 +62,5 @@ export {
noShow,
approveInstantBooking,
removeFromListByEmail,
sendBookingDetailEmail,
};

0 comments on commit 257d773

Please sign in to comment.