mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-04 06:57:12 +01:00
switch to prisma
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { createEvents, createEvent, EventStatus } from 'ics'
|
||||
import { Booking } from '../db/booking'
|
||||
import { BOOKING_STATUS } from '../db/enums'
|
||||
import { Booking, BookingStatus} from '@prisma/client';
|
||||
import { getBaseURL } from './url'
|
||||
import { daysFormatFrontend } from './date'
|
||||
import { dateFormatFrontend, getDayCount } from './date'
|
||||
|
||||
function convertDay(value: string): [number, number, number] {
|
||||
const parts = value.split('-')
|
||||
@@ -16,9 +15,9 @@ export function generateCalendarEntry(booking: Booking): string {
|
||||
const { error, value } = createEvent({
|
||||
productId: 'app.vercel.pfadi-bussle/ics',
|
||||
title: `Pfadi-Bussle Buchung`,
|
||||
start: convertDay(booking.days[0]),
|
||||
start: convertDay(booking.startDate),
|
||||
startOutputType: 'local',
|
||||
duration: { days: booking.days.length },
|
||||
duration: { days: getDayCount(booking) },
|
||||
location: 'Mömpelgardgasse 25, 72348 Rosenfeld, Deutschland',
|
||||
geo: { lat: 48.287044, lon: 8.726361 },
|
||||
description: `Gebucht auf ${booking.name}
|
||||
@@ -26,7 +25,7 @@ export function generateCalendarEntry(booking: Booking): string {
|
||||
Buchungs-Link: ${getBaseURL()}/bookings/${booking.uuid}
|
||||
`,
|
||||
status:
|
||||
booking.status === BOOKING_STATUS.CONFIRMED
|
||||
booking.status === BookingStatus.CONFIRMED
|
||||
? ('CONFIRMED' as EventStatus)
|
||||
: ('TENTATIVE' as EventStatus),
|
||||
})
|
||||
@@ -54,12 +53,12 @@ export function generateBookedCalendar(bookings: Booking[]): string {
|
||||
} => ({
|
||||
productId: 'app.vercel.pfadi-bussle/ics',
|
||||
calName: 'Pfadi-Bussle Buchungen',
|
||||
start: convertDay(booking.days[0]),
|
||||
start: convertDay(booking.startDate),
|
||||
startOutputType: 'local',
|
||||
duration: { days: booking.days.length },
|
||||
duration: { days: getDayCount(booking) },
|
||||
title: `Buchung ${booking.name}`,
|
||||
description: `Name: ${booking.name}
|
||||
Zeitraum: ${daysFormatFrontend(booking.days)}
|
||||
Zeitraum: ${dateFormatFrontend(new Date(booking.startDate))}-${dateFormatFrontend(new Date(booking.endDate))}
|
||||
|
||||
Email: ${booking.email}
|
||||
Telefon: ${booking.phone}
|
||||
@@ -67,7 +66,7 @@ Telefon: ${booking.phone}
|
||||
Link: ${getBaseURL()}/admin/bookings/${booking.uuid}
|
||||
`,
|
||||
status:
|
||||
booking.status === BOOKING_STATUS.CONFIRMED
|
||||
booking.status === BookingStatus.CONFIRMED
|
||||
? ('CONFIRMED' as EventStatus)
|
||||
: ('TENTATIVE' as EventStatus),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user