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:
parent
2663819eef
commit
440c7da8fd
1 changed files with 11 additions and 4 deletions
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue