From 2c50781084da0f407b8ed52ccaaffa18ef591741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20L=C3=B3pez?= Date: Thu, 23 Sep 2021 12:03:07 -0600 Subject: [PATCH] Makes every day available for events that don't have availability set (#756) * Abstracts MinutesField * Adds missing Minimum booking notice * Refactoring * Fixes int field sent as string * Sorts slots by time * Fixes availability page * Fixes available days * Type fixes * More availability bugfixes * Makes every day available for events that don't have availability set * Type fixes --- pages/api/availability/[user].ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pages/api/availability/[user].ts b/pages/api/availability/[user].ts index 7058cd347a..875f7757e0 100644 --- a/pages/api/availability/[user].ts +++ b/pages/api/availability/[user].ts @@ -65,7 +65,15 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) })); const timeZone = eventType?.timeZone || currentUser.timeZone; - const workingHours = eventType?.availability.length ? eventType.availability : currentUser.availability; + const defaultAvailability = { + startTime: currentUser.startTime, + endTime: currentUser.endTime, + days: [0, 1, 2, 3, 4, 5, 6], + }; + const workingHours = eventType?.availability.length + ? eventType.availability + : // currentUser.availability /* note(zomars) There's no UI nor default for this as of today */ + [defaultAvailability]; /* note(zomars) For now, make every day available as fallback */ res.status(200).json({ busy: bufferedBusyTimes,