No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

UserInformationCard_Individual.js 38 KiB

hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 15 horas
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 15 horas
hace 15 horas
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 1 mes
hace 1 mes
hace 1 mes
hace 1 mes
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 1 mes
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 1 año
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 15 horas
hace 2 años
hace 15 horas
hace 2 años
hace 15 horas
hace 2 años
hace 15 horas
hace 2 años
hace 15 horas
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 1 año
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 1 mes
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 1 mes
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 3 meses
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 1 año
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
hace 2 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. // material-ui
  2. import {
  3. Grid, Button, Typography,
  4. FormHelperText,
  5. Stack,
  6. IconButton
  7. } from '@mui/material';
  8. import MainCard from "components/MainCard";
  9. import { useEffect, useState, lazy } from "react";
  10. import * as yup from 'yup';
  11. import { useFormik } from 'formik';
  12. import * as FieldUtils from "utils/FieldUtils";
  13. import * as HttpUtils from 'utils/HttpUtils';
  14. import * as UrlUtils from "utils/ApiPathConst";
  15. import * as ComboData from "utils/ComboData";
  16. import en from "translations/en.json";
  17. const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent')));
  18. import Loadable from 'components/Loadable';
  19. import { notifyActiveSuccess, notifyLockSuccess, notifySaveSuccess, notifyVerifySuccess } from 'utils/CommonFunction';
  20. import { PRIMARY_CONTAINED_BUTTON_SX } from 'themes/colorConst';
  21. import { useIntl } from "react-intl";
  22. import { PNSPS_BUTTON_THEME } from "themes/buttonConst";
  23. import { ThemeProvider } from "@emotion/react";
  24. import { EyeInvisibleOutlined, EyeOutlined } from '@ant-design/icons';
  25. import { isGrantedAny } from "auth/utils";
  26. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  27. const UserInformationCard_Individual = ({ formData, loadDataFun }) => {
  28. const intl = useIntl();
  29. const [currentUserData, setCurrentUserData] = useState(formData);
  30. const [editMode, setEditMode] = useState(false);
  31. const [locked, setLocked] = useState(false);
  32. const [onReady, setOnReady] = useState(false);
  33. const [errorMsg, setErrorMsg] = useState("");
  34. const [showId, setshowId] = useState(false);
  35. const [selectedIdDocInputType, setSelectedIdDocInputType] = useState("");
  36. const handleClickShowId = () => {
  37. setshowId(!showId);
  38. };
  39. const handleMouseDownId = (event) => {
  40. event.preventDefault();
  41. };
  42. const getIdDocTypeLabel = (option) => {
  43. if (!option) return "";
  44. if (typeof option === "string") {
  45. const item = ComboData.idDocType.find((o) => o.type === option);
  46. return item?.label ? (en[item.label] ?? option) : option;
  47. }
  48. return option.label ? (en[option.label] ?? "") : "";
  49. };
  50. useEffect(() => {
  51. //if state data are ready and assign to different field
  52. // console.log(currentApplicationDetailData)
  53. if (Object.keys(currentUserData).length > 0) {
  54. setSelectedIdDocInputType(currentUserData.idDocType);
  55. setOnReady(true);
  56. }
  57. }, [currentUserData]);
  58. function getMaxErrStr(num, fieldname) {
  59. return intl.formatMessage({ id: 'noMoreThenNWords' }, { num: num, fieldname: fieldname ? intl.formatMessage({ id: fieldname }) + ": " : "" });
  60. }
  61. function getRequiredErrStr(fieldname) {
  62. return displayErrorMsg(intl.formatMessage({ id: 'require' }, { fieldname: fieldname ? intl.formatMessage({ id: fieldname }) : "" }));
  63. }
  64. function displayErrorMsg(errorMsg) {
  65. return <Typography variant="errorMessage1">{errorMsg}</Typography>
  66. }
  67. const formik = useFormik({
  68. enableReinitialize: true,
  69. initialValues: currentUserData,
  70. validationSchema: yup.object().shape({
  71. enName: yup.string().max(40, getMaxErrStr(40)).when('chName', {
  72. is: (chName) => chName?false:true,
  73. then: yup.string().required(intl.formatMessage({ id: 'userRequireEnglishName' }))
  74. }).nullable(),
  75. chName: yup.string().max(6, getMaxErrStr(6)).nullable(),
  76. addressLine1: yup.string().max(40, getMaxErrStr(40)).required(intl.formatMessage({ id: 'validateAddressLine1' })),
  77. addressLine2: yup.string().max(40, getMaxErrStr(40)).nullable(),
  78. addressLine3: yup.string().max(40, getMaxErrStr(40)).nullable(),
  79. emailAddress: yup.string().email(intl.formatMessage({ id: 'validEmailFormat' })).max(255).required(intl.formatMessage({ id: 'requireEmail' })),
  80. idDocType: yup.string().max(255, getMaxErrStr(255)).required(intl.formatMessage({ id: 'requireIdDocType' })),
  81. identification: yup.string().when('verifiedBy', {
  82. is: (verifiedBy) => verifiedBy != null,
  83. then: (schema) => schema.notRequired(),
  84. otherwise: (schema) => schema.required(getRequiredErrStr('number'))
  85. .matches(/^[aA-zZ0-9\s]+$/, { message: displayErrorMsg(`${selectedIdDocInputType}${intl.formatMessage({ id: 'noSpecialCharacter' })}`) })
  86. .matches(/^\S*$/, { message: displayErrorMsg(`${selectedIdDocInputType}${intl.formatMessage({ id: 'noSpace' })}`) })
  87. .test('checkIDCardFormat', displayErrorMsg(`${intl.formatMessage({ id: 'requiredValid' })}${selectedIdDocInputType}${intl.formatMessage({ id: 'number' })}`), function (value) {
  88. var pattern_HKIDv1 = /^[A-Z]{1}[0-9]{6}$/;
  89. var pattern_HKIDv2 = /^[A-Z]{2}[0-9]{6}$/;
  90. var pattern_passport = /^[A-Z]{1}[0-9]{8}$/;
  91. var pattern_CHID = /^[0-9]{6}(20|19)[0-9]{2}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])[0-9]{3}[0-9X]{1}/;
  92. var pattern_otherCert = /^[A-Z]{1}[0-9]{5,}/;
  93. if (value !== undefined) {
  94. switch (selectedIdDocInputType) {
  95. case "HKID":
  96. if (value.match(pattern_HKIDv1)) {
  97. return true
  98. } else if (value.match(pattern_HKIDv2)) {
  99. return true
  100. } else {
  101. return false
  102. }
  103. case "passport":
  104. if (value.match(pattern_passport)) {
  105. return true
  106. } else {
  107. return false
  108. }
  109. case "CNID":
  110. if (value.match(pattern_CHID)) {
  111. const subStr_year = value.substring(6, 10)
  112. const subStr_month = value.substring(10, 12)
  113. const subStr_date = value.substring(12, 14)
  114. const today = new Date()
  115. const inputDate = new Date(`${subStr_year}-${subStr_month}-${subStr_date}`)
  116. if (inputDate > today || inputDate === "Invalid Date" || inputDate.getFullYear().toString() !== subStr_year || (inputDate.getMonth() + 1).toString().padStart(2, "0") !== subStr_month || inputDate.getDate().toString().padStart(2, "0") !== subStr_date) {
  117. return false
  118. } else {
  119. return true
  120. }
  121. } else {
  122. return false
  123. }
  124. case "otherCert":
  125. if (value.match(pattern_otherCert)) {
  126. return true
  127. } else {
  128. return false
  129. }
  130. default:
  131. break;
  132. }
  133. }
  134. })
  135. }),
  136. checkDigit: yup.string().when('verifiedBy', {
  137. is: (verifiedBy) => verifiedBy != null,
  138. then: (schema) => schema.notRequired(),
  139. otherwise: (schema) => schema.max(1, getMaxErrStr(1)).nullable()
  140. .matches(/^[A-Z0-9\s]+$/, { message: displayErrorMsg(`${selectedIdDocInputType}${intl.formatMessage({ id: 'noSpecialCharacter' })}`) })
  141. .test('checkIDCardFormat', displayErrorMsg(`${intl.formatMessage({ id: 'requiredNumberInQuote' })}`), function (value) {
  142. // console.log(selectedIdDocInputType)
  143. if (value != undefined || value != null) {
  144. switch (selectedIdDocInputType) {
  145. case "HKID":
  146. if (value.length == 1) {
  147. return true
  148. } else {
  149. return false
  150. }
  151. case "passport":
  152. return true
  153. case "CNID":
  154. return true
  155. case "otherCert":
  156. return true
  157. default:
  158. break;
  159. }
  160. } else {
  161. if (selectedIdDocInputType != "HKID"){
  162. return true
  163. } else {
  164. return false
  165. }
  166. }
  167. })
  168. }),
  169. tel_countryCode: yup.string().min(3, intl.formatMessage({ id: 'require3Number' })).required(intl.formatMessage({ id: 'requireDialingCode' })),
  170. fax_countryCode: yup.string().min(3, intl.formatMessage({ id: 'require3Number' })),
  171. phoneNumber: yup.string().min(8, intl.formatMessage({ id: 'require8Number' })).required(intl.formatMessage({ id: 'requireContactNumber' })),
  172. faxNumber: yup.string().min(8, intl.formatMessage({ id: 'require8Number' })).nullable(),
  173. }),
  174. onSubmit: values => {
  175. if (values.country == null) {
  176. setErrorMsg(intl.formatMessage({ id: 'pleaseFillInCountry' }))
  177. } else {
  178. if (values.country.type == "hongKong" && values.district == null) {
  179. setErrorMsg(intl.formatMessage({ id: 'pleaseFillInDistrict' }))
  180. } else {
  181. HttpUtils.post({
  182. url: UrlUtils.POST_IND_USER + "/" + formData.id,
  183. params: {
  184. prefix: values.prefix,
  185. enName: values.enName,
  186. chName: values.chName,
  187. idDocType: values.idDocType,
  188. mobileNumber: {
  189. countryCode: values.tel_countryCode,
  190. phoneNumber: values.phoneNumber
  191. },
  192. ...(values.verifiedBy == null ? {
  193. identification: values.identification,
  194. checkDigit: values.checkDigit,
  195. } : {}),
  196. faxNo: {
  197. countryCode: values.fax_countryCode,
  198. faxNumber: values.faxNumber
  199. },
  200. emailAddress: values.emailAddress,
  201. address: {
  202. country: values.country.type,
  203. district: values.district?.type,
  204. addressLine1: values.addressLine1,
  205. addressLine2: values.addressLine2,
  206. addressLine3: values.addressLine3,
  207. },
  208. preferLocale: values.preferLocale.type
  209. },
  210. onSuccess: function () {
  211. notifySaveSuccess();
  212. loadDataFun();
  213. }
  214. });
  215. }
  216. }
  217. }
  218. });
  219. useEffect(() => {
  220. if (Object.keys(formData).length > 0) {
  221. setCurrentUserData(formData);
  222. }
  223. }, [formData]);
  224. useEffect(() => {
  225. setLocked(currentUserData.locked);
  226. }, [currentUserData]);
  227. const onEditClick = () => {
  228. setEditMode(true);
  229. };
  230. const onVerifiedClick = () => {
  231. HttpUtils.get({
  232. url: UrlUtils.GET_IND_USER_VERIFY + "/" + formData.id,
  233. onSuccess: function () {
  234. notifyVerifySuccess()
  235. loadDataFun();
  236. }
  237. });
  238. };
  239. const doLock = () => {
  240. HttpUtils.get({
  241. url: UrlUtils.GET_USER_LOCK + "/" + formData.id,
  242. onSuccess: function () {
  243. notifyLockSuccess()
  244. loadDataFun();
  245. }
  246. });
  247. };
  248. const doUnlock = () => {
  249. HttpUtils.get({
  250. url: UrlUtils.GET_USER_UNLOCK + "/" + formData.id,
  251. onSuccess: function () {
  252. notifyActiveSuccess()
  253. loadDataFun();
  254. }
  255. });
  256. };
  257. return (
  258. <MainCard elevation={0}
  259. border={false}
  260. content={false}
  261. >
  262. {!onReady ?
  263. <LoadingComponent />
  264. :
  265. <form onSubmit={formik.handleSubmit} style={{ padding: 12 }}>
  266. {/*top button*/}
  267. {
  268. isGrantedAny(["MAINTAIN_USER", "MAINTAIN_IND_USER"]) ?
  269. <Grid item xs={12} sm={12} md={12} lg={12} sx={{ mb: 3 }} alignItems={"start"} justifyContent="center">
  270. <Grid container maxWidth justifyContent="flex-start">
  271. {editMode ?
  272. <>
  273. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  274. <Grid item sx={{ mr: 3 }}>
  275. <Button
  276. variant="contained"
  277. onClick={loadDataFun}
  278. color="cancel"
  279. >
  280. Reset & Back
  281. </Button>
  282. </Grid>
  283. <Grid item sx={{ ml: 3, mr: 3 }}>
  284. <Button
  285. variant="contained"
  286. type="submit"
  287. sx={PRIMARY_CONTAINED_BUTTON_SX}
  288. >
  289. Save
  290. </Button>
  291. </Grid>
  292. </ThemeProvider>
  293. </>
  294. :
  295. <>
  296. <Grid item sx={{ mr: 3 }}>
  297. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  298. <Button
  299. variant="contained"
  300. onClick={onEditClick}
  301. >
  302. Edit
  303. </Button>
  304. </ThemeProvider>
  305. </Grid>
  306. </>
  307. }
  308. </Grid>
  309. </Grid>
  310. : <></>
  311. }
  312. {/*end top button*/}
  313. <Typography variant="h4" sx={{ mt: 3, mb: 2, borderBottom: "1px solid black" }}>
  314. Individual User Details
  315. </Typography>
  316. <Grid item xs={12} sm={12} md={12} lg={12}>
  317. <Grid container>
  318. <Grid item xs={12}>
  319. <FormHelperText error id="helper-text-address1-signup">
  320. <Typography variant="errorMessage1">
  321. {errorMsg}
  322. </Typography>
  323. </FormHelperText>
  324. </Grid>
  325. <Grid item xs={12} sm={12} md={12} lg={4} >
  326. {FieldUtils.getTextField({
  327. label: "Username:",
  328. valueName: "username",
  329. disabled: true,
  330. form: formik
  331. })}
  332. </Grid>
  333. <Grid item xs={12} sm={12} md={12} lg={4}>
  334. {FieldUtils.getTextField({
  335. label: "English Name:",
  336. valueName: "enName",
  337. disabled: (!editMode),
  338. form: formik
  339. })}
  340. </Grid>
  341. <Grid item xs={12} sm={12} md={12} lg={4}>
  342. {FieldUtils.getTextField({
  343. label: "Created Date:",
  344. valueName: "createDate",
  345. disabled: true,
  346. form: formik
  347. })}
  348. </Grid>
  349. <Grid item xs={12} sm={12} md={12} lg={4}>
  350. {FieldUtils.getTextField({
  351. label: "Prefix:",
  352. valueName: "prefix",
  353. disabled: (!editMode),
  354. form: formik
  355. })}
  356. </Grid>
  357. <Grid item xs={12} sm={12} md={12} lg={4}>
  358. {FieldUtils.getTextField({
  359. label: "Chinese Name:",
  360. valueName: "chName",
  361. disabled: (!editMode),
  362. form: formik
  363. })}
  364. </Grid>
  365. <Grid item xs={12} sm={12} md={12} lg={4}>
  366. {FieldUtils.getTextField({
  367. label: "Last Updated:",
  368. valueName: "modifieDate",
  369. disabled: true,
  370. form: formik
  371. })}
  372. </Grid>
  373. <Grid item xs={12} sm={12} md={12} lg={4}>
  374. {FieldUtils.getComboField({
  375. label: `${en.idDocType}:`,
  376. valueName: "idDocType",
  377. disabled: (!editMode),
  378. dataList: ComboData.idDocType,
  379. filterOptions: (options) => options,
  380. getOptionLabel: getIdDocTypeLabel,
  381. isOptionEqualToValue: (option, value) => {
  382. if (typeof value === "string") {
  383. return option?.type === value;
  384. }
  385. return option?.type === value?.type;
  386. },
  387. onInputChange: (event, newValue, setInputValue) => {
  388. if (newValue == null) {
  389. setInputValue("");
  390. return;
  391. }
  392. setInputValue(newValue);
  393. },
  394. onChange: (event, newValue) => {
  395. if (newValue == null) {
  396. formik.setFieldValue("idDocType", "");
  397. setSelectedIdDocInputType("");
  398. return;
  399. }
  400. formik.setFieldValue("idDocType", newValue.type);
  401. setSelectedIdDocInputType(newValue.type);
  402. if (newValue.type !== "HKID") {
  403. formik.setFieldValue("checkDigit", "")
  404. }
  405. },
  406. form: formik
  407. })}
  408. </Grid>
  409. <Grid item xs={12} sm={12} md={12} lg={4}>
  410. {FieldUtils.getPhoneField({
  411. label: "Contact Tel:",
  412. valueName: {
  413. code: "tel_countryCode",
  414. num: "phoneNumber"
  415. },
  416. disabled: (!editMode),
  417. form: formik
  418. })}
  419. </Grid>
  420. <Grid item xs={12} sm={12} md={12} lg={4}>
  421. <Grid container alignItems={"center"}>
  422. <Grid item xs={12} md={3} lg={3} sx={{ display: 'flex', alignItems: 'center' }}>
  423. <Typography variant="h5">Verified:</Typography>
  424. </Grid>
  425. {
  426. !isGrantedAny(["MAINTAIN_USER", "MAINTAIN_IND_USER"]) || currentUserData.verifiedBy || editMode ?
  427. <Grid item xs={12} sm={12} md={6} lg={6} sx={{ mb: 2 }}>
  428. {FieldUtils.initField({
  429. valueName: "verifiedStatus",
  430. disabled: true,
  431. form: formik,
  432. })}
  433. </Grid>
  434. :
  435. <>
  436. <Grid item xs={8} sm={8} md={6} lg={4} sx={{ mb: 2 }}>
  437. {FieldUtils.initField({
  438. valueName: "verifiedStatus",
  439. disabled: true,
  440. form: formik,
  441. })}
  442. </Grid>
  443. <Grid item xs={2} sm={2} md={2} lg={2} sx={{ ml: 2, mb: 2 }}>
  444. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  445. <Button
  446. variant="contained"
  447. onClick={onVerifiedClick}
  448. >
  449. Verify
  450. </Button>
  451. </ThemeProvider>
  452. </Grid>
  453. </>
  454. }
  455. </Grid>
  456. </Grid>
  457. <Grid xs={12} sm={12} md={12} lg={4}>
  458. <Grid container alignItems={"center"} sx={{ mb: 2 }}>
  459. <Grid item xs={12} sm={12} md={3} lg={3} sx={{ display: 'flex', alignItems: 'center' }}>
  460. <Typography variant="h5">ID No.:</Typography>
  461. </Grid>
  462. <Grid item xs={12} sm={12} md={9} lg={6}>
  463. {currentUserData.verifiedBy ?
  464. <Typography variant="h5" mt={1}>
  465. Hidden for security purpose
  466. </Typography>
  467. :
  468. <Grid container>
  469. {formik.values.idDocType === "HKID" ?
  470. editMode ?
  471. <>
  472. <Grid item xs={6} sm={6} md={6} lg={7.5} sx={{ mr: 1 }}>
  473. {FieldUtils.initField({
  474. valueName: "identification",
  475. disabled: (!editMode),
  476. form: formik,
  477. placeholder: intl.formatMessage({ id: 'idDocNumber' }),
  478. inputProps: {
  479. maxLength: 7,
  480. onKeyDown: (e) => {
  481. if (e.key === 'Enter') {
  482. e.preventDefault();
  483. }
  484. },
  485. }
  486. })}
  487. </Grid>
  488. <Grid item xs={2} sm={2} md={2} lg={2} style={{ minWidth: 40 }}>
  489. {FieldUtils.initField({
  490. valueName: "checkDigit",
  491. disabled: (!editMode),
  492. form: formik,
  493. })}
  494. </Grid>
  495. </>
  496. :
  497. <Stack direction="row">
  498. <Typography variant="h5" mt={1}>
  499. {formik.values.identification?.slice(0, 4)}
  500. </Typography>
  501. <Typography variant="h5" mt={1}>
  502. {showId ? formik.values.identification?.slice(4) : "****"}{showId ? formik.values.checkDigit?'(' +formik.values.checkDigit+ ')': "()" : ""}
  503. </Typography>
  504. <IconButton
  505. aria-label={intl.formatMessage({ id: 'ariaToggleIdVisibility' })}
  506. onClick={handleClickShowId}
  507. onMouseDown={handleMouseDownId}
  508. edge="end"
  509. size="large"
  510. >
  511. {showId ? <EyeOutlined /> : <EyeInvisibleOutlined />}
  512. </IconButton>
  513. </Stack>
  514. :
  515. editMode ?
  516. <>
  517. <Grid item xs={10} sm={4} md={4} lg={10}>
  518. {FieldUtils.initField({
  519. valueName: "identification",
  520. disabled: (!editMode),
  521. form: formik
  522. })}
  523. </Grid>
  524. </>
  525. :
  526. <Stack direction="row">
  527. <Typography variant="h5" mt={1}>
  528. {formik.values.identification?.slice(0, 4)}
  529. </Typography>
  530. <Typography variant="h5" mt={1}>
  531. {showId ? formik.values.identification?.slice(4) : "****"}
  532. </Typography>
  533. <IconButton
  534. aria-label={intl.formatMessage({ id: 'ariaToggleIdVisibility' })}
  535. onClick={handleClickShowId}
  536. onMouseDown={handleMouseDownId}
  537. edge="end"
  538. size="large"
  539. >
  540. {showId ? <EyeOutlined /> : <EyeInvisibleOutlined />}
  541. </IconButton>
  542. </Stack>
  543. }
  544. </Grid>
  545. }
  546. </Grid>
  547. </Grid>
  548. </Grid>
  549. <Grid item xs={12} sm={12} md={12} lg={4}>
  550. {FieldUtils.getPhoneField({
  551. label: "Fax No.:",
  552. valueName: {
  553. code: "fax_countryCode",
  554. num: "faxNumber"
  555. },
  556. disabled: (!editMode),
  557. form: formik
  558. })}
  559. </Grid>
  560. <Grid item xs={12} sm={12} md={12} lg={4}>
  561. {FieldUtils.getTextField({
  562. label: "Last Login:",
  563. valueName: "lastLoginDate",
  564. disabled: true,
  565. form: formik
  566. })}
  567. </Grid>
  568. <Grid item xs={12} sm={12} md={12} lg={4}>
  569. {FieldUtils.getComboField({
  570. label: intl.formatMessage({ id: 'language' }) + ":",
  571. valueName: "preferLocale",
  572. dataList: ComboData.Locale,
  573. getOptionLabel: (option) => (option?.label != null ? String(option.label) : ""),
  574. disabled: (!editMode),
  575. form: formik
  576. })}
  577. </Grid>
  578. <Grid item xs={12} sm={12} md={12} lg={4}>
  579. {FieldUtils.getTextField({
  580. label: "Email:",
  581. valueName: "emailAddress",
  582. disabled: (!editMode),
  583. form: formik
  584. })}
  585. </Grid>
  586. <Grid item xs={12} sm={12} md={12} lg={4}>
  587. <Grid container alignItems={"center"} sx={{ mb: 2 }}>
  588. <Grid item xs={12} sm={12} md={3} lg={3} sx={{ display: 'flex', alignItems: 'center' }}>
  589. <Typography variant="h5">Status:</Typography>
  590. </Grid>
  591. {
  592. !isGrantedAny(["MAINTAIN_USER", "MAINTAIN_IND_USER"]) || editMode ?
  593. <Grid item xs={8} sm={8} md={6} lg={6}>
  594. {FieldUtils.initField({
  595. valueName: "status",
  596. disabled: true,
  597. form: formik,
  598. })}
  599. </Grid>
  600. :
  601. <>
  602. <Grid item xs={8} sm={8} md={6} lg={4}>
  603. {FieldUtils.initField({
  604. valueName: "status",
  605. disabled: true,
  606. form: formik,
  607. })}
  608. </Grid>
  609. {
  610. locked ?
  611. <Grid item xs={2} sm={2} md={2} lg={2} sx={{ ml: 2 }}>
  612. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  613. <Button
  614. variant="contained"
  615. color="success"
  616. onClick={doUnlock}
  617. >
  618. Active
  619. </Button>
  620. </ThemeProvider>
  621. </Grid>
  622. :
  623. <Grid item xs={2} sm={2} md={2} lg={2} sx={{ ml: 2 }}>
  624. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  625. <Button
  626. variant="contained"
  627. color="error"
  628. onClick={doLock}
  629. >
  630. Lock
  631. </Button>
  632. </ThemeProvider>
  633. </Grid>
  634. }
  635. </>
  636. }
  637. </Grid>
  638. </Grid>
  639. <Grid item xs={12} sm={12} md={12} lg={12}>
  640. {FieldUtils.getAddressField({
  641. label: "Address:",
  642. valueName: ["addressLine1", "addressLine2", "addressLine3"],
  643. disabled: (!editMode),
  644. form: formik
  645. })}
  646. </Grid>
  647. <Grid item xs={12} sm={12} md={12} lg={12}>
  648. {FieldUtils.getProfileComboField({
  649. label: "",
  650. valueName: "district",
  651. dataList: ComboData.district,
  652. getOptionLabel: (option) => option.type ? intl.formatMessage({ id: option.type }) : "",
  653. disabled: (!editMode),
  654. form: formik
  655. })}
  656. </Grid>
  657. <Grid item xs={12} sm={12} md={12} lg={12}>
  658. {FieldUtils.getProfileComboField({
  659. label: "",
  660. valueName: "country",
  661. getOptionLabel: (option) => option.type ? intl.formatMessage({ id: option.type }) : "",
  662. dataList: ComboData.country,
  663. disabled: true,
  664. form: formik
  665. })}
  666. </Grid>
  667. </Grid>
  668. </Grid>
  669. </form>
  670. }
  671. </MainCard>
  672. );
  673. };
  674. export default UserInformationCard_Individual;