import type { UseFieldArrayRemove } from "react-hook-form"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery"; import type { TimeRange, WorkingHours } from "@calcom/types/schedule"; import { Button, DialogTrigger, Tooltip } from "@calcom/ui"; import { FiEdit2, FiTrash2 } from "@calcom/ui/components/icon"; 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; }; const useSettings = () => { const { data } = useMeQuery(); return { hour12: data?.timeFormat === 12, timeZone: data?.timeZone, }; }; const DateOverrideList = ({ items, remove, update, workingHours, excludedDates = [], }: { remove: UseFieldArrayRemove; // eslint-disable-next-line @typescript-eslint/no-explicit-any update: any; items: { ranges: TimeRange[]; id: string }[]; workingHours: WorkingHours[]; excludedDates?: string[]; }) => { const { t, i18n } = useLocale(); const { hour12 } = useSettings(); if (!items.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 (
{t("unavailable")}
) : ( item.ranges.map((range, i) => ({timeSpan(range)}
)) )}