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.
 
 

106 line
3.6 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. // Typography,
  5. Tab,
  6. Box,
  7. // Button
  8. } from '@mui/material';
  9. import { TabPanel, TabContext, TabList } from '@mui/lab';
  10. import * as React from "react";
  11. import Loadable from 'components/Loadable';
  12. import { lazy } from 'react';
  13. const BaseGrid = Loadable(lazy(() => import('./BaseGrid')));
  14. const StatusHistoryTab = Loadable(lazy(() => import('./StatusHistoryTab')));
  15. const LoadingComponent = Loadable(lazy(() => import('../../../extra-pages/LoadingComponent')));
  16. const ProofTab = Loadable(lazy(() => import('./ProofTab')));
  17. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  18. const PublicNotice = ({applicationDetailData, proofList}) => {
  19. const [_proofList, setProofList] = React.useState([]);
  20. const [inProgressList,] = React.useState([]);
  21. const [onReady,setOnReady] = React.useState(false);
  22. const [selectedTab, setSelectedTab] = React.useState("1");
  23. // const navigate = useNavigate();
  24. const [statusHistoryList, setStatusHistoryList] = React.useState([]);
  25. const reloadPage = () => {
  26. window.location.reload(false);
  27. }
  28. React.useEffect(() => {
  29. if (Object.keys(applicationDetailData).length > 0) {
  30. setStatusHistoryList(applicationDetailData.statusHistoryList);
  31. }
  32. }, [applicationDetailData]);
  33. React.useEffect(() => {
  34. setProofList(proofList);
  35. }, [proofList]);
  36. React.useEffect(() => {
  37. //if state data are ready and assign to different field
  38. if (statusHistoryList.length > 0) {
  39. setOnReady(true);
  40. }
  41. }, [statusHistoryList]);
  42. // useEffect(() => {
  43. // setLoding(false);
  44. // }, [submittedList]);
  45. const handleChange = (event, newValue) => {
  46. setSelectedTab(newValue);
  47. }
  48. // const onBtnClick = () => {
  49. // navigate('/publicNotice/apply')
  50. // }
  51. return (
  52. !onReady ?
  53. <LoadingComponent />
  54. :
  55. <Grid container sx={{minHeight: '40vh'}}>
  56. {/*col 2*/}
  57. <Grid item xs={12}>
  58. <TabContext value={selectedTab}>
  59. <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
  60. <TabList onChange={handleChange} aria-label="lab API tabs example">
  61. <Tab label={"Proof(" + (_proofList?.length?_proofList?.length:0) + ")"} value="1" />
  62. <Tab label={"Payment(" + inProgressList.length + ")"} value="2" />
  63. <Tab label={"Status History(" + statusHistoryList.length + ")"} value="3" />
  64. </TabList>
  65. </Box>
  66. <TabPanel value="1">
  67. <ProofTab
  68. rows={_proofList}
  69. reloadFunction={reloadPage}
  70. />
  71. </TabPanel>
  72. <TabPanel value="2">
  73. <BaseGrid
  74. rows={inProgressList}
  75. reloadFunction={reloadPage}
  76. />
  77. </TabPanel>
  78. <TabPanel value="3">
  79. <StatusHistoryTab
  80. rows={statusHistoryList}
  81. reloadFunction={reloadPage}
  82. />
  83. </TabPanel>
  84. </TabContext>
  85. </Grid>
  86. </Grid>
  87. );
  88. };
  89. export default PublicNotice;