|
|
|
|
@ -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>
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
|