mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
firt attempt for an ics calendar
This commit is contained in:
committed by
Thomas Ruoff
parent
2b0cbe565f
commit
56c8263e90
20
helpers/ical.ts
Normal file
20
helpers/ical.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { createEvents } from 'ics'
|
||||
import { BookingDocument } from '../db/booking'
|
||||
|
||||
export function generateBookedCalendar(bookings: BookingDocument[]) {
|
||||
const events = bookings.map((booking) => ({
|
||||
title: `Buchung ${booking.booker.name}`,
|
||||
description: `UUID: ${booking.uuid}
|
||||
Link: http://${process.env.VERCEL_URL}/booking/${booking.uuid}`,
|
||||
start: booking.days[0].split('-'),
|
||||
end: booking.days[booking.days.length - 1].split('-'),
|
||||
}))
|
||||
// ts-ignore
|
||||
const { error, value } = createEvents(events)
|
||||
|
||||
if (error) {
|
||||
throw new Error(error)
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
Reference in New Issue
Block a user