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