Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

738 lignes
39 KiB

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