import { useEffect } from "react"; import { useBookerStore } from "@calcom/features/bookings/Booker/store"; import classNames from "@calcom/lib/classNames"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { Badge } from "@calcom/ui"; import type { PublicEvent } from "../../types"; export const EventDuration = ({ event }: { event: PublicEvent }) => { const { t } = useLocale(); const [selectedDuration, setSelectedDuration] = useBookerStore((state) => [ state.selectedDuration, state.setSelectedDuration, ]); // Sets initial value of selected duration to the default duration. useEffect(() => { // Only store event duration in url if event has multiple durations. if (!selectedDuration && event.metadata?.multipleDuration) setSelectedDuration(event.length); }, [selectedDuration, setSelectedDuration, event.length, event.metadata?.multipleDuration]); if (!event?.metadata?.multipleDuration) return <>{t("multiple_duration_mins", { count: event.length })}; return (
{event.metadata.multipleDuration.map((duration) => ( setSelectedDuration(duration)}>{`${duration} ${t("minute_timeUnit")}`} ))}
); };