mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 22:47:15 +01:00
add /booking/uuid
This commit is contained in:
20
pages/api/booking/[uuid].js
Normal file
20
pages/api/booking/[uuid].js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { getBookingByUUID, createBooking } from '../../../db/index'
|
||||
|
||||
export default async function userHandler(req, res) {
|
||||
const {
|
||||
method,
|
||||
query: { uuid },
|
||||
} = req
|
||||
|
||||
let booking
|
||||
|
||||
switch (method) {
|
||||
case 'GET':
|
||||
booking = await getBookingByUUID(uuid)
|
||||
res.status(200).json(booking)
|
||||
break
|
||||
default:
|
||||
res.setHeader('Allow', ['POST'])
|
||||
res.status(405).end(`Method ${method} Not Allowed`)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createBooking } from '../../db/index'
|
||||
import { createBooking } from '../../../db/index'
|
||||
import { Error } from 'mongoose'
|
||||
|
||||
import { sendReceivedBookingMail } from '../../helpers/mail'
|
||||
import { sendReceivedBookingMail } from '../../../helpers/mail'
|
||||
|
||||
export default async function userHandler(req, res) {
|
||||
const { method } = req
|
||||
@@ -1,9 +1,14 @@
|
||||
import React, { useContext } from 'react'
|
||||
import { AppContext } from '../../context/appStore'
|
||||
|
||||
import { WizardContext } from '../../context/wizardStore'
|
||||
import Footer from '../../components/footer'
|
||||
|
||||
// TODO: load booking somehow if we navigate to booking
|
||||
// TODO: when storing data take loaded booking instead of fromData
|
||||
// TODO: show state of booking and minimal data
|
||||
|
||||
export default function Booking() {
|
||||
const { state, storeData } = useContext(AppContext)
|
||||
const { state, storeData } = useContext(WizardContext)
|
||||
const { dataStored, dataStoredLoaded } = state
|
||||
|
||||
return (
|
||||
@@ -11,7 +16,7 @@ export default function Booking() {
|
||||
<main className="flex-grow">
|
||||
<h1 className="text-3xl">Pfadi Bussle Buchung</h1>
|
||||
|
||||
<h3>Danke, die Buchung ist in Bearbeitung!</h3>
|
||||
<h3>Vielen Dank für die Buchung!</h3>
|
||||
<p>Nach Prüfung bestätigen wir die Buchung bald per E-Mail!</p>
|
||||
{!dataStoredLoaded && typeof dataStored !== 'boolean' && (
|
||||
<>
|
||||
@@ -33,6 +38,7 @@ export default function Booking() {
|
||||
{dataStored === true && (
|
||||
<p>Ok, die Daten wurden für die nächste Buchung gespeichert.</p>
|
||||
)}
|
||||
<div>{JSON.stringify(state.booking, null, 4)}</div>
|
||||
</main>
|
||||
|
||||
<Footer />
|
||||
Reference in New Issue
Block a user