mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-04 15:07:13 +01:00
further code improvements
This commit is contained in:
committed by
Thomas Ruoff
parent
52a68e9989
commit
4b16e07985
@@ -4,15 +4,25 @@ import Footer from '../../components/footer'
|
||||
import Header from '../../components/header'
|
||||
import { Booking } from '../../db/booking'
|
||||
import { BOOKING_STATUS } from '../../db/bookingStatus'
|
||||
import { getBookingByUUIDAsJSON } from '../../db/index'
|
||||
import { getBookingByUUID } from '../../db/index'
|
||||
import { dateFormatFrontend } from '../../helpers/date'
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async (context) => {
|
||||
const { uuids } = context.params
|
||||
const {
|
||||
res,
|
||||
params: { uuid: uuids },
|
||||
} = context
|
||||
const uuid = Array.isArray(uuids) ? uuids[0] : uuids
|
||||
const booking = await getBookingByUUIDAsJSON(uuid)
|
||||
const booking = await getBookingByUUID(uuid)
|
||||
|
||||
if (!booking) {
|
||||
res.statusCode = 404
|
||||
res.end()
|
||||
return { props: {} }
|
||||
}
|
||||
|
||||
// TODO: hack, not sure why _id is not serilizable
|
||||
const bookingJSON = JSON.parse(JSON.stringify(booking))
|
||||
const bookingJSON = JSON.parse(JSON.stringify(booking.toJSON()))
|
||||
return {
|
||||
props: { booking: bookingJSON },
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user