mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 22:47:15 +01:00
43 lines
1015 B
TypeScript
43 lines
1015 B
TypeScript
import { BookFormData } from '../context/book'
|
|
import { BOOKING_STATUS } from '../db/enums'
|
|
import fetch from './fetch'
|
|
|
|
export function getBookingStatus(status: BOOKING_STATUS) {
|
|
switch (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!'
|
|
}
|
|
}
|
|
|
|
export async function createBooking(formData: BookFormData) {
|
|
return fetch('/api/bookings', {
|
|
method: 'POST',
|
|
body: formData,
|
|
})
|
|
}
|
|
|
|
export async function cancelBooking(uuid: string) {
|
|
return fetch(`/api/bookings/${uuid}`, {
|
|
method: 'PATCH',
|
|
body: { status: BOOKING_STATUS.CANCELED },
|
|
})
|
|
}
|
|
|
|
export async function patchBooking(
|
|
uuid: string,
|
|
bookingData: Partial<BookFormData>
|
|
) {
|
|
return fetch(`/api/bookings/${uuid}`, {
|
|
method: 'PATCH',
|
|
body: bookingData,
|
|
})
|
|
}
|