From 724e3f2755df30de41e3050ddbf261b4a43ca691 Mon Sep 17 00:00:00 2001 From: Ajeet Pratap Singh Date: Thu, 28 Aug 2025 21:41:51 +0530 Subject: [PATCH] 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 Co-authored-by: Kartik Saini <41051387+kart1ka@users.noreply.github.com> Co-authored-by: Rajiv Sahal Co-authored-by: Devanshu Sharma --- .../availability/EventAvailabilityTab.tsx | 2 +- .../EventAvailabilityTabPlatformWrapper.tsx | 25 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/packages/features/eventtypes/components/tabs/availability/EventAvailabilityTab.tsx b/packages/features/eventtypes/components/tabs/availability/EventAvailabilityTab.tsx index f620d366c2..98bc0502ba 100644 --- a/packages/features/eventtypes/components/tabs/availability/EventAvailabilityTab.tsx +++ b/packages/features/eventtypes/components/tabs/availability/EventAvailabilityTab.tsx @@ -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; diff --git a/packages/platform/atoms/event-types/wrappers/EventAvailabilityTabPlatformWrapper.tsx b/packages/platform/atoms/event-types/wrappers/EventAvailabilityTabPlatformWrapper.tsx index 1424be8238..dd2098bdb3 100644 --- a/packages/platform/atoms/event-types/wrappers/EventAvailabilityTabPlatformWrapper.tsx +++ b/packages/platform/atoms/event-types/wrappers/EventAvailabilityTabPlatformWrapper.tsx @@ -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, + })), }} /> );