Missing dayjs().isBetween plugin + format Z explicitly
This commit is contained in:
		
							parent
							
								
									a4c1ac8275
								
							
						
					
					
						commit
						78de56b7f5
					
				
					 1 changed files with 6 additions and 4 deletions
				
			
		|  | @ -14,12 +14,14 @@ import logger from "../../../lib/logger"; | |||
| 
 | ||||
| import utc from "dayjs/plugin/utc"; | ||||
| import timezone from "dayjs/plugin/timezone"; | ||||
| import isBetween from "dayjs/plugin/isBetween"; | ||||
| import dayjsBusinessDays from "dayjs-business-days"; | ||||
| import { Exception } from "handlebars"; | ||||
| import EventOrganizerRequestMail from "@lib/emails/EventOrganizerRequestMail"; | ||||
| 
 | ||||
| dayjs.extend(dayjsBusinessDays); | ||||
| dayjs.extend(utc); | ||||
| dayjs.extend(isBetween); | ||||
| dayjs.extend(timezone); | ||||
| 
 | ||||
| const translator = short(); | ||||
|  | @ -28,7 +30,6 @@ const log = logger.getChildLogger({ prefix: ["[api] book:user"] }); | |||
| function isAvailable(busyTimes, time, length) { | ||||
|   // Check for conflicts
 | ||||
|   let t = true; | ||||
| 
 | ||||
|   if (Array.isArray(busyTimes) && busyTimes.length > 0) { | ||||
|     busyTimes.forEach((busyTime) => { | ||||
|       const startTime = dayjs(busyTime.start); | ||||
|  | @ -312,8 +313,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) | |||
| 
 | ||||
|     const calendarAvailability = await getBusyCalendarTimes( | ||||
|       currentUser.credentials, | ||||
|       dayjs(req.body.start).startOf("day").utc().format(), | ||||
|       dayjs(req.body.end).endOf("day").utc().format(), | ||||
|       dayjs(req.body.start).startOf("day").utc().format("YYYY-MM-DDTHH:mm:ss[Z]"), | ||||
|       dayjs(req.body.end).endOf("day").utc().format("YYYY-MM-DDTHH:mm:ss[Z]"), | ||||
|       selectedCalendars | ||||
|     ); | ||||
|     const videoAvailability = await getBusyVideoTimes( | ||||
|  | @ -412,7 +413,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) | |||
| 
 | ||||
|     try { | ||||
|       isAvailableToBeBooked = isAvailable(commonAvailability, req.body.start, selectedEventType.length); | ||||
|     } catch { | ||||
|     } catch (e) { | ||||
|       console.log(e); | ||||
|       log.debug({ | ||||
|         message: "Unable set isAvailableToBeBooked. Using true. ", | ||||
|       }); | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Alex van Andel
						Alex van Andel