From 59aea7f8af681a514a961c07734b7172feb08020 Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Thu, 31 Mar 2022 22:57:47 +0200 Subject: [PATCH] fix date conversion in bookings api --- helpers/booking.ts | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/helpers/booking.ts b/helpers/booking.ts index adda804..fc90592 100644 --- a/helpers/booking.ts +++ b/helpers/booking.ts @@ -3,18 +3,6 @@ import { BOOKING_STATUS } from '../db/enums' import { dateFormatBackend } from './date'; import fetch from './fetch' -function getBody(formData: Partial) { - const body: any = { - ...formData, - }; - - // if existend, convert dates to TZ less YYYY-MM-DD format - body.startDate && (body.startDate = dateFormatBackend(body.startDate)) - body.endDate && (body.endDate = dateFormatBackend(body.endDate)) - - return body; -} - export function getBookingStatus(status: BOOKING_STATUS) { switch (status) { case BOOKING_STATUS.REQUESTED: @@ -33,7 +21,7 @@ export function getBookingStatus(status: BOOKING_STATUS) { export async function createBooking(formData: BookFormData) { return fetch('/api/bookings', { method: 'POST', - body: getBody(formData), + body: formData, }) } @@ -47,6 +35,6 @@ export async function cancelBooking(uuid: string) { export async function patchBooking(uuid: string, bookingData: Partial) { return fetch(`/api/bookings/${uuid}`, { method: 'PATCH', - body: getBody(bookingData), + body: bookingData, }) }