Add optional cancellation message for notifications
This commit is contained in:
@@ -50,7 +50,7 @@ export async function createBooking(planId: string, date: Date, name: string, ty
|
||||
revalidatePath(`/${lang}/dashboard/${planId}`)
|
||||
}
|
||||
|
||||
export async function deleteBooking(bookingId: number, planId: string, lang: string = "en") {
|
||||
export async function deleteBooking(bookingId: number, planId: string, lang: string = "en", reason?: string) {
|
||||
const dict = await getDictionary(lang as any)
|
||||
|
||||
const booking = await prisma.booking.findUnique({
|
||||
@@ -70,10 +70,12 @@ export async function deleteBooking(bookingId: number, planId: string, lang: str
|
||||
const planUrl = `${protocol}://${host}/${lang}/dashboard/${planId}`
|
||||
|
||||
const dateStr = booking.date.toLocaleDateString(lang)
|
||||
const messageDisplay = reason ? `\nMessage: ${reason}` : ""
|
||||
const message = dict.notifications.cancellation
|
||||
.replace("{name}", booking.sitterName || "Someone")
|
||||
.replace("{date}", dateStr)
|
||||
.replace("{url}", planUrl)
|
||||
.replace("{message}", messageDisplay)
|
||||
|
||||
await sendNotification(booking.plan.webhookUrl, message)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user