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:
@@ -2,12 +2,11 @@ import React from 'react'
|
|||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
|
|
||||||
import { daysFormatFrontend } from '../helpers/date'
|
import { daysFormatFrontend } from '../helpers/date'
|
||||||
import { BookingDocument } from '../db/booking'
|
|
||||||
|
|
||||||
export default function BookingTable({
|
export default function BookingTable({
|
||||||
booking,
|
booking,
|
||||||
}: {
|
}: {
|
||||||
booking: BookingDocument
|
booking: Booking
|
||||||
}) {
|
}) {
|
||||||
const data = [
|
const data = [
|
||||||
{ name: 'Status', value: booking.status },
|
{ name: 'Status', value: booking.status },
|
||||||
@@ -58,9 +57,8 @@ export default function BookingTable({
|
|||||||
{data.map(({ name, value }, index) => (
|
{data.map(({ name, value }, index) => (
|
||||||
<div
|
<div
|
||||||
key={`${booking.uuid}-${name}`}
|
key={`${booking.uuid}-${name}`}
|
||||||
className={`${
|
className={`${index % 2 === 1 ? 'bg-white' : 'bg-gray-100'
|
||||||
index % 2 === 1 ? 'bg-white' : 'bg-gray-100'
|
} px-2 py-3 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6`}
|
||||||
} px-2 py-3 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6`}
|
|
||||||
>
|
>
|
||||||
<dt className="text-sm font-medium text-gray-500">{name}</dt>
|
<dt className="text-sm font-medium text-gray-500">{name}</dt>
|
||||||
<dd className="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
|
<dd className="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
|
||||||
@@ -72,4 +70,4 @@ export default function BookingTable({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -4,10 +4,10 @@ import Link from 'next/link'
|
|||||||
import Calendar from '../../../../components/calendar'
|
import Calendar from '../../../../components/calendar'
|
||||||
import { getServerSideBooking } from '../../../../lib/getServerSideProps'
|
import { getServerSideBooking } from '../../../../lib/getServerSideProps'
|
||||||
import { Booking } from '../../../../db/booking'
|
import { Booking } from '../../../../db/booking'
|
||||||
import { getBookingStatus, patchBooking } from '../../../../helpers/booking'
|
import { patchBooking } from '../../../../helpers/booking'
|
||||||
import { daysFormatFrontend } from '../../../../helpers/date'
|
|
||||||
import { log } from '../../../../helpers/log'
|
import { log } from '../../../../helpers/log'
|
||||||
import { BOOKING_STATUS } from '../../../../db/enums'
|
import { BOOKING_STATUS } from '../../../../db/enums'
|
||||||
|
import BookingTable from '../../../../components/bookingTable'
|
||||||
|
|
||||||
export const getServerSideProps = getServerSideBooking
|
export const getServerSideProps = getServerSideBooking
|
||||||
|
|
||||||
@@ -20,13 +20,11 @@ function ShowBookingAdmin({ booking: bookingProp }: { booking: Booking }) {
|
|||||||
// in case the props change, update the internal state
|
// in case the props change, update the internal state
|
||||||
useEffect(() => setBooking(bookingProp), [bookingProp])
|
useEffect(() => setBooking(bookingProp), [bookingProp])
|
||||||
|
|
||||||
const onStoreBooking = async (confirmed: boolean) => {
|
const patchBookingStatus = async (status: BOOKING_STATUS) => {
|
||||||
try {
|
try {
|
||||||
setStoringBookingError(null)
|
setStoringBookingError(null)
|
||||||
setStoringBooking(true)
|
setStoringBooking(true)
|
||||||
const updatedBooking = await patchBooking(booking.uuid, {
|
const updatedBooking = await patchBooking(booking.uuid, { status })
|
||||||
status: confirmed ? BOOKING_STATUS.CONFIRMED : BOOKING_STATUS.REJECTED,
|
|
||||||
})
|
|
||||||
setBooking(updatedBooking)
|
setBooking(updatedBooking)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setStoringBookingError('Buchung konnte nicht gespeichert werden.')
|
setStoringBookingError('Buchung konnte nicht gespeichert werden.')
|
||||||
@@ -39,28 +37,27 @@ function ShowBookingAdmin({ booking: bookingProp }: { booking: Booking }) {
|
|||||||
<>
|
<>
|
||||||
<h2 className="text-3xl">Buchung {booking.uuid}</h2>
|
<h2 className="text-3xl">Buchung {booking.uuid}</h2>
|
||||||
<Calendar start={booking.startDate} end={booking.endDate} />
|
<Calendar start={booking.startDate} end={booking.endDate} />
|
||||||
<div>
|
<BookingTable booking={booking} />
|
||||||
<strong>Buchungszeitraum:</strong> {daysFormatFrontend(booking.days)}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<strong>Bucher:</strong> {booking.name}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<strong>Buchungsstatus:</strong> {getBookingStatus(booking.status)}
|
|
||||||
</div>
|
|
||||||
{storingBookingError && (
|
{storingBookingError && (
|
||||||
<div className="error-message flex-grow">{storingBookingError}</div>
|
<div className="error-message flex-grow">{storingBookingError}</div>
|
||||||
)}
|
)}
|
||||||
<div className="my-6">
|
<div className="my-6">
|
||||||
<button
|
<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"
|
className="btn btn-blue"
|
||||||
disabled={storingBooking}
|
disabled={storingBooking}
|
||||||
>
|
>
|
||||||
Buchung Bestätigen
|
Buchung Bestätigen
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => onStoreBooking(false)}
|
onClick={() => patchBookingStatus(BOOKING_STATUS.REJECTED)}
|
||||||
className="btn btn-red"
|
className="btn btn-red"
|
||||||
disabled={storingBooking}
|
disabled={storingBooking}
|
||||||
>
|
>
|
||||||
@@ -76,4 +73,4 @@ function ShowBookingAdmin({ booking: bookingProp }: { booking: Booking }) {
|
|||||||
|
|
||||||
ShowBookingAdmin.authenticationRequired = true
|
ShowBookingAdmin.authenticationRequired = true
|
||||||
|
|
||||||
export default ShowBookingAdmin
|
export default ShowBookingAdmin
|
||||||
@@ -32,6 +32,10 @@
|
|||||||
@apply ml-0;
|
@apply ml-0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-green {
|
||||||
|
@apply bg-green-800 text-white;
|
||||||
|
}
|
||||||
|
|
||||||
.btn-blue {
|
.btn-blue {
|
||||||
@apply bg-blue-800 text-white;
|
@apply bg-blue-800 text-white;
|
||||||
}
|
}
|
||||||
@@ -181,4 +185,4 @@
|
|||||||
|
|
||||||
/* Start purging... */
|
/* Start purging... */
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
/* Stop purging. */
|
/* Stop purging. */
|
||||||
Reference in New Issue
Block a user