Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send email to user when status is changed #116

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion media_commons_booking_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"deploy:staging": "rimraf dist && npm run build:staging && npx clasp push",
"deploy": "rimraf dist && npm run build && npx clasp push",
"serve": "cross-env NODE_ENV=development CALENDAR_ENV=development webpack serve",
"start": "npm run deploy:dev && npm run serve"
"start": "npm run deploy:local && npm run serve"
},
"keywords": [
"react",
Expand Down
38 changes: 36 additions & 2 deletions media_commons_booking_app/src/server/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from './db';
import { inviteUserToCalendarEvent, updateEventPrefix } from './calendars';

import { sendHTMLEmail } from './emails';
import { sendHTMLEmail, sendTextEmail } from './emails';

export const bookingContents = (id: string) => {
const values = fetchById(TableNames.BOOKING, id);
Expand Down Expand Up @@ -112,6 +112,11 @@ export const approveEvent = (id: string) => {
id,
ActiveSheetBookingStatusColumns.EMAIL
);
sendTextEmail(
guestEmail,
'Media Commons Reservation Approved',
'Your reservation request for Media Commons is approved.'
);

updateEventPrefix(id, 'APPROVED');
inviteUserToCalendarEvent(id, guestEmail);
Expand All @@ -125,7 +130,16 @@ export const reject = (id: string) => {
new Date()
);

//TODO: send email to user
const guestEmail = getActiveSheetValueById(
TableNames.BOOKING_STATUS,
id,
ActiveSheetBookingStatusColumns.EMAIL
);
sendTextEmail(
guestEmail,
'Media Commons Reservation Has Been Rejected',
'Your reservation request for Media Commons has been rejected. For detailed reasons regarding this decision, please contact us at [email protected].'
);
updateEventPrefix(id, 'REJECTED');
};

Expand All @@ -136,6 +150,16 @@ export const cancel = (id: string) => {
ActiveSheetBookingStatusColumns.CANCELLED_DATE,
new Date()
);
const guestEmail = getActiveSheetValueById(
TableNames.BOOKING_STATUS,
id,
ActiveSheetBookingStatusColumns.EMAIL
);
sendTextEmail(
guestEmail,
'Media Commons Reservation Has Been Cancelled',
'Your reservation request for Media Commons has been cancelled. For detailed reasons regarding this decision, please contact us at [email protected].'
);
updateEventPrefix(id, 'CANCELLED');
};

Expand All @@ -146,6 +170,16 @@ export const checkin = (id: string) => {
ActiveSheetBookingStatusColumns.CHECKED_IN_DATE,
new Date()
);
const guestEmail = getActiveSheetValueById(
TableNames.BOOKING_STATUS,
id,
ActiveSheetBookingStatusColumns.EMAIL
);
sendTextEmail(
guestEmail,
'Media Commons Reservation Has Been Checked In',
'Your reservation request for Media Commons has been checked in. Thank you for choosing Media Commons.'
);
updateEventPrefix(id, 'CHECKED IN');
};

Expand Down
Loading