mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
allow sending email again
This commit is contained in:
@@ -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 }) {
|
||||
<>
|
||||
<h2 className="text-3xl">Buchung {booking.uuid}</h2>
|
||||
<Calendar start={booking.startDate} end={booking.endDate} />
|
||||
<div>
|
||||
<strong>Buchungszeitraum:</strong> {daysFormatFrontend(booking.days)}
|
||||
</div>
|
||||
<div>
|
||||
<strong>Bucher:</strong> {booking.name}
|
||||
</div>
|
||||
<div>
|
||||
<strong>Buchungsstatus:</strong> {getBookingStatus(booking.status)}
|
||||
</div>
|
||||
<BookingTable booking={booking} />
|
||||
{storingBookingError && (
|
||||
<div className="error-message flex-grow">{storingBookingError}</div>
|
||||
)}
|
||||
<div className="my-6">
|
||||
<button
|
||||
onClick={() => onStoreBooking(true)}
|
||||
onClick={() => patchBookingStatus(BOOKING_STATUS.REQUESTED)}
|
||||
className="btn btn-green"
|
||||
disabled={storingBooking}
|
||||
>
|
||||
Zurück auf Requested
|
||||
</button>
|
||||
<button
|
||||
onClick={() => patchBookingStatus(BOOKING_STATUS.CONFIRMED)}
|
||||
className="btn btn-blue"
|
||||
disabled={storingBooking}
|
||||
>
|
||||
Buchung Bestätigen
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onStoreBooking(false)}
|
||||
onClick={() => patchBookingStatus(BOOKING_STATUS.REJECTED)}
|
||||
className="btn btn-red"
|
||||
disabled={storingBooking}
|
||||
>
|
||||
@@ -76,4 +73,4 @@ function ShowBookingAdmin({ booking: bookingProp }: { booking: Booking }) {
|
||||
|
||||
ShowBookingAdmin.authenticationRequired = true
|
||||
|
||||
export default ShowBookingAdmin
|
||||
export default ShowBookingAdmin
|
||||
Reference in New Issue
Block a user