mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
show booking date in mails
This commit is contained in:
12
helpers/date.test.ts
Normal file
12
helpers/date.test.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { daysFormatFrontend } from './date'
|
||||||
|
|
||||||
|
test('daysFormatFrontend', () => {
|
||||||
|
expect(daysFormatFrontend([])).toEqual('')
|
||||||
|
expect(daysFormatFrontend(['2020-01-01'])).toEqual('01.01.2020')
|
||||||
|
expect(daysFormatFrontend(['2020-01-01', '2020-01-02'])).toEqual(
|
||||||
|
'01.01.2020-02.01.2020'
|
||||||
|
)
|
||||||
|
expect(
|
||||||
|
daysFormatFrontend(['2020-01-01', '2020-01-02', '2020-01-05'])
|
||||||
|
).toEqual('01.01.2020-05.01.2020')
|
||||||
|
})
|
||||||
@@ -3,6 +3,20 @@ import { parse, format, addDays } from 'date-fns'
|
|||||||
const FRONTEND_FORMAT = 'dd.MM.yyyy'
|
const FRONTEND_FORMAT = 'dd.MM.yyyy'
|
||||||
const BACKEND_FORMAT = 'yyyy-MM-dd'
|
const BACKEND_FORMAT = 'yyyy-MM-dd'
|
||||||
|
|
||||||
|
export function daysFormatFrontend(days: string[]) {
|
||||||
|
if (days.length === 0) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
if (days.length === 1) {
|
||||||
|
return dateFormatFrontend(new Date(days[0]))
|
||||||
|
}
|
||||||
|
|
||||||
|
return [days[0], days.slice(-1)]
|
||||||
|
.map((day: string) => dateFormatFrontend(new Date(day)))
|
||||||
|
.join('-')
|
||||||
|
}
|
||||||
|
|
||||||
export function getDays({
|
export function getDays({
|
||||||
startDate,
|
startDate,
|
||||||
endDate,
|
endDate,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Booking } from '../db/booking'
|
import { Booking } from '../db/booking'
|
||||||
import { getBaseURL } from '../helpers/url'
|
import { getBaseURL } from '../helpers/url'
|
||||||
|
import { daysFormatFrontend } from './date'
|
||||||
|
|
||||||
const SENDGRID_API_KEY = process.env.SENDGRID_API_KEY
|
const SENDGRID_API_KEY = process.env.SENDGRID_API_KEY
|
||||||
const ADMIN_EMAIL = process.env.ADMIN_EMAIL
|
const ADMIN_EMAIL = process.env.ADMIN_EMAIL
|
||||||
@@ -31,7 +32,9 @@ Tel. 0151/212 253 62
|
|||||||
function getReceivedBookingBookerText(booking: Booking) {
|
function getReceivedBookingBookerText(booking: Booking) {
|
||||||
return `Hallo liebe/r ${booking.booker.name},
|
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!
|
Vielen Dank für Deine Buchungsanfrage zum ${daysFormatFrontend(booking.days)}!
|
||||||
|
|
||||||
|
Nach Prüfung bestätigen wir die Buchung bald per E-Mail!
|
||||||
|
|
||||||
Du kannst sie jederzeit unter
|
Du kannst sie jederzeit unter
|
||||||
|
|
||||||
@@ -46,7 +49,9 @@ ${footer}
|
|||||||
function getBookingConfirmedText(booking: Booking) {
|
function getBookingConfirmedText(booking: Booking) {
|
||||||
return `Hallo liebe/r ${booking.booker.name},
|
return `Hallo liebe/r ${booking.booker.name},
|
||||||
|
|
||||||
deine Buchung ist bestätigt!
|
deine Buchunganfrage zum ${daysFormatFrontend(
|
||||||
|
booking.days
|
||||||
|
)} bestätigen wir gerne!
|
||||||
|
|
||||||
Bitte melde dich spätestens 7 Tage vor dem Buchungstermin per E-Mail oder Telefon
|
Bitte melde dich spätestens 7 Tage vor dem Buchungstermin per E-Mail oder Telefon
|
||||||
um eine Schlüsselübergabe zu vereinbaren.
|
um eine Schlüsselübergabe zu vereinbaren.
|
||||||
@@ -60,7 +65,9 @@ ${footer}
|
|||||||
function getBookingRejectedText(booking: Booking) {
|
function getBookingRejectedText(booking: Booking) {
|
||||||
return `Hallo liebe/r ${booking.booker.name},
|
return `Hallo liebe/r ${booking.booker.name},
|
||||||
|
|
||||||
es tut uns leid aber deine Buchung konnte leider nicht bestätigt werden.
|
es tut uns leid aber deine Buchungsanfrage zum ${daysFormatFrontend(
|
||||||
|
booking.days
|
||||||
|
)} konnten wir leider nicht bestätigen.
|
||||||
|
|
||||||
Willst du das Bussle an einem anderen Termin buchen? Dann stelle bitte nochmal
|
Willst du das Bussle an einem anderen Termin buchen? Dann stelle bitte nochmal
|
||||||
eine Buchungsanfrage auf ${getBaseURL()}.
|
eine Buchungsanfrage auf ${getBaseURL()}.
|
||||||
|
|||||||
Reference in New Issue
Block a user