Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

218 строки
10 KiB

  1. // material-ui
  2. import * as React from "react";
  3. import { Grid, Typography, Button, Stack, Box, Tab } from '@mui/material';
  4. import { TabPanel, TabContext, TabList } from '@mui/lab';
  5. import FileList from "components/FileList"
  6. import MainCard from "components/MainCard";
  7. import * as HttpUtils from "utils/HttpUtils";
  8. import { useParams } from "react-router-dom";
  9. import * as UrlUtils from "utils/ApiPathConst";
  10. import * as DateUtils from 'utils/DateUtils';
  11. import ForwardIcon from '@mui/icons-material/Forward';
  12. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  13. const BackgroundHead = {
  14. backgroundImage: `url(${titleBackgroundImg})`,
  15. width: '100%',
  16. height: '100%',
  17. backgroundSize: 'contain',
  18. backgroundRepeat: 'no-repeat',
  19. backgroundColor: '#0C489E',
  20. backgroundPosition: 'right'
  21. }
  22. import Loadable from 'components/Loadable';
  23. import { useNavigate } from "react-router-dom";
  24. import {getObjectByType} from "utils/CommonFunction";
  25. import * as ComboData from "utils/ComboData";
  26. const LoadingComponent = Loadable(React.lazy(() => import('../../extra-pages/LoadingComponent')));
  27. const UserInformationCard = Loadable(React.lazy(() => import('./UserInformationCard_Individual')));
  28. const UserInformationPubCard = Loadable(React.lazy(() => import('./UserInformationCard_Individual_Pub')));
  29. const LoginGrid = Loadable(React.lazy(() => import('./LoginGrid')));
  30. import {
  31. isGLDLoggedIn,
  32. isINDLoggedIn,
  33. isORGLoggedIn
  34. } from "utils/Utils";
  35. import {FormattedMessage, useIntl} from "react-intl";
  36. import usePageTitle from "components/usePageTitle";
  37. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  38. const UserMaintainPage_Individual = () => {
  39. usePageTitle("userProfile");
  40. const intl = useIntl();
  41. const params = useParams();
  42. const navigate = useNavigate();
  43. const [formData, setFormData] = React.useState({})
  44. const [isLoading, setLoding] = React.useState(true);
  45. const [selectedTab, setSelectedTab] = React.useState("1");
  46. React.useEffect(() => {
  47. if (isORGLoggedIn()){
  48. navigate('/dashboard');
  49. }else{
  50. loadData();
  51. }
  52. }, []);
  53. const handleChange = (event, newValue) => {
  54. setSelectedTab(newValue);
  55. }
  56. const loadData = () => {
  57. setLoding(true);
  58. if (isGLDLoggedIn()){
  59. HttpUtils.get({
  60. url: `${UrlUtils.GET_IND_USER_PATH}/${params.id}`,
  61. onSuccess: function (response) {
  62. response.data["address"] = JSON.parse(response.data["address"]);
  63. response.data["mobileNumber"] = JSON.parse(response.data["mobileNumber"]);
  64. response.data["faxNo"] = JSON.parse(response.data["faxNo"]);
  65. let createDate = DateUtils.datetimeStr(response.data.created);
  66. let modifiedBy = DateUtils.datetimeStr(response.data.modified) + ", " + response.data.modifiedBy;
  67. response.data["createDate"] = createDate;
  68. response.data["modifieDate"] = modifiedBy;
  69. response.data["verifiedStatus"] = response.data.verifiedBy ? DateUtils.datetimeStr(response.data.verifiedDate) + ", " + response.data.verifiedByName : "Not Verified";
  70. response.data["country"] = getObjectByType(ComboData.country, "type", response.data.address?.country);
  71. response.data["district"] = getObjectByType(ComboData.district, "type", response.data.address?.district);
  72. response.data["addressLine1"] = response.data.address?.addressLine1;
  73. response.data["addressLine2"] = response.data.address?.addressLine2;
  74. response.data["addressLine3"] = response.data.address?.addressLine3;
  75. response.data["phoneNumber"] = response.data.mobileNumber?.phoneNumber;
  76. response.data["tel_countryCode"] = response.data.mobileNumber?.countryCode;
  77. response.data["faxNumber"] = response.data.faxNo?.faxNumber;
  78. response.data["fax_countryCode"] = response.data.faxNo?.countryCode;
  79. response.data["lastLoginDate"] = response.data.lastLogin ? DateUtils.datetimeStr(response.data.lastLogin) : "";
  80. response.data["preferLocale"] = getObjectByType(ComboData.Locale, "type", response.data?.preferLocale);
  81. setFormData(response.data);
  82. setLoding(false);
  83. }
  84. });
  85. }
  86. else if (isINDLoggedIn()){
  87. HttpUtils.get({
  88. url: `${UrlUtils.GET_PUB_IND_USER_PATH}`,
  89. onSuccess: function (response) {
  90. response.data["address"] = JSON.parse(response.data["address"]);
  91. response.data["mobileNumber"] = JSON.parse(response.data["mobileNumber"]);
  92. response.data["faxNo"] = JSON.parse(response.data["faxNo"]);
  93. response.data["country"] = getObjectByType(ComboData.country, "type", response.data.address?.country);
  94. response.data["district"] = getObjectByType(ComboData.district, "type", response.data.address?.district);
  95. response.data["addressLine1"] = response.data.address?.addressLine1;
  96. response.data["addressLine2"] = response.data.address?.addressLine2;
  97. response.data["addressLine3"] = response.data.address?.addressLine3;
  98. response.data["phoneNumber"] = response.data.mobileNumber?.phoneNumber;
  99. response.data["tel_countryCode"] = response.data.mobileNumber?.countryCode;
  100. response.data["faxNumber"] = response.data.faxNo?.faxNumber;
  101. response.data["fax_countryCode"] = response.data.faxNo?.countryCode;
  102. response.data["preferLocale"] = getObjectByType(ComboData.Locale, "type", response.data?.preferLocale);
  103. // console.log(response.data)
  104. setFormData(response.data);
  105. setLoding(false);
  106. }
  107. });
  108. }
  109. };
  110. return (
  111. isLoading ?
  112. <Grid container sx={{ minHeight: '87vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center">
  113. <Grid item>
  114. <LoadingComponent />
  115. </Grid>
  116. </Grid>
  117. :
  118. <Grid container direction="column" sx={{minHeight: '87vh', backgroundColor: isGLDLoggedIn()?'backgroundColor.default':'#ffffff', maxWidth:'100%' }}>
  119. <Grid item xs={12}>
  120. <div style={BackgroundHead}>
  121. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  122. {isGLDLoggedIn()?
  123. <Typography ml={15} color='#FFF' variant="h4" sx={{display: { xs: 'none', sm: 'none', md: 'block', pt:2 }}}>
  124. Maintain Individual User
  125. </Typography>
  126. :
  127. <Typography ml={15} color='#FFF' variant="h4" sx={{display: { xs: 'none', sm: 'none', md: 'block', pt:2 }}}>
  128. <FormattedMessage id="userProfile" />
  129. </Typography>
  130. }
  131. </Stack>
  132. </div>
  133. </Grid>
  134. <Grid item xs={12}>
  135. <Button title={intl.formatMessage({ id: "back" })}
  136. aria-label={intl.formatMessage({ id: "back" })}
  137. sx={{ ml: 3.5, mt: 2 }} style={{ border: '2px solid' }}
  138. variant="outlined" onClick={() => { navigate(-1) }}
  139. >
  140. <ForwardIcon style={{ height: 30, width: 50, transform: "rotate(180deg)" }} />
  141. </Button>
  142. </Grid>
  143. {/*col 1*/}
  144. <Grid item xs={12} sm={12} md={12} lg={12} >
  145. <Grid container>
  146. {isGLDLoggedIn()?
  147. <Grid item xs={12} sm={12} md={12} lg={12} >
  148. <UserInformationCard
  149. formData={formData}
  150. loadDataFun={loadData}
  151. />
  152. </Grid>
  153. :isINDLoggedIn()?
  154. <Grid item xs={12} sm={12} md={12} lg={12} >
  155. <UserInformationPubCard
  156. formData={formData}
  157. loadDataFun={loadData}
  158. />
  159. </Grid>
  160. :null
  161. }
  162. {isGLDLoggedIn()?
  163. <Grid item xs={12} md={12} lg={12}>
  164. <MainCard elevation={0} border={false} content={false} sx={{maxWidth: '100%', mr:2, width: "-webkit-fill-available"}}>
  165. <TabContext value={selectedTab}>
  166. <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
  167. <TabList variant="scrollable" onChange={handleChange} aria-label="lab API tabs example">
  168. <Tab label="Attachments" value="1" />
  169. <Tab label="Login Log" value="2" />
  170. </TabList>
  171. </Box>
  172. <TabPanel value="1">
  173. <FileList
  174. refId={params.id}
  175. refType={"identification"}
  176. />
  177. </TabPanel>
  178. <TabPanel value="2">
  179. <LoginGrid
  180. u1 = {params.id}
  181. />
  182. </TabPanel>
  183. </TabContext>
  184. </MainCard>
  185. <br />
  186. </Grid>
  187. :null
  188. }
  189. </Grid>
  190. </Grid>
  191. {/*col 2*/}
  192. </Grid>
  193. );
  194. };
  195. export default UserMaintainPage_Individual;