fix(hq-web): guard client dialog against double-submit and cancel-during-save

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
feat/client-detail-redesign
Thomas Joise 5 days ago
parent 0aca8b42b4
commit 59c41ee8f7

@ -38,6 +38,7 @@ export function ClientFormDialog(props: {
setContacts((prev) => prev.map((c, j) => (j === i ? { ...c, [k]: e.target.value } : c)))
const save = () => {
if (saving) return
if (f.name.trim() === '') { setError('Name is required'); return }
if (!/^\d{2}$/.test(f.stateCode.trim())) { setError('State code must be two digits'); return }
const cleaned: ClientContact[] = contacts
@ -72,12 +73,12 @@ export function ClientFormDialog(props: {
return (
<Dialog
open={props.open}
onClose={props.onClose}
onClose={() => { if (!saving) props.onClose() }}
title={editing ? `Edit ${props.initial!.name}` : 'New client'}
size="lg"
footer={
<>
<Button pill onClick={props.onClose}>Cancel</Button>
<Button pill onClick={() => { if (!saving) props.onClose() }}>Cancel</Button>
<Button pill tone="primary" onClick={save}>{saving ? 'Saving…' : editing ? 'Save changes' : 'Create client'}</Button>
</>
}

Loading…
Cancel
Save