import { useState } from 'react' import { Moon } from 'lucide-react' import { useTranslation } from '../../i18n/TranslationContext' import ToggleSwitch from '../Settings/ToggleSwitch' export interface EndDayControlProps { active: boolean /** * Whatever it resolves to is ignored here: this control reads its state back from the * trip. The writer reports success to callers that flip a switch optimistically, and the * type has to let that through. */ onToggle: () => Promise } export default function EndDayControl({ active, onToggle }: EndDayControlProps) { const { t } = useTranslation() const [pending, setPending] = useState(false) return (
{t('roadtrip.window.endHere')} { if (pending) return setPending(true) try { await onToggle() } finally { setPending(false) } }} />
) }