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
24
pages/api/daysbooked.ical.tsx
Normal file
24
pages/api/daysbooked.ical.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { getBookings } from '../../db/index'
|
||||
import { generateBookedCalendar } from '../../helpers/ical'
|
||||
|
||||
export default async function useHandler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
const { method } = req
|
||||
|
||||
switch (method) {
|
||||
case 'GET':
|
||||
const bookings = await getBookings()
|
||||
const ical = generateBookedCalendar(bookings)
|
||||
res.statusCode = 200
|
||||
//res.set('Content-Type', 'text/calendar;charset=utf-8')
|
||||
//res.set('Content-Disposition', 'attachment; filename="pfadi-bussle.ics"')
|
||||
res.send(ical)
|
||||
break
|
||||
default:
|
||||
res.setHeader('Allow', ['GET'])
|
||||
res.status(405).end(`Method ${method} Not Allowed`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user