Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 

246 Zeilen
12 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. Tab,
  6. Box,
  7. Button,
  8. Stack
  9. } from '@mui/material';
  10. import { TabPanel, TabContext, TabList } from '@mui/lab';
  11. import { useEffect, useState } from "react";
  12. import { useNavigate } from "react-router-dom";
  13. import * as React from "react";
  14. import * as HttpUtils from "utils/HttpUtils";
  15. import {
  16. GET_PUBLIC_NOTICE_LIST_ListByStatus,
  17. GET_PUBLIC_NOTICE_LIST_ListByStatus_submitted,
  18. GET_PUBLIC_NOTICE_LIST_ListByStatus_pendingPayment,
  19. GET_PUBLIC_NOTICE_LIST_ListByStatus_pendingPublish
  20. } from "utils/ApiPathConst";
  21. import Loadable from 'components/Loadable';
  22. import { lazy } from 'react';
  23. const BaseGrid = Loadable(lazy(() => import('./BaseGrid')));
  24. const PendingPaymentTab = Loadable(lazy(() => import('./PendingPaymentTab')));
  25. const LoadingComponent = Loadable(lazy(() => import('../../extra-pages/LoadingComponent')));
  26. const SearchTab = Loadable(lazy(() => import('./SearchPublicNoticeTab')));
  27. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  28. import { PNSPS_LONG_BUTTON_THEME } from "../../../themes/buttonConst";
  29. import { ThemeProvider } from "@emotion/react";
  30. import { FormattedMessage, useIntl } from "react-intl";
  31. import usePageTitle from 'components/usePageTitle';
  32. import { fetchOrgBrData, applyBlockVariant, applyClickVariant } from "utils/orgBrUtils";
  33. import BrStatusDialog from "components/BrStatusDialog";
  34. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  35. const PublicNotice = () => {
  36. usePageTitle("myPublicNotice");
  37. const [submittedCount, setSubmittedCount] = useState(0);
  38. const [pendingPaymentCount, setPendingPaymentCount] = useState(0);
  39. const [pendingPublishCount, setPendingPublishCount] = useState(0);
  40. const [isLoading, setLoding] = useState(true);
  41. const [selectedTab, setSelectedTab] = useState("1");
  42. const navigate = useNavigate();
  43. const intl = useIntl();
  44. const [orgBrData, setOrgBrData] = useState(null);
  45. const [brDialog, setBrDialog] = useState({ open: false, variant: null, afterClose: null });
  46. const _sx = {
  47. padding: "4 2 4 2",
  48. boxShadow: 1,
  49. border: 1,
  50. borderColor: '#DDD',
  51. '& .MuiDataGrid-cell': {
  52. borderTop: 1,
  53. borderBottom: 1,
  54. borderColor: "#EEE"
  55. },
  56. '& .MuiDataGrid-footerContainer': {
  57. border: 1,
  58. borderColor: "#EEE"
  59. },
  60. '& .MuiTabPanel-root': {
  61. padding: '0px',
  62. }
  63. }
  64. const BackgroundHead = {
  65. backgroundImage: `url(${titleBackgroundImg})`,
  66. width: '100%',
  67. height: '100%',
  68. backgroundSize: 'contain',
  69. backgroundRepeat: 'no-repeat',
  70. backgroundColor: '#0C489E',
  71. backgroundPosition: 'right'
  72. }
  73. useEffect(() => {
  74. loadData();
  75. fetchOrgBrData({
  76. onSuccess: (org) => setOrgBrData(org)
  77. });
  78. }, []);
  79. const loadData = () => {
  80. setLoding(true);
  81. HttpUtils.get({
  82. url: GET_PUBLIC_NOTICE_LIST_ListByStatus,
  83. onSuccess: function (response) {
  84. setSubmittedCount(response.submitted ?? 0);
  85. setPendingPaymentCount(response.pendingPayment ?? 0);
  86. setPendingPublishCount(response.pendingPublish ?? 0);
  87. }
  88. });
  89. };
  90. useEffect(() => {
  91. setLoding(false);
  92. }, [submittedCount]);
  93. const handleChange = (event, newValue) => {
  94. setSelectedTab(newValue);
  95. }
  96. const onBtnClick = () => {
  97. const variant = applyClickVariant(orgBrData);
  98. if (variant) {
  99. setBrDialog({
  100. open: true,
  101. variant,
  102. afterClose: applyBlockVariant(orgBrData) ? "stay" : "apply",
  103. });
  104. return;
  105. }
  106. navigate('/publicNotice/apply')
  107. }
  108. return (
  109. isLoading ?
  110. <Grid container sx={{ minHeight: '87vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center">
  111. <Grid item>
  112. <LoadingComponent />
  113. </Grid>
  114. </Grid>
  115. :
  116. <Grid container sx={{ minHeight: '87vh', backgroundColor: 'backgroundColor.default' }} direction="column">
  117. <Grid item xs={12}>
  118. <div style={BackgroundHead}>
  119. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  120. <Typography component="h1" ml={15} color='#FFF' variant="h4" sx={{ display: { xs: 'none', sm: 'none', md: 'block' } }}>
  121. <FormattedMessage id="myPublicNotice" />
  122. </Typography>
  123. </Stack>
  124. </div>
  125. </Grid>
  126. <Grid item xs={12} sm={12} md={12} lg={12} mt={1} sx={{ mt: 3, mr: { xs: 3, sm: 3, md: 0 } }} >
  127. <Stack direction="row" justifyContent="flex-end" alignItems="center">
  128. <ThemeProvider theme={PNSPS_LONG_BUTTON_THEME}>
  129. <Box sx={{ mr: { md: "47px" } }}>
  130. <Button
  131. aria-label={intl.formatMessage({ id: 'applyPublicNotice' })}
  132. variant="contained"
  133. onClick={() => { onBtnClick() }}
  134. >
  135. <FormattedMessage id="applyPublicNotice" />
  136. </Button>
  137. </Box>
  138. </ThemeProvider>
  139. </Stack>
  140. </Grid>
  141. {/*col 2*/}
  142. {
  143. JSON.parse(localStorage.getItem('userData')).creditor ? (
  144. <Grid item xs={12} sm={12} md={12} lg={12} sx={{ height: '100%', maxWidth: '100%', width: "-webkit-fill-available", backgroundColor: "#fff", mt: 3, mr: { xs: 1, md: 3 }, ml: { xs: 1, md: 3 }, mb: 3, ..._sx }}>
  145. <TabContext value={selectedTab}>
  146. <Box sx={{ borderBottom: 1, borderColor: 'divider', overflowX: 'auto', overflowY: 'auto' }}>
  147. <TabList variant="scrollable" onChange={handleChange} aria-label={intl.formatMessage({ id: 'ariaRelatedRecords' })} sx={{ display: 'flex', flexDirection: 'row' }}>
  148. <Tab aria-label={intl.formatMessage({ id: 'processing' })} label={intl.formatMessage({ id: 'processing' }) + " (" + submittedCount + ")"} value="1" />
  149. <Tab aria-label={intl.formatMessage({ id: 'pendingPublish' })} label={intl.formatMessage({ id: 'pendingPublish' }) + " (" + pendingPublishCount + ")"} value="3" />
  150. <Tab aria-label={intl.formatMessage({ id: 'pendingPayment' })} label={intl.formatMessage({ id: 'pendingPayment' }) + " (" + pendingPaymentCount + ")"} value="4" />
  151. <Tab aria-label={intl.formatMessage({ id: 'searchApplyRecord' })} label={intl.formatMessage({ id: 'searchApplyRecord' })} value="5" />
  152. </TabList>
  153. </Box>
  154. <TabPanel value="1">
  155. <BaseGrid
  156. url={GET_PUBLIC_NOTICE_LIST_ListByStatus_submitted}
  157. setCount={setSubmittedCount}
  158. />
  159. </TabPanel>
  160. <TabPanel value="3">
  161. <BaseGrid
  162. url={GET_PUBLIC_NOTICE_LIST_ListByStatus_pendingPublish}
  163. setCount={setPendingPublishCount}
  164. />
  165. </TabPanel>
  166. <TabPanel value="4">
  167. <BaseGrid
  168. url={GET_PUBLIC_NOTICE_LIST_ListByStatus_pendingPayment}
  169. setCount={setPendingPaymentCount}
  170. />
  171. </TabPanel>
  172. <TabPanel value="5">
  173. <SearchTab />
  174. </TabPanel>
  175. </TabContext>
  176. </Grid>
  177. ) : (
  178. <Grid item xs={12} sx={{ minHeight: '80vh', height: "100%", maxHeight: '300vh', maxWidth: '95%', width: "-webkit-fill-available", backgroundColor: "#fff", mt: 3, mr: { xs: 1, md: 3 }, ml: { xs: 1, md: 3 }, mb: 3, ..._sx }}>
  179. <TabContext value={selectedTab}>
  180. <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
  181. <TabList variant="scrollable" onChange={handleChange} aria-label={intl.formatMessage({ id: 'ariaApplicationGroup' })}>
  182. <Tab aria-label={intl.formatMessage({ id: 'processing' })} label={intl.formatMessage({ id: 'processing' }) + " (" + submittedCount + ")"} value="1" />
  183. <Tab aria-label={intl.formatMessage({ id: 'pendingPayment' })} label={intl.formatMessage({ id: 'pendingPayment' }) + " (" + pendingPaymentCount + ")"} value="3" />
  184. <Tab aria-label={intl.formatMessage({ id: 'pendingPublish' })} label={intl.formatMessage({ id: 'pendingPublish' }) + " (" + pendingPublishCount + ")"} value="4" />
  185. <Tab aria-label={intl.formatMessage({ id: 'searchApplyRecord' })} label={intl.formatMessage({ id: 'searchApplyRecord' })} value="5" />
  186. </TabList>
  187. </Box>
  188. <TabPanel value="1">
  189. <BaseGrid
  190. url={GET_PUBLIC_NOTICE_LIST_ListByStatus_submitted}
  191. setCount={setSubmittedCount}
  192. />
  193. </TabPanel>
  194. <TabPanel value="3">
  195. <PendingPaymentTab
  196. url={GET_PUBLIC_NOTICE_LIST_ListByStatus_pendingPayment}
  197. setCount={setPendingPaymentCount}
  198. />
  199. </TabPanel>
  200. <TabPanel value="4">
  201. <BaseGrid
  202. url={GET_PUBLIC_NOTICE_LIST_ListByStatus_pendingPublish}
  203. setCount={setPendingPublishCount}
  204. />
  205. </TabPanel>
  206. <TabPanel value="5">
  207. <SearchTab />
  208. </TabPanel>
  209. </TabContext>
  210. </Grid>
  211. )
  212. }
  213. <BrStatusDialog
  214. open={brDialog.open}
  215. variant={brDialog.variant}
  216. expiryDate={orgBrData?.brExpiryDate}
  217. onClose={() => {
  218. const afterClose = brDialog.afterClose;
  219. setBrDialog({ open: false, variant: null, afterClose: null });
  220. if (afterClose === "apply") {
  221. navigate("/publicNotice/apply");
  222. }
  223. }}
  224. />
  225. </Grid>
  226. );
  227. };
  228. export default PublicNotice;