use strings for startDate endDate

all the way to the FE
This commit is contained in:
Thomas Ruoff
2020-11-06 23:52:00 +01:00
parent e4e56ce96a
commit 088ca3ea5b

View File

@@ -1,6 +1,5 @@
import * as mongoose from 'mongoose'
import { v4 as uuidv4 } from 'uuid'
import { startOfDay } from 'date-fns'
import { dateFormatBackend, getDays } from '../helpers/date'
import { Bill } from './bill'
import { Booker } from './booker'
@@ -10,8 +9,8 @@ export interface Booking {
uuid: string
booker: Booker
bill: Bill
startDate: Date
endDate: Date
startDate: string
endDate: string
status: BOOKING_STATUS
purpose?: string
org?: string
@@ -94,7 +93,8 @@ BookingSchema.static('findBookedDays', async function (): Promise<string[]> {
.find(
{
status: { $in: [BOOKING_STATUS.REQUESTED, BOOKING_STATUS.CONFIRMED] },
endDate: { $gt: startOfDay(new Date()) },
// dateFormatBackend uses YYYY-MM-DD, which is startOfDay anyway
endDate: { $gt: dateFormatBackend(new Date()) },
},
'days'
)