"use client"; import { useRouter } from "next/navigation"; import { useActionState, useEffect } from "react"; import type { OperatorSettings } from "@/lib/global-settings"; import type { SchedulerStatus } from "@/lib/scheduler-status"; import { saveOperatorSettingsAction, sendTestAlertAction, type SaveOperatorSettingsState, type SendTestAlertState, } from "./actions"; const saveInitialState: SaveOperatorSettingsState = { error: null, saved: false }; const testInitialState: SendTestAlertState = { result: null }; function Toggle({ name, label, hint, defaultChecked }: { name: string; label: string; hint?: string; defaultChecked: boolean }) { return ( ); } export function OperatorSettingsForm({ initial, status }: { initial: OperatorSettings; status: SchedulerStatus }) { const router = useRouter(); const [saveState, saveAction, isSaving] = useActionState(saveOperatorSettingsAction, saveInitialState); const [testState, testAction, isTesting] = useActionState(sendTestAlertAction, testInitialState); useEffect(() => { if (saveState.saved) router.refresh(); }, [saveState, router]); return (
The Manager calls every business's notification cron, checks its /api/health and runs scheduled backups itself. Alerts are emailed with the SMTP settings above; a business must fail two checks in a row before you hear about it.
Last tick: {status.heartbeatAt ? new Date(status.heartbeatAt).toLocaleString() : "never (scheduler not running?)"}
{status.rows.length > 0 && (| Task | Last run | Result |
|---|---|---|
| {key} | {state.lastFinishedAt ? new Date(state.lastFinishedAt).toLocaleString() : "running / never"} | {state.lastMessage ?? "—"} |