25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

UserInformationCard_Individual.js 38 KiB

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