diff --git a/apps/citizen-pwa/src/App.routes.test.tsx b/apps/citizen-pwa/src/App.routes.test.tsx index 7453425d..70c79372 100644 --- a/apps/citizen-pwa/src/App.routes.test.tsx +++ b/apps/citizen-pwa/src/App.routes.test.tsx @@ -6,7 +6,7 @@ vi.mock('./components/MapTab/index.js', () => ({ MapTab: () =>
Pre-filled from your last report
}Your name
Is anyone hurt?
++ Is anyone hurt? + May injured ba? +
{draftError}
} + > ) } function SubmissionPanel({ draft, - phone, onSuccess, }: { draft: Draft - phone: string onSuccess: (publicRef: string) => void }) { + const nav = useNavigate() const [now] = useState(() => Date.now()) + const hasAutoSubmittedRef = useRef(false) const machine = useSubmissionMachine({ draft, onSuccess, @@ -203,7 +191,60 @@ function SubmissionPanel({ }, }) - const showSmsFallback = machine.state === 'queued' || machine.state === 'failed_terminal' + // Auto-start: wizard captured consent in Step3, no second confirm needed. + // Ref guard prevents double-invocation under React Strict Mode. + useEffect(() => { + if (hasAutoSubmittedRef.current) return + hasAutoSubmittedRef.current = true + void machine.submit() + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []) + + if (machine.state === 'server_confirmed') { + return