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>
This commit is contained in:
Ajeet Pratap Singh
2025-08-28 16:11:51 +00:00
committed by GitHub
co-authored by Keith Williams Kartik Saini Rajiv Sahal Devanshu Sharma
parent 59c76141ce
commit 724e3f2755
2 changed files with 13 additions and 14 deletions
@@ -35,7 +35,7 @@ import { Icon } from "@calcom/ui/components/icon";
import { Spinner } from "@calcom/ui/components/icon";
import { SkeletonText } from "@calcom/ui/components/skeleton";
type ScheduleQueryData = RouterOutputs["viewer"]["availability"]["schedule"]["get"];
export type ScheduleQueryData = RouterOutputs["viewer"]["availability"]["schedule"]["get"];
type AvailabilityTableCustomClassNames = {
tableContainer?: string;
@@ -2,10 +2,10 @@ import { useFormContext } from "react-hook-form";
import type { EventAvailabilityTabCustomClassNames } from "@calcom/features/eventtypes/components/tabs/availability/EventAvailabilityTab";
import { EventAvailabilityTab } from "@calcom/features/eventtypes/components/tabs/availability/EventAvailabilityTab";
import type { ScheduleQueryData } from "@calcom/features/eventtypes/components/tabs/availability/EventAvailabilityTab";
import type { EventTypeSetup, FormValues } from "@calcom/features/eventtypes/lib/types";
import type { User } from "@calcom/prisma/client";
import type { Availability } from "../../availability/AvailabilitySettings";
import { useAtomSchedule } from "../../hooks/schedules/useAtomSchedule";
import { useSchedules } from "../../hooks/schedules/useSchedules";
import { useTeamMembers } from "../../hooks/teams/useTeamMembers";
@@ -54,22 +54,21 @@ const EventAvailabilityTabPlatformWrapper = ({
isSchedulePending={isSchedulePending}
hostSchedulesQuery={({ userId }: { userId: number }) => hostSchedulesQuery({ userId, teamId })}
scheduleQueryData={{
...atomSchedule,
isManaged: atomSchedule.isManaged,
readOnly: atomSchedule.readOnly,
id: atomSchedule.id,
timeZone: atomSchedule.timeZone,
schedule:
atomSchedule.schedule.reduce(
(acc: Availability[], avail: Availability) => [
...acc,
{
startTime: new Date(avail.startTime),
endTime: new Date(avail.endTime),
days: avail.days,
},
],
[]
) || [],
schedule: (atomSchedule.schedule || []).map((avail: ScheduleQueryData["schedule"][number]) => ({
id: avail.id ?? null,
startTime: new Date(avail.startTime),
endTime: new Date(avail.endTime),
userId: avail.userId ?? null,
eventTypeId: avail.eventTypeId ?? null,
scheduleId: avail.scheduleId ?? null,
date: avail.date ? new Date(avail.date) : null,
days: avail.days,
})),
}}
/>
);