fix: get slot logic for v1 API (#16620)

* fix faulty slug match

* Allow team event slot

* pass it to getSchedule

---------

Co-authored-by: Keith Williams <[email protected]>
This commit is contained in:
Syed Ali ShahbazandKeith Williams authored and GitHub committed 2024-09-13 16:34:03 +00:00
1 parent a5191d1e5a
commit e3b478f5b1
5 files changed
+39 -39

No files matched your search

+3 -2
View File
@@ -27,12 +27,13 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
isColdStart = false;
}
const { usernameList, ...rest } = req.query;
const { usernameList, isTeamEvent, ...rest } = req.query;
const parsedIsTeamEvent = String(isTeamEvent).toLowerCase() === "true";
let slugs = usernameList;
if (!Array.isArray(usernameList)) {
slugs = usernameList ? [usernameList] : undefined;
}
const input = getScheduleSchema.parse({ usernameList: slugs, ...rest });
const input = getScheduleSchema.parse({ usernameList: slugs, isTeamEvent: parsedIsTeamEvent, ...rest });
const timeZoneSupported = input.timeZone ? isSupportedTimeZone(input.timeZone) : false;
const availableSlots = await getAvailableSlots({ ctx: await createContext({ req, res }), input });
const slotsInProvidedTimeZone = timeZoneSupported