fix(ui): password field in the service-data Edit form (Client 360 modules)

The portal/gateway password could only be set via a separate 'Set…' button in the read
view — easy to miss, and absent from the Edit form (where you'd look for it). Add a
Password field to the Edit form (owner/manager) alongside Username: blank keeps the
current one, typing sets it. Rides the same audited PATCH the button used. So on a
client's SMS module you can now add/change the gateway password right where you edit
the login. typecheck + build clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
feat/client-detail-redesign
Thomas Joise 2 days ago
parent 7742b583c3
commit 1bf0e4ee45

@ -971,7 +971,7 @@ function ServiceDataCard(props: { cm: ClientModule; name: string; fieldSpec: Fie
const [pw, setPw] = useState('')
const [busy, setBusy] = useState(false)
const [editing, setEditing] = useState(false)
const [f, setF] = useState({ provider: '', username: '', remark: '' })
const [f, setF] = useState({ provider: '', username: '', remark: '', password: '' })
const [details, setDetails] = useState<ServiceDetail[]>([])
const copy = (text: string, what: string) => {
@ -994,7 +994,7 @@ function ServiceDataCard(props: { cm: ClientModule; name: string; fieldSpec: Fie
.finally(() => setBusy(false))
}
const startEdit = () => {
setF({ provider: cm.provider ?? '', username: cm.username ?? '', remark: cm.remark ?? '' })
setF({ provider: cm.provider ?? '', username: cm.username ?? '', remark: cm.remark ?? '', password: '' })
setDetails(cm.details.map((d) => ({ ...d })))
setEditing(true)
}
@ -1006,6 +1006,8 @@ function ServiceDataCard(props: { cm: ClientModule; name: string; fieldSpec: Fie
patchClientModule(cm.id, {
provider: f.provider, username: f.username, remark: f.remark,
details: cleaned.map((d) => ({ label: d.label.trim(), value: d.value })),
// Password only when the managerial user typed one (blank = keep current).
...(managerial && f.password.trim() !== '' ? { password: f.password } : {}),
})
.then(() => { toast.ok('Service data saved'); setEditing(false); props.onChanged() })
.catch((e: Error) => toast.err(e.message))
@ -1027,6 +1029,12 @@ function ServiceDataCard(props: { cm: ClientModule; name: string; fieldSpec: Fie
<div style={{ display: 'flex', gap: 10, flexWrap: 'wrap', alignItems: 'flex-end', marginBottom: 8 }}>
<Field label="Provider"><input className="wf" style={{ width: 140 }} value={f.provider} onChange={(e) => setF((p) => ({ ...p, provider: e.target.value }))} /></Field>
<Field label="Username"><input className="wf mono" style={{ width: 160 }} value={f.username} onChange={(e) => setF((p) => ({ ...p, username: e.target.value }))} /></Field>
{managerial && (
<Field label="Password">
<input className="wf mono" style={{ width: 160 }} placeholder={cm.hasPassword ? 'leave blank to keep' : 'set password'}
value={f.password} onChange={(e) => setF((p) => ({ ...p, password: e.target.value }))} />
</Field>
)}
<Field label="Remark"><input className="wf" style={{ width: 220 }} value={f.remark} onChange={(e) => setF((p) => ({ ...p, remark: e.target.value }))} /></Field>
</div>
{details.map((d, i) => (

Loading…
Cancel
Save