Skip to content

Scheduling infrastructure for absolutely everyone.

Updated team to also use getWorkingHours (#1188)

Alex van Andeld6dd13a9d8cf
diff --git a/pages/team/[slug]/[type].tsx b/pages/team/[slug]/[type].tsx
index 797be2743be..8f9e8725e70 100644
--- a/pages/team/[slug]/[type].tsx
+++ b/pages/team/[slug]/[type].tsx
@@ -1,6 +1,7 @@
import { GetServerSidePropsContext } from "next";
import { asStringOrNull } from "@lib/asStringOrNull";
+import { getWorkingHours } from "@lib/availability";
import prisma from "@lib/prisma";
import { inferSSRProps } from "@lib/types/inferSSRProps";
@@ -74,26 +75,12 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
const [eventType] = team.eventTypes;
- type Availability = typeof eventType["availability"];
- const getWorkingHours = (availability: Availability) =>
- availability?.length
- ? availability.map((schedule) => ({
- ...schedule,
- startTime: schedule.startTime.getUTCHours() * 60 + schedule.startTime.getUTCMinutes(),
- endTime: schedule.endTime.getUTCHours() * 60 + schedule.endTime.getUTCMinutes(),
- }))
- : null;
- const workingHours =
- getWorkingHours(eventType.availability) ||
- [
- {
- days: [0, 1, 2, 3, 4, 5, 6],
- startTime: 0,
- endTime: 1440,
- },
- ].filter((availability): boolean => typeof availability["days"] !== "undefined");
-
- workingHours.sort((a, b) => a.startTime - b.startTime);
+ const workingHours = getWorkingHours(
+ {
+ timeZone: eventType.timeZone || undefined,
+ },
+ eventType.availability
+ );
const eventTypeObject = Object.assign({}, eventType, {
periodStartDate: eventType.periodStartDate?.toString() ?? null,