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