Skip to content

Commit 724e3f2

Browse files
apsinghdevkeithwillcodekart1kaRyukemeisterDevanshusharma2005
authored
fix: type error in the EventAvailabilityTabPlatformWrapper component (#21983)
* fix: add required props in scheduleQueryData * chore: remove any to fix runtime type checking * chore: add a fallback to avoid runtime err --------- Co-authored-by: Keith Williams <keithwillcode@gmail.com> Co-authored-by: Kartik Saini <41051387+kart1ka@users.noreply.github.com> Co-authored-by: Rajiv Sahal <sahalrajiv-extc@atharvacoe.ac.in> Co-authored-by: Devanshu Sharma <devanshusharma658@gmail.com>
1 parent 59c7614 commit 724e3f2

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

packages/features/eventtypes/components/tabs/availability/EventAvailabilityTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { Icon } from "@calcom/ui/components/icon";
3535
import { Spinner } from "@calcom/ui/components/icon";
3636
import { SkeletonText } from "@calcom/ui/components/skeleton";
3737

38-
type ScheduleQueryData = RouterOutputs["viewer"]["availability"]["schedule"]["get"];
38+
export type ScheduleQueryData = RouterOutputs["viewer"]["availability"]["schedule"]["get"];
3939

4040
type AvailabilityTableCustomClassNames = {
4141
tableContainer?: string;

packages/platform/atoms/event-types/wrappers/EventAvailabilityTabPlatformWrapper.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { useFormContext } from "react-hook-form";
22

33
import type { EventAvailabilityTabCustomClassNames } from "@calcom/features/eventtypes/components/tabs/availability/EventAvailabilityTab";
44
import { EventAvailabilityTab } from "@calcom/features/eventtypes/components/tabs/availability/EventAvailabilityTab";
5+
import type { ScheduleQueryData } from "@calcom/features/eventtypes/components/tabs/availability/EventAvailabilityTab";
56
import type { EventTypeSetup, FormValues } from "@calcom/features/eventtypes/lib/types";
67
import type { User } from "@calcom/prisma/client";
78

8-
import type { Availability } from "../../availability/AvailabilitySettings";
99
import { useAtomSchedule } from "../../hooks/schedules/useAtomSchedule";
1010
import { useSchedules } from "../../hooks/schedules/useSchedules";
1111
import { useTeamMembers } from "../../hooks/teams/useTeamMembers";
@@ -54,22 +54,21 @@ const EventAvailabilityTabPlatformWrapper = ({
5454
isSchedulePending={isSchedulePending}
5555
hostSchedulesQuery={({ userId }: { userId: number }) => hostSchedulesQuery({ userId, teamId })}
5656
scheduleQueryData={{
57+
...atomSchedule,
5758
isManaged: atomSchedule.isManaged,
5859
readOnly: atomSchedule.readOnly,
5960
id: atomSchedule.id,
6061
timeZone: atomSchedule.timeZone,
61-
schedule:
62-
atomSchedule.schedule.reduce(
63-
(acc: Availability[], avail: Availability) => [
64-
...acc,
65-
{
66-
startTime: new Date(avail.startTime),
67-
endTime: new Date(avail.endTime),
68-
days: avail.days,
69-
},
70-
],
71-
[]
72-
) || [],
62+
schedule: (atomSchedule.schedule || []).map((avail: ScheduleQueryData["schedule"][number]) => ({
63+
id: avail.id ?? null,
64+
startTime: new Date(avail.startTime),
65+
endTime: new Date(avail.endTime),
66+
userId: avail.userId ?? null,
67+
eventTypeId: avail.eventTypeId ?? null,
68+
scheduleId: avail.scheduleId ?? null,
69+
date: avail.date ? new Date(avail.date) : null,
70+
days: avail.days,
71+
})),
7372
}}
7473
/>
7574
);

0 commit comments

Comments
 (0)