import React from 'react' import { Loader2, Save, Plug, RefreshCw, Unplug } from 'lucide-react' import { useTranslation } from '../../i18n' import { useFormatDate } from '../../hooks/useDateFormat' import { useDawarichConnection } from '../../hooks/useDawarichConnection' import DawarichIcon from '../shared/DawarichIcon' import Section from './Section' import ToggleSwitch from './ToggleSwitch' import { SETTINGS_BUTTON, SETTINGS_BUTTON_DANGER, SETTINGS_BUTTON_PRIMARY, SettingRow, SettingRows, StatusPill } from './settingsKit' import { EditorField, GRID_2, INPUT } from '../shared/dialogParts' import { fs } from '../shared/DialogShell' /** * Settings → Integrations → Dawarich. * * All of the behaviour is in `useDawarichConnection`, shared with the phone * twin; this file is markup. The layout follows the AirTrail and LLM sections * so the three read as one shelf: fields side by side, the switches as rows, * the actions under them and the connection state as a pill in the band. * * The status block below the fields is the part that earns its space: a * connection to somebody else's server fails in ways they can act on — a wrong * key, a certificate, an instance that is simply off — and "not connected" with * no reason is the version of this card that generates support questions. */ export default function DawarichConnectionSection(): React.ReactElement { const { t } = useTranslation() const S = useDawarichConnection() return ( }> {S.connected ? t('dawarich.connected') : t('dawarich.notConnected')} } >
{state.probeMessage}
} {state.connected && ({state.lastSyncAt ? t('dawarich.lastSync', { when: formatDateTime(new Date(state.lastSyncAt)) }) : t('dawarich.neverSynced')} {state.lastSyncState === 'partial' && `, ${t('dawarich.syncPartial')}`}
)} {state.lastSyncError && ({state.lastSyncError}
)} {state.capabilities?.serverVersion && ({t('dawarich.serverVersion', { version: state.capabilities.serverVersion })}
)} {missing.length > 0 && ({t('dawarich.capability.missing', { features: missing.join(', ') })}
)}