import dayjs from "@calcom/dayjs"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import type { RouterOutputs } from "@calcom/trpc/react"; import type { TimeRange, WorkingHours } from "@calcom/types/schedule"; import { Button, DialogTrigger, Tooltip } from "@calcom/ui"; import DateOverrideInputDialog from "./DateOverrideInputDialog"; const sortByDate = (a: { ranges: TimeRange[]; id: string }, b: { ranges: TimeRange[]; id: string }) => { return a.ranges[0].start > b.ranges[0].start ? 1 : -1; }; // I would like this to be decoupled, but RHF really doesn't support this. const DateOverrideList = ({ workingHours, excludedDates = [], travelSchedules = [], userTimeFormat, hour12, replace, fields, weekStart = 0, }: { // eslint-disable-next-line @typescript-eslint/no-explicit-any replace: any; fields: { ranges: TimeRange[]; id: string }[]; workingHours: WorkingHours[]; excludedDates?: string[]; userTimeFormat: number | null; hour12: boolean; travelSchedules?: RouterOutputs["viewer"]["getTravelSchedules"]; weekStart?: 0 | 1 | 2 | 3 | 4 | 5 | 6; }) => { const { t, i18n } = useLocale(); const unsortedFieldArrayMap = fields.reduce( (map: { [id: string]: number }, { id }, index) => ({ ...map, [id]: index }), {} ); if (!fields.length) { return <>; } const timeSpan = ({ start, end }: TimeRange) => { return `${new Intl.DateTimeFormat(i18n.language, { hour: "numeric", minute: "numeric", hour12 }).format( new Date(start.toISOString().slice(0, -1)) )} - ${new Intl.DateTimeFormat(i18n.language, { hour: "numeric", minute: "numeric", hour12 }).format( new Date(end.toISOString().slice(0, -1)) )}`; }; return ( ); }; export default DateOverrideList;