mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
add email to customer as well
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import { BookingDocument } from '../db/booking'
|
||||
import { getBaseURL } from '../helpers/url'
|
||||
|
||||
const SENDGRID_API_KEY = process.env.SENDGRID_API_KEY
|
||||
const ADMIN_EMAIL = process.env.ADMIN_EMAIL
|
||||
const FROM_EMAIL = process.env.FROM_EMAIL
|
||||
@@ -31,24 +34,63 @@ async function sendMail(data: object) {
|
||||
}
|
||||
}
|
||||
|
||||
function getReceivedBookingText(booking: { uuid: string }) {
|
||||
function getReceivedBookingAdminText(booking: { uuid: string }) {
|
||||
return `Hallo lieber Admin,
|
||||
|
||||
es ging folgende Buchung ein: {getBaseURL()}/booking/${booking.uuid}
|
||||
es ging folgende Buchung ein: ${getBaseURL()}/booking/${booking.uuid}
|
||||
|
||||
MfG`
|
||||
MfG`
|
||||
}
|
||||
|
||||
export async function sendReceivedBookingMail(booking: { uuid: string }) {
|
||||
export async function sendReceivedBookingAdminMail(booking: BookingDocument) {
|
||||
const data = {
|
||||
personalizations: [
|
||||
{
|
||||
to: [{ email: ADMIN_EMAIL }],
|
||||
},
|
||||
],
|
||||
from: { email: FROM_EMAIL },
|
||||
subject: `Pfadi Bussle - Buchung ${booking.uuid} eingegangen!`,
|
||||
content: [{ type: 'text/plain', value: getReceivedBookingText(booking) }],
|
||||
from: { email: FROM_EMAIL, name: "Pfadi-Bussle Wart" },
|
||||
subject: `Buchung für ${booking.days} eingegangen!`,
|
||||
content: [{ type: 'text/plain', value: getReceivedBookingAdminText(booking) }],
|
||||
}
|
||||
|
||||
try {
|
||||
await sendMail(data)
|
||||
} catch (error) {
|
||||
console.error(`Failed in sendReceivedBookingMail for ${booking.uuid}`)
|
||||
}
|
||||
}
|
||||
|
||||
function getReceivedBookingBookerText(booking: BookingDocument) {
|
||||
return `Hallo liebe/r ${booking.booker.name},
|
||||
|
||||
Vielen Dank für Deine Buchung. Nach Prüfung bestätigen wir die Buchung bald per E-Mail!
|
||||
|
||||
Du kannst sie jederzeit unter
|
||||
|
||||
${getBaseURL()}/booking/${booking.uuid}
|
||||
|
||||
einsehen und auch stornieren.
|
||||
|
||||
Viele Grüße
|
||||
|
||||
Thomas Ruoff
|
||||
Pfadi Bussle Wart
|
||||
|
||||
Tel. 0151/212 253 62
|
||||
`
|
||||
}
|
||||
|
||||
export async function sendReceivedBookingBookerMail(booking: BookingDocument) {
|
||||
const data = {
|
||||
personalizations: [
|
||||
{
|
||||
to: [{ email: booking.booker.email, name: booking.booker.name }],
|
||||
},
|
||||
],
|
||||
from: { email: FROM_EMAIL, name: "Pfadi-Bussle Wart" },
|
||||
subject: `Deine Buchung ist eingegangen!`,
|
||||
content: [{ type: 'text/plain', value: getReceivedBookingBookerText(booking) }],
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user