You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

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