690329:1114 Fixing bugs uuid by GPT-5.3 #03
CI / CD Pipeline / build (push) Successful in 11m44s
CI / CD Pipeline / deploy (push) Successful in 7m37s

This commit is contained in:
2026-03-29 11:14:06 +07:00
parent 6d873f016d
commit e8965658b1
2 changed files with 53 additions and 20 deletions
+15 -7
View File
@@ -367,13 +367,21 @@ export function CorrespondenceForm({ initialData, uuid }: { initialData?: Initia
<SelectValue placeholder={isLoadingContracts ? 'Loading...' : 'Select Contract'} /> <SelectValue placeholder={isLoadingContracts ? 'Loading...' : 'Select Contract'} />
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
{contracts.map((c) => ( {contracts.map((c) => {
<SelectItem key={c.publicId} value={c.publicId || ''}> const contractValue = c.publicId;
{c.contractName || c.contractCode}
</SelectItem> if (!contractValue) {
))} return null;
}
return (
<SelectItem key={contractValue} value={contractValue}>
{c.contractName || c.contractCode}
</SelectItem>
);
})}
{!isLoadingContracts && contracts.length === 0 && ( {!isLoadingContracts && contracts.length === 0 && (
<SelectItem value="" disabled> <SelectItem value="__no_contract_available__" disabled>
No contracts found for this project No contracts found for this project
</SelectItem> </SelectItem>
)} )}
@@ -422,7 +430,7 @@ export function CorrespondenceForm({ initialData, uuid }: { initialData?: Initia
</SelectItem> </SelectItem>
))} ))}
{!isLoadingDisciplines && disciplines.length === 0 && ( {!isLoadingDisciplines && disciplines.length === 0 && (
<SelectItem value="" disabled> <SelectItem value="__no_discipline_available__" disabled>
No disciplines found for this contract No disciplines found for this contract
</SelectItem> </SelectItem>
)} )}
+38 -13
View File
@@ -53,7 +53,7 @@ type ContractOption = {
}; };
type DisciplineOption = { type DisciplineOption = {
publicId: string; // ADR-019: public identifier publicId?: string; // ADR-019: public identifier
id?: number; // Internal INT id?: number; // Internal INT
disciplineCode: string; disciplineCode: string;
codeNameEn?: string; codeNameEn?: string;
@@ -61,7 +61,7 @@ type DisciplineOption = {
}; };
type RfaTypeOption = { type RfaTypeOption = {
publicId: string; // ADR-019: public identifier publicId?: string; // ADR-019: public identifier
id?: number; // Internal INT id?: number; // Internal INT
typeCode?: string; typeCode?: string;
typeName?: string; typeName?: string;
@@ -137,6 +137,10 @@ const getOptionValue = (value?: string | number): string | undefined => {
return String(value); return String(value);
}; };
const getMasterOptionValue = (option: { publicId?: string; id?: number }): string | undefined => {
return getOptionValue(option.publicId ?? option.id);
};
export function RFAForm() { export function RFAForm() {
const router = useRouter(); const router = useRouter();
const createMutation = useCreateRFA(); const createMutation = useCreateRFA();
@@ -187,9 +191,12 @@ export function RFAForm() {
const selectedContractId = watch('contractId'); const selectedContractId = watch('contractId');
const { data: disciplinesData, isLoading: isLoadingDisciplines } = useDisciplines(selectedContractId); const { data: disciplinesData, isLoading: isLoadingDisciplines } = useDisciplines(selectedContractId);
const disciplines = dedupeByKey(extractArrayData<DisciplineOption>(disciplinesData), (discipline) => discipline.publicId); const disciplines = dedupeByKey(
extractArrayData<DisciplineOption>(disciplinesData),
(discipline) => getMasterOptionValue(discipline)
);
const { data: rfaTypesData, isLoading: isLoadingRfaTypes } = useRfaTypes(selectedContractId); const { data: rfaTypesData, isLoading: isLoadingRfaTypes } = useRfaTypes(selectedContractId);
const rfaTypes = dedupeByKey(extractArrayData<RfaTypeOption>(rfaTypesData), (rfaType) => rfaType.publicId); const rfaTypes = dedupeByKey(extractArrayData<RfaTypeOption>(rfaTypesData), (rfaType) => getMasterOptionValue(rfaType));
const [shopDrawingSearch, setShopDrawingSearch] = useState(''); const [shopDrawingSearch, setShopDrawingSearch] = useState('');
const [shopDrawingPage, setShopDrawingPage] = useState(1); const [shopDrawingPage, setShopDrawingPage] = useState(1);
const { data: shopDrawingsData, isLoading: isLoadingShopDrawings } = useDrawings('SHOP', { const { data: shopDrawingsData, isLoading: isLoadingShopDrawings } = useDrawings('SHOP', {
@@ -222,7 +229,7 @@ export function RFAForm() {
const toOrganizationId = watch('toOrganizationId'); const toOrganizationId = watch('toOrganizationId');
const selectedShopDrawingRevisionIds = watch('shopDrawingRevisionIds') ?? []; const selectedShopDrawingRevisionIds = watch('shopDrawingRevisionIds') ?? [];
const selectedAsBuiltDrawingRevisionIds = watch('asBuiltDrawingRevisionIds') ?? []; 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 selectedRfaTypeCode = selectedRfaType?.typeCode?.toUpperCase();
const requiresShopDrawings = selectedRfaTypeCode === 'DDW' || selectedRfaTypeCode === 'SDW'; const requiresShopDrawings = selectedRfaTypeCode === 'DDW' || selectedRfaTypeCode === 'SDW';
const requiresAsBuiltDrawings = selectedRfaTypeCode === 'ADW'; const requiresAsBuiltDrawings = selectedRfaTypeCode === 'ADW';
@@ -443,9 +450,19 @@ export function RFAForm() {
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
{disciplines.map((d) => ( {disciplines.map((d) => (
<SelectItem key={d.publicId} value={String(d.publicId)}> (() => {
{`${d.codeNameEn || d.codeNameTh || d.disciplineCode} (${d.disciplineCode})`} const disciplineValue = getMasterOptionValue(d);
</SelectItem>
if (!disciplineValue) {
return null;
}
return (
<SelectItem key={disciplineValue} value={disciplineValue}>
{`${d.codeNameEn || d.codeNameTh || d.disciplineCode} (${d.disciplineCode})`}
</SelectItem>
);
})()
))} ))}
{!isLoadingDisciplines && disciplines.length === 0 && ( {!isLoadingDisciplines && disciplines.length === 0 && (
<SelectItem value="0" disabled> <SelectItem value="0" disabled>
@@ -474,11 +491,19 @@ export function RFAForm() {
<SelectValue placeholder={isLoadingRfaTypes ? 'Loading...' : 'Select RFA Type'} /> <SelectValue placeholder={isLoadingRfaTypes ? 'Loading...' : 'Select RFA Type'} />
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
{rfaTypes.map((rfaType) => ( {rfaTypes.map((rfaType) => {
<SelectItem key={rfaType.publicId} value={String(rfaType.publicId)}> const rfaTypeValue = getMasterOptionValue(rfaType);
{`${rfaType.typeCode || 'RFA'} - ${rfaType.typeName || rfaType.typeNameEn || rfaType.typeNameTh || 'Unnamed Type'}`}
</SelectItem> if (!rfaTypeValue) {
))} return null;
}
return (
<SelectItem key={rfaTypeValue} value={rfaTypeValue}>
{`${rfaType.typeCode || 'RFA'} - ${rfaType.typeName || rfaType.typeNameEn || rfaType.typeNameTh || 'Unnamed Type'}`}
</SelectItem>
);
})}
</SelectContent> </SelectContent>
</Select> </Select>
{errors.rfaTypeId && <p className="text-sm text-destructive mt-1">{errors.rfaTypeId.message}</p>} {errors.rfaTypeId && <p className="text-sm text-destructive mt-1">{errors.rfaTypeId.message}</p>}