switch to prisma

This commit is contained in:
Thomas Ruoff
2022-10-11 11:43:32 +02:00
parent 41342475ba
commit 1ef9b14e95
28 changed files with 764 additions and 780 deletions

View File

@@ -1,7 +1,7 @@
import { Booking } from '../db/booking'
import { Booking, Prisma } from '@prisma/client';
import { getBaseURL } from '../helpers/url'
import { log } from '../helpers/log'
import { daysFormatFrontend } from './date'
import { dateFormatFrontend } from './date'
import { generateCalendarEntry } from './ical'
import sgMail from '@sendgrid/mail'
@@ -34,10 +34,11 @@ Tel. 0151/212 253 62
${getBaseURL()}
`
function getReceivedBookingBookerText(booking: Booking): string {
function getReceivedBookingBookerText(booking: Prisma.BookingCreateInput): string {
return `Hallo liebe/r ${booking.name},
Vielen Dank für Deine Buchungsanfrage zum ${daysFormatFrontend(booking.days)}!
Vielen Dank für Deine Buchungsanfrage vom
${dateFormatFrontend(new Date(booking.startDate))} bis ${dateFormatFrontend(new Date(booking.endDate))}
Nach Prüfung bestätigen wir die Buchung bald per E-Mail!
@@ -54,9 +55,9 @@ ${footer}
function getBookingConfirmedText(booking: Booking): string {
return `Hallo liebe/r ${booking.name},
deine Buchunganfrage zum ${daysFormatFrontend(
booking.days
)} bestätigen wir gerne!
deine Buchunganfrage vom
${dateFormatFrontend(new Date(booking.startDate))} bis ${dateFormatFrontend(new Date(booking.endDate))}
bestätigen wir gerne!
Bitte melde dich spätestens 7 Tage vor dem Buchungstermin per E-Mail oder Telefon
um eine Schlüsselübergabe zu vereinbaren.
@@ -71,9 +72,9 @@ ${footer}
function getBookingRejectedText(booking: Booking): string {
return `Hallo liebe/r ${booking.name},
es tut uns leid, aber deine Buchungsanfrage zum ${daysFormatFrontend(
booking.days
)} konnten wir leider nicht bestätigen.
es tut uns leid, aber deine Buchungsanfrage vom
${dateFormatFrontend(new Date(booking.startDate))} bis ${dateFormatFrontend(new Date(booking.endDate))}
konnten wir leider nicht bestätigen.
Willst du das Bussle an einem anderen Termin buchen? Dann stelle bitte nochmal
eine Buchungsanfrage auf ${getBaseURL()}.
@@ -85,7 +86,9 @@ ${footer}
function getBookingCanceledText(booking: Booking): string {
return `Hallo liebe/r ${booking.name},
deine Buchungsanfrage zum ${daysFormatFrontend(booking.days)} wurde storniert.
deine Buchungsanfrage vom
${dateFormatFrontend(new Date(booking.startDate))} bis ${dateFormatFrontend(new Date(booking.endDate))}
wurde storniert.
Willst du das Bussle an einem anderen Termin buchen? Dann stelle bitte nochmal
eine Buchungsanfrage auf ${getBaseURL()}.
@@ -109,7 +112,7 @@ export async function sendReceivedBookingAdminMail(
await sendMail({
to: [{ email: ADMIN_EMAIL }],
from: { email: FROM_EMAIL, name: 'Pfadi-Bussle Wart' },
subject: `Buchung für ${booking.days} eingegangen!`,
subject: `Buchung für ${booking.startDate}-${booking.endDate} eingegangen!`,
textPlainContent: getReceivedBookingAdminText(booking),
})
} catch (error) {
@@ -118,7 +121,7 @@ export async function sendReceivedBookingAdminMail(
}
export async function sendReceivedBookingBookerMail(
booking: Booking
booking: Prisma.BookingCreateInput
): Promise<void> {
try {
await sendMail({