| @@ -14,6 +14,7 @@ import * as FieldUtils from "utils/FieldUtils"; | |||||
| import * as HttpUtils from 'utils/HttpUtils'; | import * as HttpUtils from 'utils/HttpUtils'; | ||||
| import * as UrlUtils from "utils/ApiPathConst"; | import * as UrlUtils from "utils/ApiPathConst"; | ||||
| import * as ComboData from "utils/ComboData"; | import * as ComboData from "utils/ComboData"; | ||||
| import en from "translations/en.json"; | |||||
| const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent'))); | const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent'))); | ||||
| import Loadable from 'components/Loadable'; | import Loadable from 'components/Loadable'; | ||||
| import { notifyActiveSuccess, notifyLockSuccess, notifySaveSuccess, notifyVerifySuccess } from 'utils/CommonFunction'; | import { notifyActiveSuccess, notifyLockSuccess, notifySaveSuccess, notifyVerifySuccess } from 'utils/CommonFunction'; | ||||
| @@ -45,11 +46,20 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => { | |||||
| event.preventDefault(); | 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(() => { | useEffect(() => { | ||||
| //if state data are ready and assign to different field | //if state data are ready and assign to different field | ||||
| // console.log(currentApplicationDetailData) | // console.log(currentApplicationDetailData) | ||||
| if (Object.keys(currentUserData).length > 0) { | if (Object.keys(currentUserData).length > 0) { | ||||
| setSelectedIdDocInputType(currentUserData.idDocType) | |||||
| setSelectedIdDocInputType(currentUserData.idDocType); | |||||
| setOnReady(true); | setOnReady(true); | ||||
| } | } | ||||
| }, [currentUserData]); | }, [currentUserData]); | ||||
| @@ -393,24 +403,29 @@ const UserInformationCard_Individual = ({ formData, loadDataFun }) => { | |||||
| <Grid item xs={12} sm={12} md={12} lg={4}> | <Grid item xs={12} sm={12} md={12} lg={4}> | ||||
| {FieldUtils.getComboField({ | {FieldUtils.getComboField({ | ||||
| label: "ID Type:", | |||||
| label: `${en.idDocType}:`, | |||||
| valueName: "idDocType", | valueName: "idDocType", | ||||
| disabled: (!editMode), | disabled: (!editMode), | ||||
| dataList: ComboData.idDocType, | dataList: ComboData.idDocType, | ||||
| filterOptions: (options) => options, | 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) => { | onInputChange: (event, newValue, setInputValue) => { | ||||
| if (newValue == null) { | if (newValue == null) { | ||||
| setInputValue(""); | setInputValue(""); | ||||
| return; | |||||
| } | } | ||||
| let _val = newValue.split("-"); | |||||
| if (_val[0]) { | |||||
| setInputValue(_val[0]); | |||||
| } | |||||
| setInputValue(newValue); | |||||
| }, | }, | ||||
| onChange: (event, newValue) => { | onChange: (event, newValue) => { | ||||
| if (newValue == null) { | if (newValue == null) { | ||||
| formik.setFieldValue("idDocType", ""); | formik.setFieldValue("idDocType", ""); | ||||
| setSelectedIdDocInputType(""); | |||||
| return; | return; | ||||
| } | } | ||||
| formik.setFieldValue("idDocType", newValue.type); | formik.setFieldValue("idDocType", newValue.type); | ||||