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.
 
 

231 rivejä
11 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 {getObjectByValue,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} from "react-intl";
  36. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  37. const UserMaintainPage_Individual = () => {
  38. const params = useParams();
  39. const navigate = useNavigate();
  40. const [formData, setFormData] = React.useState({})
  41. const [loginLogData, setLoginLogData] = React.useState([])
  42. const [isLoading, setLoding] = React.useState(true);
  43. const [selectedTab, setSelectedTab] = React.useState("1");
  44. React.useEffect(() => {
  45. if (isORGLoggedIn()){
  46. navigate('/dashboard');
  47. }else{
  48. loadData();
  49. }
  50. }, []);
  51. const handleChange = (event, newValue) => {
  52. setSelectedTab(newValue);
  53. }
  54. const loadData = () => {
  55. setLoding(true);
  56. if (isGLDLoggedIn()){
  57. HttpUtils.get({
  58. url: `${UrlUtils.GET_IND_USER_PATH}/${params.id}`,
  59. onSuccess: function (response) {
  60. response.data["address"] = JSON.parse(response.data["address"]);
  61. response.data["mobileNumber"] = JSON.parse(response.data["mobileNumber"]);
  62. response.data["faxNo"] = JSON.parse(response.data["faxNo"]);
  63. let createDate = DateUtils.datetimeStr(response.data.created);
  64. let modifiedBy = DateUtils.datetimeStr(response.data.modified) + ", " + response.data.modifiedBy;
  65. response.data["createDate"] = createDate;
  66. response.data["modifieDate"] = modifiedBy;
  67. response.data["verifiedStatus"] = response.data.verifiedBy ? DateUtils.datetimeStr(response.data.verifiedDate) + ", " + response.data.verifiedByName : "Not Verified";
  68. response.data["country"] = getObjectByValue(ComboData.country, "key", response.data.address?.country);
  69. response.data["district"] = getObjectByType(ComboData.district, "type", response.data.address?.district);
  70. response.data["addressLine1"] = response.data.address?.addressLine1;
  71. response.data["addressLine2"] = response.data.address?.addressLine2;
  72. response.data["addressLine3"] = response.data.address?.addressLine3;
  73. response.data["phoneNumber"] = response.data.mobileNumber?.phoneNumber;
  74. response.data["tel_countryCode"] = response.data.mobileNumber?.countryCode;
  75. response.data["faxNumber"] = response.data.faxNo?.faxNumber;
  76. response.data["fax_countryCode"] = response.data.faxNo?.countryCode;
  77. response.data["lastLoginDate"] = response.data.lastLogin ? DateUtils.datetimeStr(response.data.lastLogin) : "";
  78. response.data["preferLocale"] = getObjectByType(ComboData.Locale, "type", response.data?.preferLocale);
  79. setFormData(response.data);
  80. getLoginLogList()
  81. }
  82. });
  83. }
  84. else if (isINDLoggedIn()){
  85. HttpUtils.get({
  86. url: `${UrlUtils.GET_PUB_IND_USER_PATH}`,
  87. onSuccess: function (response) {
  88. response.data["address"] = JSON.parse(response.data["address"]);
  89. response.data["mobileNumber"] = JSON.parse(response.data["mobileNumber"]);
  90. response.data["faxNo"] = JSON.parse(response.data["faxNo"]);
  91. response.data["country"] = getObjectByValue(ComboData.country, "key", response.data.address?.country);
  92. response.data["district"] = getObjectByType(ComboData.district, "type", response.data.address?.district);
  93. response.data["addressLine1"] = response.data.address?.addressLine1;
  94. response.data["addressLine2"] = response.data.address?.addressLine2;
  95. response.data["addressLine3"] = response.data.address?.addressLine3;
  96. response.data["phoneNumber"] = response.data.mobileNumber?.phoneNumber;
  97. response.data["tel_countryCode"] = response.data.mobileNumber?.countryCode;
  98. response.data["faxNumber"] = response.data.faxNo?.faxNumber;
  99. response.data["fax_countryCode"] = response.data.faxNo?.countryCode;
  100. response.data["preferLocale"] = getObjectByType(ComboData.Locale, "type", response.data?.preferLocale);
  101. // console.log(response.data)
  102. setFormData(response.data);
  103. }
  104. });
  105. }
  106. };
  107. const getLoginLogList = () => {
  108. HttpUtils.get({
  109. url: `${UrlUtils.GET_LOGIN_LOG_LIST}`,
  110. params:{
  111. userId:params.id
  112. },
  113. onSuccess: function (response) {
  114. // console.log(response)
  115. setLoginLogData(response);
  116. }
  117. });
  118. }
  119. React.useEffect(() => {
  120. setLoding(false);
  121. }, [loginLogData]);
  122. return (
  123. isLoading ?
  124. <Grid container sx={{ minHeight: '87vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center">
  125. <Grid item>
  126. <LoadingComponent />
  127. </Grid>
  128. </Grid>
  129. :
  130. <Grid container direction="column" sx={{minHeight: '87vh', backgroundColor: isGLDLoggedIn()?'backgroundColor.default':'#ffffff', maxWidth:'100%' }}>
  131. <Grid item xs={12}>
  132. <div style={BackgroundHead}>
  133. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  134. {isGLDLoggedIn()?
  135. <Typography ml={15} color='#FFF' variant="h4" sx={{display: { xs: 'none', sm: 'none', md: 'block', pt:2 }}}>
  136. Maintain Individual User
  137. </Typography>
  138. :
  139. <Typography ml={15} color='#FFF' variant="h4" sx={{display: { xs: 'none', sm: 'none', md: 'block', pt:2 }}}>
  140. <FormattedMessage id="userProfile" />
  141. </Typography>
  142. }
  143. </Stack>
  144. </div>
  145. </Grid>
  146. <Grid item xs={12}>
  147. <Button title="Back"
  148. sx={{ ml: 3.5, mt: 2 }} style={{ border: '2px solid' }}
  149. variant="outlined" onClick={() => { navigate(-1) }}
  150. >
  151. <ForwardIcon style={{ height: 30, width: 50, transform: "rotate(180deg)" }} />
  152. </Button>
  153. </Grid>
  154. {/*col 1*/}
  155. <Grid item xs={12} sm={12} md={12} lg={12} >
  156. <Grid container>
  157. {isGLDLoggedIn()?
  158. <Grid item xs={12} sm={12} md={12} lg={12} >
  159. <UserInformationCard
  160. formData={formData}
  161. loadDataFun={loadData}
  162. />
  163. </Grid>
  164. :isINDLoggedIn()?
  165. <Grid item xs={12} sm={12} md={12} lg={12} >
  166. <UserInformationPubCard
  167. formData={formData}
  168. loadDataFun={loadData}
  169. />
  170. </Grid>
  171. :null
  172. }
  173. {isGLDLoggedIn()?
  174. <Grid item xs={12} md={12} lg={12}>
  175. <MainCard elevation={0} border={false} content={false} sx={{maxWidth: '100%', mr:2, width: "-webkit-fill-available"}}>
  176. <TabContext value={selectedTab}>
  177. <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
  178. <TabList variant="scrollable" onChange={handleChange} aria-label="lab API tabs example">
  179. <Tab label="Files" value="1" />
  180. <Tab label="Login" value="2" />
  181. </TabList>
  182. </Box>
  183. <TabPanel value="1">
  184. <FileList
  185. refId={params.id}
  186. refType={"identification"}
  187. />
  188. </TabPanel>
  189. <TabPanel value="2">
  190. <LoginGrid
  191. rows = {loginLogData}
  192. />
  193. </TabPanel>
  194. </TabContext>
  195. </MainCard>
  196. <br />
  197. </Grid>
  198. :null
  199. }
  200. </Grid>
  201. </Grid>
  202. {/*col 2*/}
  203. </Grid>
  204. );
  205. };
  206. export default UserMaintainPage_Individual;