mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
add an admin overview page
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { getBookingByUUID } from '../db/index'
|
||||
import { startOfYear } from 'date-fns'
|
||||
import { nowInTz } from '../helpers/date'
|
||||
import { getBookingByUUID, getBookings } from '../db/index'
|
||||
|
||||
export interface ServerSideBooking {
|
||||
props: {
|
||||
@@ -6,6 +8,30 @@ export interface ServerSideBooking {
|
||||
}
|
||||
}
|
||||
|
||||
export interface ServerSideRecentBooking {
|
||||
props: {
|
||||
bookings: object[]
|
||||
}
|
||||
}
|
||||
|
||||
export const getServerSideRecentBookings = async (): Promise<
|
||||
ServerSideRecentBooking
|
||||
> => {
|
||||
const bookings = await getBookings({
|
||||
startDateGreaterThan: startOfYear(nowInTz()).toISOString(),
|
||||
})
|
||||
|
||||
// TODO: hack, not sure why _id is not serilizable
|
||||
const bookingsJSON = JSON.parse(
|
||||
JSON.stringify(bookings.map((b) => b.toJSON()))
|
||||
) as object[]
|
||||
return {
|
||||
props: {
|
||||
bookings: bookingsJSON,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export const getServerSideBooking = async (
|
||||
context: any
|
||||
): Promise<ServerSideBooking> => {
|
||||
|
||||
Reference in New Issue
Block a user