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.
 
 

214 line
10 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. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  33. const PublicNotice = () => {
  34. usePageTitle("myPublicNotice");
  35. const [submittedCount, setSubmittedCount] = useState(0);
  36. const [pendingPaymentCount, setPendingPaymentCount] = useState(0);
  37. const [pendingPublishCount, setPendingPublishCount] = useState(0);
  38. const [isLoading, setLoding] = useState(true);
  39. const [selectedTab, setSelectedTab] = useState("1");
  40. const navigate = useNavigate();
  41. const intl = useIntl();
  42. const _sx = {
  43. padding: "4 2 4 2",
  44. boxShadow: 1,
  45. border: 1,
  46. borderColor: '#DDD',
  47. '& .MuiDataGrid-cell': {
  48. borderTop: 1,
  49. borderBottom: 1,
  50. borderColor: "#EEE"
  51. },
  52. '& .MuiDataGrid-footerContainer': {
  53. border: 1,
  54. borderColor: "#EEE"
  55. },
  56. '& .MuiTabPanel-root': {
  57. padding: '0px',
  58. }
  59. }
  60. const BackgroundHead = {
  61. backgroundImage: `url(${titleBackgroundImg})`,
  62. width: '100%',
  63. height: '100%',
  64. backgroundSize: 'contain',
  65. backgroundRepeat: 'no-repeat',
  66. backgroundColor: '#0C489E',
  67. backgroundPosition: 'right'
  68. }
  69. useEffect(() => {
  70. loadData();
  71. }, []);
  72. const loadData = () => {
  73. setLoding(true);
  74. HttpUtils.get({
  75. url: GET_PUBLIC_NOTICE_LIST_ListByStatus,
  76. onSuccess: function (response) {
  77. setSubmittedCount(response.submitted ?? 0);
  78. setPendingPaymentCount(response.pendingPayment ?? 0);
  79. setPendingPublishCount(response.pendingPublish ?? 0);
  80. }
  81. });
  82. };
  83. useEffect(() => {
  84. setLoding(false);
  85. }, [submittedCount]);
  86. const handleChange = (event, newValue) => {
  87. setSelectedTab(newValue);
  88. }
  89. const onBtnClick = () => {
  90. navigate('/publicNotice/apply')
  91. }
  92. return (
  93. isLoading ?
  94. <Grid container sx={{ minHeight: '87vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center">
  95. <Grid item>
  96. <LoadingComponent />
  97. </Grid>
  98. </Grid>
  99. :
  100. <Grid container sx={{ minHeight: '87vh', backgroundColor: 'backgroundColor.default' }} direction="column">
  101. <Grid item xs={12}>
  102. <div style={BackgroundHead}>
  103. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  104. <Typography ml={15} color='#FFF' variant="h4" sx={{ display: { xs: 'none', sm: 'none', md: 'block' } }}>
  105. <FormattedMessage id="myPublicNotice" />
  106. </Typography>
  107. </Stack>
  108. </div>
  109. </Grid>
  110. <Grid item xs={12} sm={12} md={12} lg={12} mt={1} sx={{ mt: 3, mr: { xs: 3, sm: 3, md: 0 } }} >
  111. <Stack direction="row" justifyContent="flex-end" alignItems="center">
  112. <ThemeProvider theme={PNSPS_LONG_BUTTON_THEME}>
  113. <Box sx={{ mr: { md: "47px" } }}>
  114. <Button aria-label={intl.formatMessage({ id: 'applyPublicNotice' })} variant="contained" onClick={() => { onBtnClick() }}>
  115. <FormattedMessage id="applyPublicNotice" />
  116. </Button>
  117. </Box>
  118. </ThemeProvider>
  119. </Stack>
  120. </Grid>
  121. {/*col 2*/}
  122. {
  123. JSON.parse(localStorage.getItem('userData')).creditor ? (
  124. <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 }}>
  125. <TabContext value={selectedTab}>
  126. <Box sx={{ borderBottom: 1, borderColor: 'divider', overflowX: 'auto', overflowY: 'auto' }}>
  127. <TabList variant="scrollable" onChange={handleChange} aria-label="lab API tabs example" sx={{ display: 'flex', flexDirection: 'row' }}>
  128. <Tab aria-label={intl.formatMessage({ id: 'processing' })} label={intl.formatMessage({ id: 'processing' }) + " (" + submittedCount + ")"} value="1" />
  129. <Tab aria-label={intl.formatMessage({ id: 'pendingPublish' })} label={intl.formatMessage({ id: 'pendingPublish' }) + " (" + pendingPublishCount + ")"} value="3" />
  130. <Tab aria-label={intl.formatMessage({ id: 'pendingPayment' })} label={intl.formatMessage({ id: 'pendingPayment' }) + " (" + pendingPaymentCount + ")"} value="4" />
  131. <Tab aria-label={intl.formatMessage({ id: 'searchApplyRecord' })} label={intl.formatMessage({ id: 'searchApplyRecord' })} value="5" />
  132. </TabList>
  133. </Box>
  134. <TabPanel value="1">
  135. <BaseGrid
  136. url={GET_PUBLIC_NOTICE_LIST_ListByStatus_submitted}
  137. setCount={setSubmittedCount}
  138. />
  139. </TabPanel>
  140. <TabPanel value="3">
  141. <BaseGrid
  142. url={GET_PUBLIC_NOTICE_LIST_ListByStatus_pendingPublish}
  143. setCount={setPendingPublishCount}
  144. />
  145. </TabPanel>
  146. <TabPanel value="4">
  147. <BaseGrid
  148. url={GET_PUBLIC_NOTICE_LIST_ListByStatus_pendingPayment}
  149. setCount={setPendingPaymentCount}
  150. />
  151. </TabPanel>
  152. <TabPanel value="5">
  153. <SearchTab />
  154. </TabPanel>
  155. </TabContext>
  156. </Grid>
  157. ) : (
  158. <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 }}>
  159. <TabContext value={selectedTab}>
  160. <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
  161. <TabList variant="scrollable" onChange={handleChange} aria-label="lab API tabs example">
  162. <Tab aria-label={intl.formatMessage({ id: 'processing' })} label={intl.formatMessage({ id: 'processing' }) + " (" + submittedCount + ")"} value="1" />
  163. <Tab aria-label={intl.formatMessage({ id: 'pendingPayment' })} label={intl.formatMessage({ id: 'pendingPayment' }) + " (" + pendingPaymentCount + ")"} value="3" />
  164. <Tab aria-label={intl.formatMessage({ id: 'pendingPublish' })} label={intl.formatMessage({ id: 'pendingPublish' }) + " (" + pendingPublishCount + ")"} value="4" />
  165. <Tab aria-label={intl.formatMessage({ id: 'searchApplyRecord' })} label={intl.formatMessage({ id: 'searchApplyRecord' })} value="5" />
  166. </TabList>
  167. </Box>
  168. <TabPanel value="1">
  169. <BaseGrid
  170. url={GET_PUBLIC_NOTICE_LIST_ListByStatus_submitted}
  171. setCount={setSubmittedCount}
  172. />
  173. </TabPanel>
  174. <TabPanel value="3">
  175. <PendingPaymentTab
  176. url={GET_PUBLIC_NOTICE_LIST_ListByStatus_pendingPayment}
  177. setCount={setPendingPaymentCount}
  178. />
  179. </TabPanel>
  180. <TabPanel value="4">
  181. <BaseGrid
  182. url={GET_PUBLIC_NOTICE_LIST_ListByStatus_pendingPublish}
  183. setCount={setPendingPublishCount}
  184. />
  185. </TabPanel>
  186. <TabPanel value="5">
  187. <SearchTab />
  188. </TabPanel>
  189. </TabContext>
  190. </Grid>
  191. )
  192. }
  193. </Grid>
  194. );
  195. };
  196. export default PublicNotice;