選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

202 行
9.1 KiB

  1. // material-ui
  2. import { Grid, Typography, Stack, Box, Button } from '@mui/material';
  3. import * as React from "react";
  4. import * as HttpUtils from "utils/HttpUtils";
  5. import * as UrlUtils from "utils/ApiPathConst";
  6. import * as DateUtils from "utils/DateUtils";
  7. import Loadable from 'components/Loadable';
  8. const InfoCard = Loadable(React.lazy(() => import('./OrganizationCard')));
  9. const InfoPubCard = Loadable(React.lazy(() => import('./OrganizationPubCard')));
  10. const Table = Loadable(React.lazy(() => import('./CreditorHistoryTable')));
  11. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  12. import ForwardIcon from '@mui/icons-material/Forward';
  13. import { useNavigate, useParams } from 'react-router-dom';
  14. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  15. import {getObjectByType} from "utils/CommonFunction";
  16. import * as ComboData from "utils/ComboData";
  17. import {
  18. isGLDLoggedIn,
  19. isINDLoggedIn,
  20. isORGLoggedIn,
  21. isPrimaryLoggedIn
  22. } from "utils/Utils";
  23. const BackgroundHead = {
  24. backgroundImage: `url(${titleBackgroundImg})`,
  25. width: '100%',
  26. height: '100%',
  27. backgroundSize: 'contain',
  28. backgroundRepeat: 'no-repeat',
  29. backgroundColor: '#0C489E',
  30. backgroundPosition: 'right'
  31. }
  32. import {
  33. FormattedMessage,
  34. // FormattedMessage,
  35. useIntl
  36. } from "react-intl";
  37. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  38. const OrganizationDetailPage = () => {
  39. const params = useParams();
  40. const [formData, setFormData] = React.useState({})
  41. const [list, setList] = React.useState([])
  42. const [isLoading, setLoding] = React.useState(true);
  43. const [isEditMode, setEditMode] = React.useState(false);
  44. const navigate = useNavigate();
  45. const intl = useIntl();
  46. const { locale } = intl;
  47. const isCreditor = locale === 'en' ?"Yes":locale === 'zh-HK' ?"是":"是";
  48. const notCreditor = locale === 'en' ?"No":locale === 'zh-HK' ?"否":"否";
  49. React.useEffect(() => {
  50. // console.log(formData);
  51. if (isINDLoggedIn()||isORGLoggedIn()&&!isPrimaryLoggedIn()){
  52. navigate('/dashboard');
  53. }else{
  54. loadData();
  55. }
  56. loadData();
  57. }, []);
  58. const loadData = () => {
  59. setLoding(true);
  60. if(isGLDLoggedIn()){
  61. if (params.id > 0) {
  62. HttpUtils.get({
  63. url: UrlUtils.GET_ORG_PATH + "/" + params.id,
  64. onSuccess: function (response) {
  65. // console.log(response)
  66. response.data["country"] = getObjectByType(ComboData.country, "type", response.data.addressTemp?.country);
  67. response.data["district"] = getObjectByType(ComboData.district, "type", response.data.addressTemp?.district);
  68. response.data["addressLine1"] = response.data.addressTemp?.addressLine1;
  69. response.data["addressLine2"] = response.data.addressTemp?.addressLine2;
  70. response.data["addressLine3"] = response.data.addressTemp?.addressLine3;
  71. response.data["phoneNumber"] = response.data.contactTel?.phoneNumber;
  72. response.data["tel_countryCode"] = response.data.contactTel?.countryCode;
  73. response.data["faxNumber"] = response.data.faxNo?.faxNumber;
  74. response.data["fax_countryCode"] = response.data.faxNo?.countryCode;
  75. response.data["brExpiryDate"] = response.data.brExpiryDate ? DateUtils.dateValue(response.data.brExpiryDate) : "";
  76. setFormData(response.data)
  77. setList(response.historyList)
  78. }
  79. });
  80. }
  81. }
  82. if(isPrimaryLoggedIn()){
  83. HttpUtils.get({
  84. url: UrlUtils.GET_PUB_ORG_PATH,
  85. onSuccess: function (response) {
  86. // console.log(response)
  87. response.data["creditor"] = response.data.creditor!=null?response.data.creditor?isCreditor:notCreditor:notCreditor;
  88. response.data["country"] = getObjectByType(ComboData.country, "type", response.data.addressTemp?.country);
  89. response.data["district"] = getObjectByType(ComboData.district, "type", response.data.addressTemp?.district);
  90. response.data["addressLine1"] = response.data.addressTemp?.addressLine1;
  91. response.data["addressLine2"] = response.data.addressTemp?.addressLine2;
  92. response.data["addressLine3"] = response.data.addressTemp?.addressLine3;
  93. response.data["phoneNumber"] = response.data.contactTel?.phoneNumber;
  94. response.data["tel_countryCode"] = response.data.contactTel?.countryCode;
  95. response.data["faxNumber"] = response.data.faxNo?.faxNumber;
  96. response.data["fax_countryCode"] = response.data.faxNo?.countryCode;
  97. response.data["brExpiryDate"] = response.data.brExpiryDate ? DateUtils.dateValue(response.data.brExpiryDate) : "";
  98. setFormData(response.data)
  99. setList(response.historyList)
  100. }
  101. });
  102. }
  103. };
  104. React.useEffect(() => {
  105. setLoding(false);
  106. }, [formData]);
  107. return (
  108. isLoading ?
  109. <Grid container sx={{ minHeight: '87vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center">
  110. <Grid item>
  111. <LoadingComponent />
  112. </Grid>
  113. </Grid>
  114. :
  115. <Grid container direction="column" sx={{minHeight: '87vh',backgroundColor:isGLDLoggedIn()?'backgroundColor.default':'#ffffff' }}>
  116. <Grid item xs={12}>
  117. <div style={BackgroundHead}>
  118. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  119. {isGLDLoggedIn()?
  120. <Typography ml={15} color='#FFF' variant="h4" sx={{display: { xs: 'none', sm: 'none', md: 'block' }}}>
  121. Maintain Organisation
  122. </Typography>
  123. :
  124. <Typography ml={15} color='#FFF' variant="h4" sx={{display: { xs: 'none', sm: 'none', md: 'block' }}}>
  125. <FormattedMessage id="organizationProfile" />
  126. </Typography>
  127. }
  128. </Stack>
  129. </div>
  130. </Grid>
  131. <Grid item xs={12}>
  132. <Button aria-label={intl.formatMessage({id: 'back'})} title="Back" sx={{ ml: 3.5, mt: 2 }} style={{ border: '2px solid' }} variant="outlined" onClick={() => { navigate(-1)}}>
  133. <ForwardIcon style={{ height: 30, width: 50, transform: "rotate(180deg)" }} />
  134. </Button>
  135. </Grid>
  136. {/*col 1*/}
  137. <Grid item xs={12} >
  138. <Grid container>
  139. <Grid item xs={12} md={12} lg={12}>
  140. <Box xs={12} ml={0} mt={-1} mr={0} sx={{ p: 1, borderRadius: '10px' }}>
  141. {isGLDLoggedIn()?
  142. <InfoCard
  143. userData={formData}
  144. loadDataFun={loadData}
  145. id={params.id}
  146. setEditModeFun={setEditMode}
  147. />
  148. :
  149. <InfoPubCard
  150. userData={formData}
  151. loadDataFun={loadData}
  152. id={params.id}
  153. setEditModeFun={setEditMode}
  154. />
  155. }
  156. </Box>
  157. <br />
  158. </Grid>
  159. {isGLDLoggedIn()?
  160. <Grid item xs={12} md={12} lg={12} display={isEditMode?"none":""}>
  161. <Box xs={12} ml={0} mt={-1} mr={0} sx={{ pl:4, pr:4, pb:2 }}>
  162. <Grid container sx={{ p: 3, backgroundColor: "#FFF", borderRadius: '10px' }}>
  163. <Grid item xs={12} sx={{ p:1 }}>
  164. <Table
  165. sx={{ p: 1 }}
  166. recordList={list}
  167. >
  168. </Table>
  169. </Grid>
  170. </Grid>
  171. </Box>
  172. </Grid>
  173. : null
  174. }
  175. </Grid>
  176. </Grid>
  177. {/*col 2*/}
  178. </Grid>
  179. );
  180. };
  181. export default OrganizationDetailPage;