"use client"; import { usePathname, useRouter } from "next/navigation"; import { useCallback, useMemo } from "react"; import { useCompatSearchParams } from "@calcom/embed-core/src/useCompatSearchParams"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { Select, ToggleGroup } from "@calcom/ui/components/form"; export enum OutOfOfficeTab { MINE = "mine", TEAM = "team", HOLIDAYS = "holidays", } export const OutOfOfficeToggleGroup = () => { const { t } = useLocale(); const searchParams = useCompatSearchParams(); const router = useRouter(); const pathname = usePathname(); const createQueryString = useCallback( (name: string, value: string) => { const params = new URLSearchParams(searchParams ?? undefined); params.set(name, value); return params.toString(); }, [searchParams] ); const selectedTab = searchParams?.get("type") ?? OutOfOfficeTab.MINE; const tabOptions = useMemo( () => [ { value: OutOfOfficeTab.MINE, label: t("my_ooo") }, { value: OutOfOfficeTab.TEAM, label: t("team_ooo") }, { value: OutOfOfficeTab.HOLIDAYS, label: t("holidays") }, ], [t] ); const handleTabChange = useCallback( (value: string | null) => { if (!value) return; const newQuery = createQueryString("type", value); router.push(`${pathname}?${newQuery}`); }, [createQueryString, pathname, router] ); const selectedOption = useMemo( () => tabOptions.find((opt) => opt.value === selectedTab) ?? tabOptions[0], [selectedTab, tabOptions] ); return ( <> {/* Mobile: Select dropdown */}