From bde94719bb72d87ff9d5f27f02bf203b9bb4a4ae Mon Sep 17 00:00:00 2001 From: Jason Chuang Date: Mon, 27 Jul 2026 14:00:06 +0800 Subject: [PATCH] id type combo --- .../UserInformationCard_Individual.js | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js b/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js index 0e4fbe8..06c016d 100644 --- a/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js +++ b/src/pages/User/DetailsPage_Individual/UserInformationCard_Individual.js @@ -14,6 +14,7 @@ import * as FieldUtils from "utils/FieldUtils"; import * as HttpUtils from 'utils/HttpUtils'; import * as UrlUtils from "utils/ApiPathConst"; import * as ComboData from "utils/ComboData"; +import en from "translations/en.json"; const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent'))); import Loadable from 'components/Loadable'; import { notifyActiveSuccess, notifyLockSuccess, notifySaveSuccess, notifyVerifySuccess } from 'utils/CommonFunction'; @@ -45,11 +46,20 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => { event.preventDefault(); }; + const getIdDocTypeLabel = (option) => { + if (!option) return ""; + if (typeof option === "string") { + const item = ComboData.idDocType.find((o) => o.type === option); + return item?.label ? (en[item.label] ?? option) : option; + } + return option.label ? (en[option.label] ?? "") : ""; + }; + useEffect(() => { //if state data are ready and assign to different field // console.log(currentApplicationDetailData) if (Object.keys(currentUserData).length > 0) { - setSelectedIdDocInputType(currentUserData.idDocType) + setSelectedIdDocInputType(currentUserData.idDocType); setOnReady(true); } }, [currentUserData]); @@ -393,24 +403,29 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => { {FieldUtils.getComboField({ - label: "ID Type:", + label: `${en.idDocType}:`, valueName: "idDocType", disabled: (!editMode), dataList: ComboData.idDocType, filterOptions: (options) => options, - getOptionLabel: (item) => item ? typeof item === 'string' ? item : (item["type"] ? item["type"] + "-" + item["label"] : "") : "", + getOptionLabel: getIdDocTypeLabel, + isOptionEqualToValue: (option, value) => { + if (typeof value === "string") { + return option?.type === value; + } + return option?.type === value?.type; + }, onInputChange: (event, newValue, setInputValue) => { if (newValue == null) { setInputValue(""); + return; } - let _val = newValue.split("-"); - if (_val[0]) { - setInputValue(_val[0]); - } + setInputValue(newValue); }, onChange: (event, newValue) => { if (newValue == null) { formik.setFieldValue("idDocType", ""); + setSelectedIdDocInputType(""); return; } formik.setFieldValue("idDocType", newValue.type);