mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 14:37:13 +01:00
39 lines
948 B
TypeScript
39 lines
948 B
TypeScript
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: object) {
|
|
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: object) {
|
|
return fetch(`/api/bookings/${uuid}`, {
|
|
method: 'PATCH',
|
|
body: { ...bookingData },
|
|
})
|
|
}
|