mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-04 15:07:13 +01:00
move CRUD operations to helpers
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { BOOKING_STATUS } from '../db/enums'
|
||||
import fetch from './fetch'
|
||||
|
||||
export function getBookingStatus(status: BOOKING_STATUS) {
|
||||
switch (status) {
|
||||
@@ -14,3 +15,24 @@ export function getBookingStatus(status: BOOKING_STATUS) {
|
||||
return 'Unbekannt - bitte kontaktieren Sie uns!'
|
||||
}
|
||||
}
|
||||
|
||||
export async function createBooking(formData: object) {
|
||||
return fetch('/api/booking', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
}
|
||||
|
||||
export async function cancelBooking(uuid: string) {
|
||||
return fetch(`/api/booking/${uuid}`, {
|
||||
method: 'PATCH',
|
||||
body: { status: BOOKING_STATUS.CANCELED },
|
||||
})
|
||||
}
|
||||
|
||||
export async function patchBooking(uuid: string, bookingData: object) {
|
||||
return fetch(`/api/admin/booking/${uuid}`, {
|
||||
method: 'PATCH',
|
||||
body: { ...bookingData },
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user