fix(ST-511): surface field errors for code and title in PBI dialog

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Janpeter Visser 2026-04-26 21:24:58 +02:00
parent 2663819eef
commit 440c7da8fd

View file

@ -79,9 +79,13 @@ export function PbiDialog({ state, onClose }: PbiDialogProps) {
undefined
)
const error = isEdit
? (typeof updateState?.error === 'string' ? updateState.error : null)
: (typeof createState?.error === 'string' ? createState.error : null)
const activeState = isEdit ? updateState : createState
const error = typeof activeState?.error === 'string' ? activeState.error : null
const fieldError = (field: string) => {
const err = activeState?.error
if (!err || typeof err === 'string') return undefined
return (err as Record<string, string[]>)[field]?.[0]
}
const titleRef = useRef<HTMLInputElement>(null)
useEffect(() => {
@ -111,8 +115,9 @@ export function PbiDialog({ state, onClose }: PbiDialogProps) {
defaultValue={pbi?.code ?? ''}
placeholder={isEdit ? '' : 'auto'}
maxLength={30}
className="font-mono text-sm"
className={fieldError('code') ? 'font-mono text-sm border-error' : 'font-mono text-sm'}
/>
{fieldError('code') && <p className="text-xs text-error">{fieldError('code')}</p>}
</div>
<div className="grid gap-1.5">
<label htmlFor="pbi-title" className="text-sm font-medium">Titel</label>
@ -124,7 +129,9 @@ export function PbiDialog({ state, onClose }: PbiDialogProps) {
placeholder="PBI-titel…"
required
maxLength={200}
className={fieldError('title') ? 'border-error' : ''}
/>
{fieldError('title') && <p className="text-xs text-error">{fieldError('title')}</p>}
</div>
</div>