enable bill storing

This commit is contained in:
Thomas Ruoff
2020-10-05 00:09:05 +02:00
committed by Thomas Ruoff
parent df6ec51af9
commit ec1b2e9629
7 changed files with 152 additions and 109 deletions

View File

@@ -0,0 +1,33 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { BillDocument } from '../../../../db/bill'
import { createBill } from '../../../../db/index'
export default async function userHandler(
req: NextApiRequest,
res: NextApiResponse
) {
const {
method,
query: { uuid: uuids },
} = req
const bookingUUID = Array.isArray(uuids) ? uuids[0] : uuids
let bill: BillDocument
switch (method) {
case 'POST':
try {
bill = await createBill(bookingUUID, req.body)
res.status(200).json(bill)
} catch (e) {
console.error(e)
res.status(500).end(`Internal Server Error...Guru is meditating...`)
return
}
break
default:
res.setHeader('Allow', ['POST'])
res.status(405).end(`Method ${method} Not Allowed`)
}
}

View File

@@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { BookingDocument } from '../../../db/booking'
import { BOOKING_STATUS } from '../../../db/enums'
import { getBookingByUUID } from '../../../db/index'
import { BookingDocument } from '../../../../db/booking'
import { BOOKING_STATUS } from '../../../../db/enums'
import { getBookingByUUID } from '../../../../db/index'
export default async function userHandler(
req: NextApiRequest,