Skip to content

Commit

Permalink
Send notification emails when user cancel the booking
Browse files Browse the repository at this point in the history
  • Loading branch information
rlho committed Dec 6, 2024
1 parent c8b9104 commit f6fb791
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions booking-app/components/src/server/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@ import {
OperationHours,
} from "../types";

import {
ApproverLevel,
TableNames,
clientGetFinalApproverEmail,
getCancelCcEmail,
} from "../policy";
import { Timestamp, where } from "@firebase/firestore";
import {
clientFetchAllDataFromCollection,
clientGetDataByCalendarEventId,
clientSaveDataToFirestore,
clientUpdateDataInFirestore,
getPaginatedData,
} from "@/lib/firebase/firebase";
import { Timestamp, where } from "@firebase/firestore";
import {
ApproverLevel,
TableNames,
clientGetFinalApproverEmail,
getApprovalCcEmail,
getCancelCcEmail,
} from "../policy";

import { clientUpdateDataByCalendarEventId } from "@/lib/firebase/client/clientDb";
import { getBookingToolDeployUrl } from "./ui";
import { roundTimeUp } from "../client/utils/date";
import { getBookingToolDeployUrl } from "./ui";

export const fetchAllFutureBooking = async <Booking>(): Promise<Booking[]> => {
const now = Timestamp.now();
Expand All @@ -34,10 +35,17 @@ export const fetchAllFutureBooking = async <Booking>(): Promise<Booking[]> => {
);
};

export const fetchAllBookings = async <Booking>(limit:number, last:any) : Promise<Booking[]> =>{
return getPaginatedData<Booking>(TableNames.BOOKING, limit, "requestedAt", last);
}

export const fetchAllBookings = async <Booking>(
limit: number,
last: any
): Promise<Booking[]> => {
return getPaginatedData<Booking>(
TableNames.BOOKING,
limit,
"requestedAt",
last
);
};

export const getOldSafetyTrainingEmails = () => {
//TODO: implement this
Expand Down Expand Up @@ -125,6 +133,12 @@ export const cancel = async (id: string, email: string) => {
headerMessage,
BookingStatusLabel.CANCELED
);
clientSendBookingDetailEmail(
id,
getApprovalCcEmail(process.env.NEXT_PUBLIC_BRANCH_NAME),
headerMessage,
BookingStatusLabel.NO_SHOW
);
clientSendBookingDetailEmail(
id,
getCancelCcEmail(),
Expand Down Expand Up @@ -292,6 +306,12 @@ export const noShow = async (id: string, email: string) => {
headerMessage,
BookingStatusLabel.NO_SHOW
);
clientSendBookingDetailEmail(
id,
getApprovalCcEmail(process.env.NEXT_PUBLIC_BRANCH_NAME),
headerMessage,
BookingStatusLabel.NO_SHOW
);
clientSendConfirmationEmail(
id,
BookingStatusLabel.NO_SHOW,
Expand Down

0 comments on commit f6fb791

Please sign in to comment.