import { RefreshCw } from 'lucide-react';
import type React from 'react';
import { useTranslation } from '../../i18n';
import ToggleSwitch from '../Settings/ToggleSwitch';
import { fs } from '../shared/DialogShell';
import type { JourneyRecordingPrepState } from './useJourneyRecordingPrep';
/**
* The owner's switch for preparing the recorded days (JRN-03) in the desktop
* journey settings, a row among the map switches. `rowClass` is the row look
* of the list it sits in.
*/
export function JourneyRecordingPrepRow({
on,
prep,
rowClass,
}: {
on: boolean;
prep: JourneyRecordingPrepState;
rowClass: string;
}): React.ReactElement {
const { t } = useTranslation();
return (
{t('journey.settings.autoPrepare')}
{t('journey.settings.autoPrepareHint')}
{
if (!prep.saving) void prep.setEnabled(!on);
}}
label={t('journey.settings.autoPrepare')}
/>
);
}
/**
* Under the switches: how the caller's own preparation stands, in warning
* colour when something keeps it from working, with a fetch by hand where one
* would reach anything. Nothing while the switch is off.
*/
export function JourneyRecordingPrepStatus({ prep }: { prep: JourneyRecordingPrepState }): React.ReactElement | null {
const { t } = useTranslation();
const line = prep.statusLine;
if (!line) return null;
return (