Add optional cancellation message for notifications

This commit is contained in:
2026-01-12 21:42:52 +01:00
parent 62e1f5f1b4
commit cc2687dad8
5 changed files with 67 additions and 7 deletions

View File

@@ -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)
}