diff --git a/components/backlog/pbi-dialog.tsx b/components/backlog/pbi-dialog.tsx index 8174f27..b93de29 100644 --- a/components/backlog/pbi-dialog.tsx +++ b/components/backlog/pbi-dialog.tsx @@ -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)[field]?.[0] + } const titleRef = useRef(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') &&

{fieldError('code')}

}
@@ -124,7 +129,9 @@ export function PbiDialog({ state, onClose }: PbiDialogProps) { placeholder="PBI-titel…" required maxLength={200} + className={fieldError('title') ? 'border-error' : ''} /> + {fieldError('title') &&

{fieldError('title')}

}