move CRUD operations to helpers

This commit is contained in:
Thomas Ruoff
2021-06-07 23:32:54 +02:00
parent 865bbb20fa
commit 92477e5325
9 changed files with 102 additions and 93 deletions

View File

@@ -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 },
})
}