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.
 
 

86 line
2.7 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. import {useIntl} from "react-intl";
  14. const LoadingComponent = Loadable(lazy(() => import('pages/extra-pages/LoadingComponent')));
  15. const ProofTab = Loadable(lazy(() => import('./ProofTab')));
  16. const PaymentTab = Loadable(lazy(() => import('./PaymentTab')));
  17. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  18. const PublicNotice = ({ proofList, paymentList }) => {
  19. const [_proofList, setProofList] = React.useState([]);
  20. const [_paymentList, setPaymentList] = React.useState([]);
  21. const [onReady, setOnReady] = React.useState(false);
  22. const [selectedTab, setSelectedTab] = React.useState("1");
  23. const intl = useIntl();
  24. const reloadPage = () => {
  25. window.location.reload(false);
  26. }
  27. React.useEffect(() => {
  28. setProofList(proofList);
  29. setOnReady(true);
  30. }, [proofList]);
  31. React.useEffect(() => {
  32. setPaymentList(paymentList);
  33. }, [paymentList]);
  34. const handleChange = (event, newValue) => {
  35. setSelectedTab(newValue);
  36. }
  37. return (
  38. !onReady ?
  39. <LoadingComponent />
  40. :
  41. <Grid container>
  42. {/*col 2*/}
  43. <Grid item xs={12}>
  44. <TabContext value={selectedTab}>
  45. <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
  46. <TabList onChange={handleChange} aria-label="lab API tabs example">
  47. <Tab label={
  48. intl.formatMessage({id: 'proofRecord'}) + "(" + _proofList.length + ") "} value="1"
  49. />
  50. <Tab label={ intl.formatMessage({id: 'paymentHistory'}) +"(" + _paymentList.length + ") "} value="2" />
  51. </TabList>
  52. </Box>
  53. <TabPanel value="1">
  54. <ProofTab
  55. rows={_proofList}
  56. reloadFunction={reloadPage}
  57. />
  58. </TabPanel>
  59. <TabPanel value="2">
  60. <PaymentTab
  61. rows={_paymentList}
  62. reloadFunction={reloadPage}
  63. />
  64. </TabPanel>
  65. </TabContext>
  66. </Grid>
  67. </Grid>
  68. );
  69. };
  70. export default PublicNotice;