mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-04 23:17:12 +01:00
add booking status to bill
This commit is contained in:
16
helpers/booking.ts
Normal file
16
helpers/booking.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { BOOKING_STATUS } from '../db/enums'
|
||||||
|
|
||||||
|
export function getBookingStatus(booking: { status: BOOKING_STATUS }) {
|
||||||
|
switch (booking.status) {
|
||||||
|
case BOOKING_STATUS.REQUESTED:
|
||||||
|
return 'Angefragt'
|
||||||
|
case BOOKING_STATUS.CONFIRMED:
|
||||||
|
return 'Bestätigt'
|
||||||
|
case BOOKING_STATUS.REJECTED:
|
||||||
|
return 'Abgewiesen'
|
||||||
|
case BOOKING_STATUS.CANCELED:
|
||||||
|
return 'Storniert'
|
||||||
|
default:
|
||||||
|
return 'Unbekannt - bitte kontaktieren Sie uns!'
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import { BILL_STATUS, MILAGE_TARIFS } from '../../../db/enums'
|
|||||||
import { getBookingByUUID, getMilageMax } from '../../../db/index'
|
import { getBookingByUUID, getMilageMax } from '../../../db/index'
|
||||||
import { dateFormatFrontend } from '../../../helpers/date'
|
import { dateFormatFrontend } from '../../../helpers/date'
|
||||||
import { getBillTotal } from '../../../helpers/bill'
|
import { getBillTotal } from '../../../helpers/bill'
|
||||||
|
import { getBookingStatus } from '../../../helpers/booking'
|
||||||
|
|
||||||
const milageTarifOptions = Object.values(MILAGE_TARIFS).map((tarif) => {
|
const milageTarifOptions = Object.values(MILAGE_TARIFS).map((tarif) => {
|
||||||
return (
|
return (
|
||||||
@@ -184,6 +185,9 @@ export default function BillPage({
|
|||||||
<div>
|
<div>
|
||||||
<strong>Bucher:</strong> {booking.booker.name}
|
<strong>Bucher:</strong> {booking.booker.name}
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<strong>Buchungsstatus:</strong> {getBookingStatus(booking)}
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Input
|
<Input
|
||||||
label="Anfangskilometer"
|
label="Anfangskilometer"
|
||||||
|
|||||||
@@ -29,21 +29,6 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBookingStatus(booking: BookingDocument) {
|
|
||||||
switch (booking.status) {
|
|
||||||
case BOOKING_STATUS.REQUESTED:
|
|
||||||
return 'In Bearbeitung'
|
|
||||||
case BOOKING_STATUS.CONFIRMED:
|
|
||||||
return 'Bestätigt'
|
|
||||||
case BOOKING_STATUS.REJECTED:
|
|
||||||
return 'Abgewiesen'
|
|
||||||
case BOOKING_STATUS.CANCELED:
|
|
||||||
return 'Storniert'
|
|
||||||
default:
|
|
||||||
return 'Unbekannt - bitte kontaktieren Sie uns!'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function cancelBooking(booking: BookingDocument) {
|
async function cancelBooking(booking: BookingDocument) {
|
||||||
const response = await fetch(`/api/booking/${booking.uuid}`, {
|
const response = await fetch(`/api/booking/${booking.uuid}`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
|
|||||||
Reference in New Issue
Block a user