diff --git a/apps/web/components/v2/eventtype/AvailabilityTab.tsx b/apps/web/components/v2/eventtype/AvailabilityTab.tsx new file mode 100644 index 0000000000..2e4bedb3a6 --- /dev/null +++ b/apps/web/components/v2/eventtype/AvailabilityTab.tsx @@ -0,0 +1,144 @@ +import { FormValues } from "pages/v2/event-types/[type]"; +import { Controller, useFormContext } from "react-hook-form"; + +import dayjs from "@calcom/dayjs"; +import classNames from "@calcom/lib/classNames"; +import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { weekdayNames } from "@calcom/lib/weekday"; +import { trpc } from "@calcom/trpc/react"; +import { Icon } from "@calcom/ui"; +import Button from "@calcom/ui/v2/core/Button"; +import Select from "@calcom/ui/v2/core/form/Select"; +import { SkeletonText } from "@calcom/ui/v2/core/skeleton"; + +import { AvailabilitySelectSkeletonLoader } from "@components/availability/SkeletonLoader"; + +type AvailabilityOption = { + label: string; + value: number; +}; + +const AvailabilitySelect = ({ + className = "", + ...props +}: { + className?: string; + name: string; + value: number; + onBlur: () => void; + onChange: (value: AvailabilityOption | null) => void; +}) => { + const { data, isLoading } = trpc.useQuery(["viewer.availability.list"]); + if (isLoading) { + return ; + } + + const schedules = data?.schedules || []; + + const options = schedules.map((schedule) => ({ + value: schedule.id, + label: schedule.name, + })); + + const value = options.find((option) => + props.value + ? option.value === props.value + : option.value === schedules.find((schedule) => schedule.isDefault)?.id + ); + + return ( +