From e8965658b113c2497b74f8b636c9d6ce0a182165 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 29 Mar 2026 11:14:06 +0700 Subject: [PATCH] 690329:1114 Fixing bugs uuid by GPT-5.3 #03 --- frontend/components/correspondences/form.tsx | 22 ++++++--- frontend/components/rfas/form.tsx | 51 +++++++++++++++----- 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/frontend/components/correspondences/form.tsx b/frontend/components/correspondences/form.tsx index 1191a08..fdb37ac 100644 --- a/frontend/components/correspondences/form.tsx +++ b/frontend/components/correspondences/form.tsx @@ -367,13 +367,21 @@ export function CorrespondenceForm({ initialData, uuid }: { initialData?: Initia - {contracts.map((c) => ( - - {c.contractName || c.contractCode} - - ))} + {contracts.map((c) => { + const contractValue = c.publicId; + + if (!contractValue) { + return null; + } + + return ( + + {c.contractName || c.contractCode} + + ); + })} {!isLoadingContracts && contracts.length === 0 && ( - + No contracts found for this project )} @@ -422,7 +430,7 @@ export function CorrespondenceForm({ initialData, uuid }: { initialData?: Initia ))} {!isLoadingDisciplines && disciplines.length === 0 && ( - + No disciplines found for this contract )} diff --git a/frontend/components/rfas/form.tsx b/frontend/components/rfas/form.tsx index 1a544f1..8c854fc 100644 --- a/frontend/components/rfas/form.tsx +++ b/frontend/components/rfas/form.tsx @@ -53,7 +53,7 @@ type ContractOption = { }; type DisciplineOption = { - publicId: string; // ADR-019: public identifier + publicId?: string; // ADR-019: public identifier id?: number; // Internal INT disciplineCode: string; codeNameEn?: string; @@ -61,7 +61,7 @@ type DisciplineOption = { }; type RfaTypeOption = { - publicId: string; // ADR-019: public identifier + publicId?: string; // ADR-019: public identifier id?: number; // Internal INT typeCode?: string; typeName?: string; @@ -137,6 +137,10 @@ const getOptionValue = (value?: string | number): string | undefined => { return String(value); }; +const getMasterOptionValue = (option: { publicId?: string; id?: number }): string | undefined => { + return getOptionValue(option.publicId ?? option.id); +}; + export function RFAForm() { const router = useRouter(); const createMutation = useCreateRFA(); @@ -187,9 +191,12 @@ export function RFAForm() { const selectedContractId = watch('contractId'); const { data: disciplinesData, isLoading: isLoadingDisciplines } = useDisciplines(selectedContractId); - const disciplines = dedupeByKey(extractArrayData(disciplinesData), (discipline) => discipline.publicId); + const disciplines = dedupeByKey( + extractArrayData(disciplinesData), + (discipline) => getMasterOptionValue(discipline) + ); const { data: rfaTypesData, isLoading: isLoadingRfaTypes } = useRfaTypes(selectedContractId); - const rfaTypes = dedupeByKey(extractArrayData(rfaTypesData), (rfaType) => rfaType.publicId); + const rfaTypes = dedupeByKey(extractArrayData(rfaTypesData), (rfaType) => getMasterOptionValue(rfaType)); const [shopDrawingSearch, setShopDrawingSearch] = useState(''); const [shopDrawingPage, setShopDrawingPage] = useState(1); const { data: shopDrawingsData, isLoading: isLoadingShopDrawings } = useDrawings('SHOP', { @@ -222,7 +229,7 @@ export function RFAForm() { const toOrganizationId = watch('toOrganizationId'); const selectedShopDrawingRevisionIds = watch('shopDrawingRevisionIds') ?? []; const selectedAsBuiltDrawingRevisionIds = watch('asBuiltDrawingRevisionIds') ?? []; - const selectedRfaType = rfaTypes.find((rfaType) => rfaType.publicId === rfaTypeId); + const selectedRfaType = rfaTypes.find((rfaType) => getMasterOptionValue(rfaType) === rfaTypeId); const selectedRfaTypeCode = selectedRfaType?.typeCode?.toUpperCase(); const requiresShopDrawings = selectedRfaTypeCode === 'DDW' || selectedRfaTypeCode === 'SDW'; const requiresAsBuiltDrawings = selectedRfaTypeCode === 'ADW'; @@ -443,9 +450,19 @@ export function RFAForm() { {disciplines.map((d) => ( - - {`${d.codeNameEn || d.codeNameTh || d.disciplineCode} (${d.disciplineCode})`} - + (() => { + const disciplineValue = getMasterOptionValue(d); + + if (!disciplineValue) { + return null; + } + + return ( + + {`${d.codeNameEn || d.codeNameTh || d.disciplineCode} (${d.disciplineCode})`} + + ); + })() ))} {!isLoadingDisciplines && disciplines.length === 0 && ( @@ -474,11 +491,19 @@ export function RFAForm() { - {rfaTypes.map((rfaType) => ( - - {`${rfaType.typeCode || 'RFA'} - ${rfaType.typeName || rfaType.typeNameEn || rfaType.typeNameTh || 'Unnamed Type'}`} - - ))} + {rfaTypes.map((rfaType) => { + const rfaTypeValue = getMasterOptionValue(rfaType); + + if (!rfaTypeValue) { + return null; + } + + return ( + + {`${rfaType.typeCode || 'RFA'} - ${rfaType.typeName || rfaType.typeNameEn || rfaType.typeNameTh || 'Unnamed Type'}`} + + ); + })} {errors.rfaTypeId &&

{errors.rfaTypeId.message}

}