diff --git a/backend/src/.jest-cache/haste-map-60cab15b743c6776f41d29bcac696b99-0ca4a1d6e3dfec1d63b61b0119442391-1908b04cd11e739233ee8977de00dc57 b/backend/src/.jest-cache/haste-map-60cab15b743c6776f41d29bcac696b99-0ca4a1d6e3dfec1d63b61b0119442391-1908b04cd11e739233ee8977de00dc57 index 66badb7..abb55eb 100644 Binary files a/backend/src/.jest-cache/haste-map-60cab15b743c6776f41d29bcac696b99-0ca4a1d6e3dfec1d63b61b0119442391-1908b04cd11e739233ee8977de00dc57 and b/backend/src/.jest-cache/haste-map-60cab15b743c6776f41d29bcac696b99-0ca4a1d6e3dfec1d63b61b0119442391-1908b04cd11e739233ee8977de00dc57 differ diff --git a/frontend/app/(admin)/admin/doc-control/reference/disciplines/page.tsx b/frontend/app/(admin)/admin/doc-control/reference/disciplines/page.tsx index 3f9dff9..76d5990 100644 --- a/frontend/app/(admin)/admin/doc-control/reference/disciplines/page.tsx +++ b/frontend/app/(admin)/admin/doc-control/reference/disciplines/page.tsx @@ -81,12 +81,12 @@ export default function DisciplinesPage() { queryKey={['disciplines', selectedContractId ?? 'all']} fetchFn={async () => { const items = await masterDataService.getDisciplines(selectedContractId ? selectedContractId : undefined); - // ADR-019: Map contractId INT → contract UUID for edit mode select matching + // ADR-019: Map contract.publicId UUID for edit mode select matching return items.map((item) => { - const rec = item as Discipline & { contract?: { id?: number; uuid?: string }; contractId?: number | string }; + const rec = item as Discipline & { contract?: { publicId?: string }; contractId?: number | string }; return { ...item, - contractId: rec.contract?.id || rec.contract?.uuid || String(rec.contractId), + contractId: rec.contract?.publicId || (rec.contractId ? String(rec.contractId) : null), } as Discipline; }); }} diff --git a/frontend/app/(admin)/admin/doc-control/reference/rfa-types/page.tsx b/frontend/app/(admin)/admin/doc-control/reference/rfa-types/page.tsx index dc6e1dc..da2fd67 100644 --- a/frontend/app/(admin)/admin/doc-control/reference/rfa-types/page.tsx +++ b/frontend/app/(admin)/admin/doc-control/reference/rfa-types/page.tsx @@ -84,12 +84,12 @@ export default function RfaTypesPage() { queryKey={['rfa-types', selectedContractId ?? 'all']} fetchFn={async () => { const items = await masterDataService.getRfaTypes(selectedContractId ? selectedContractId : undefined); - // ADR-019: Map contractId INT → contract UUID for edit mode select matching + // ADR-019: Map contract.publicId UUID for edit mode select matching return items.map((item) => { - const rec = item as RfaType & { contract?: { id?: number | string; uuid?: string }; contract_id?: number | string }; + const rec = item as RfaType & { contract?: { publicId?: string }; contractId?: number | string }; return { ...item, - contractId: rec.contract?.id || rec.contract?.uuid || (rec.contract_id ? String(rec.contract_id) : null), + contractId: rec.contract?.publicId || (rec.contractId ? String(rec.contractId) : null), } as RfaType; }); }} diff --git a/frontend/components/numbering/template-editor.tsx b/frontend/components/numbering/template-editor.tsx index 814e630..41e7756 100644 --- a/frontend/components/numbering/template-editor.tsx +++ b/frontend/components/numbering/template-editor.tsx @@ -46,8 +46,8 @@ export function TemplateEditor({ onCancel, }: TemplateEditorProps) { const [format, setFormat] = useState(template?.formatTemplate || ''); - const [typeId, setTypeId] = useState(template?.correspondenceTypeId?.toString() || ''); - const [disciplineId, setDisciplineId] = useState(template?.disciplineId?.toString() || '0'); + const [typeId, setTypeId] = useState(template?.correspondenceTypeId ? String(template.correspondenceTypeId) : ''); + const [disciplineId, setDisciplineId] = useState(template?.disciplineId ? String(template.disciplineId) : '0'); const [reset, setReset] = useState(template?.resetSequenceYearly ?? true); const [preview, setPreview] = useState(''); @@ -64,7 +64,7 @@ export function TemplateEditor({ // Dynamic context based on selection (optional visual enhancement) if (v.key === '{TYPE}' && typeId) { const t = correspondenceTypes.find( - (ct) => ct.id?.toString() === typeId + (ct) => String(ct.publicId) === typeId ); if (t) replacement = t.typeCode; } @@ -120,7 +120,7 @@ export function TemplateEditor({ Default (All Types) {correspondenceTypes.map((type) => { return ( - + {type.typeCode} - {type.typeName} ); @@ -142,7 +142,7 @@ export function TemplateEditor({ All Disciplines {disciplines.map((d) => ( - + {d.disciplineCode} - {d.codeNameEn || d.codeNameTh} ))} diff --git a/frontend/components/rfas/form.tsx b/frontend/components/rfas/form.tsx index 76b6a91..1a544f1 100644 --- a/frontend/components/rfas/form.tsx +++ b/frontend/components/rfas/form.tsx @@ -25,7 +25,7 @@ import { Contract } from '@/types/contract'; const rfaSchema = z.object({ projectId: z.string().min(1, 'Project is required'), // ADR-019: UUID contractId: z.string().min(1, 'Contract is required'), - disciplineId: z.number({ message: 'Discipline is required' }).min(1, 'Discipline is required'), + disciplineId: z.union([z.string().min(1, 'Discipline is required'), z.number().min(1, 'Discipline is required')]), rfaTypeId: z.string().min(1, 'Type is required'), // ADR-019: UUID subject: z.string().min(5, 'Subject must be at least 5 characters'), description: z.string().optional(), @@ -165,7 +165,7 @@ export function RFAForm() { defaultValues: { projectId: '', contractId: '', - disciplineId: 0, + disciplineId: '', rfaTypeId: '', subject: '', description: '', @@ -366,7 +366,7 @@ export function RFAForm() { onValueChange={(val) => { setValue('projectId', val); setValue('contractId', ''); - setValue('disciplineId', 0); + setValue('disciplineId', ''); setValue('rfaTypeId', ''); setValue('shopDrawingRevisionIds', []); setValue('asBuiltDrawingRevisionIds', []); @@ -402,7 +402,7 @@ export function RFAForm() { value={selectedContractId || undefined} onValueChange={(val) => { setValue('contractId', val); - setValue('disciplineId', 0); + setValue('disciplineId', ''); setValue('rfaTypeId', ''); setValue('shopDrawingRevisionIds', []); setValue('asBuiltDrawingRevisionIds', []); @@ -434,8 +434,8 @@ export function RFAForm() {