diff --git a/components/bookingTable.tsx b/components/bookingTable.tsx index cf01be4..ecff4f8 100644 --- a/components/bookingTable.tsx +++ b/components/bookingTable.tsx @@ -2,12 +2,11 @@ import React from 'react' import Link from 'next/link' import { daysFormatFrontend } from '../helpers/date' -import { BookingDocument } from '../db/booking' export default function BookingTable({ booking, }: { - booking: BookingDocument + booking: Booking }) { const data = [ { name: 'Status', value: booking.status }, @@ -58,9 +57,8 @@ export default function BookingTable({ {data.map(({ name, value }, index) => (
{name}
@@ -72,4 +70,4 @@ export default function BookingTable({
) -} +} \ No newline at end of file diff --git a/pages/admin/bookings/[uuid]/index.tsx b/pages/admin/bookings/[uuid]/index.tsx index 211127c..56f2387 100644 --- a/pages/admin/bookings/[uuid]/index.tsx +++ b/pages/admin/bookings/[uuid]/index.tsx @@ -4,10 +4,10 @@ import Link from 'next/link' import Calendar from '../../../../components/calendar' import { getServerSideBooking } from '../../../../lib/getServerSideProps' import { Booking } from '../../../../db/booking' -import { getBookingStatus, patchBooking } from '../../../../helpers/booking' -import { daysFormatFrontend } from '../../../../helpers/date' +import { patchBooking } from '../../../../helpers/booking' import { log } from '../../../../helpers/log' import { BOOKING_STATUS } from '../../../../db/enums' +import BookingTable from '../../../../components/bookingTable' export const getServerSideProps = getServerSideBooking @@ -20,13 +20,11 @@ function ShowBookingAdmin({ booking: bookingProp }: { booking: Booking }) { // in case the props change, update the internal state useEffect(() => setBooking(bookingProp), [bookingProp]) - const onStoreBooking = async (confirmed: boolean) => { + const patchBookingStatus = async (status: BOOKING_STATUS) => { try { setStoringBookingError(null) setStoringBooking(true) - const updatedBooking = await patchBooking(booking.uuid, { - status: confirmed ? BOOKING_STATUS.CONFIRMED : BOOKING_STATUS.REJECTED, - }) + const updatedBooking = await patchBooking(booking.uuid, { status }) setBooking(updatedBooking) } catch (error) { setStoringBookingError('Buchung konnte nicht gespeichert werden.') @@ -39,28 +37,27 @@ function ShowBookingAdmin({ booking: bookingProp }: { booking: Booking }) { <>

Buchung {booking.uuid}

-
- Buchungszeitraum: {daysFormatFrontend(booking.days)} -
-
- Bucher: {booking.name} -
-
- Buchungsstatus: {getBookingStatus(booking.status)} -
+ {storingBookingError && (
{storingBookingError}
)}
+