diff --git a/web/src/api/client.ts b/web/src/api/client.ts index c2bd791..28dbf28 100644 --- a/web/src/api/client.ts +++ b/web/src/api/client.ts @@ -110,8 +110,12 @@ export async function apiFetch( if (text) { try { body = JSON.parse(text) - const m = (body as { message?: unknown }).message - if (typeof m === 'string') message = m + // Spring ProblemDetail uses "detail"; fallback to "message" + const parsed = body as { detail?: unknown; message?: unknown } + const d = parsed.detail + const m = parsed.message + if (typeof d === 'string') message = d + else if (typeof m === 'string') message = m } catch { body = text message = text @@ -171,7 +175,8 @@ export const catalog = { itemType: string; baseUomCode: string; active?: boolean }) => apiFetch('/api/v1/catalog/items', { method: 'POST', body: JSON.stringify(body) }), updateItem: (id: string, body: { - name?: string; description?: string | null; itemType?: string; active?: boolean + name?: string; description?: string | null; itemType?: string; active?: boolean; + ext?: Record }) => apiFetch(`/api/v1/catalog/items/${id}`, { method: 'PATCH', body: JSON.stringify(body) }), listUoms: () => apiFetch('/api/v1/catalog/uoms'), } @@ -188,7 +193,8 @@ export const partners = { }) => apiFetch('/api/v1/partners/partners', { method: 'POST', body: JSON.stringify(body) }), update: (id: string, body: { name?: string; type?: string; - email?: string | null; phone?: string | null + email?: string | null; phone?: string | null; + ext?: Record }) => apiFetch(`/api/v1/partners/partners/${id}`, { method: 'PATCH', body: JSON.stringify(body) }), } diff --git a/web/src/pages/EditItemPage.tsx b/web/src/pages/EditItemPage.tsx index c8df50b..4b10033 100644 --- a/web/src/pages/EditItemPage.tsx +++ b/web/src/pages/EditItemPage.tsx @@ -5,6 +5,7 @@ import type { Item } from '@/types/api' import { PageHeader } from '@/components/PageHeader' import { Loading } from '@/components/Loading' import { ErrorBox } from '@/components/ErrorBox' +import { DynamicExtFields } from '@/components/DynamicExtFields' const ITEM_TYPES = ['GOOD', 'SERVICE', 'DIGITAL'] as const @@ -17,6 +18,7 @@ export function EditItemPage() { const [itemType, setItemType] = useState('GOOD') const [active, setActive] = useState(true) const [loading, setLoading] = useState(true) + const [ext, setExt] = useState>({}) const [submitting, setSubmitting] = useState(false) const [error, setError] = useState(null) @@ -28,6 +30,7 @@ export function EditItemPage() { setDescription(i.description ?? '') setItemType(i.itemType) setActive(i.active) + setExt(i.ext || {}) }) .catch((e: unknown) => setError(e instanceof Error ? e : new Error(String(e)))) .finally(() => setLoading(false)) @@ -41,6 +44,7 @@ export function EditItemPage() { await catalog.updateItem(id, { name, itemType, active, description: description || null, + ...(Object.keys(ext).length > 0 ? { ext } : {}), }) navigate('/items') } catch (err: unknown) { @@ -85,6 +89,7 @@ export function EditItemPage() { className="rounded border-slate-300" id="active" /> + setExt(prev => ({ ...prev, [k]: v }))} /> {error && }