import { useEffect, useState, useCallback } from "react"; import { useTranslation } from "react-i18next"; import type { YjsState } from "~/lib/use-yjs"; const PROFILE_IDS = ["trekking", "fastbike", "safety", "shortest", "car"] as const; interface ProfileSelectorProps { yjs: YjsState; } export function ProfileSelector({ yjs }: ProfileSelectorProps) { const { t } = useTranslation("planner"); const [profile, setProfile] = useState("trekking"); useEffect(() => { const update = () => { const p = yjs.routeData.get("profile") as string | undefined; if (p) setProfile(p); }; yjs.routeData.observe(update); update(); return () => yjs.routeData.unobserve(update); }, [yjs.routeData]); const handleChange = useCallback( (e: React.ChangeEvent) => { const value = e.target.value; setProfile(value); yjs.routeData.set("profile", value); }, [yjs.routeData], ); return (
); }