Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

112 righe
4.0 KiB

  1. // material-ui
  2. import {
  3. Grid,
  4. Typography,
  5. Stack
  6. } from '@mui/material';
  7. import MainCard from "components/MainCard";
  8. import * as React from "react";
  9. import * as DateUtils from "utils/DateUtils";
  10. import Loadable from 'components/Loadable';
  11. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  12. const SearchForm = Loadable(React.lazy(() => import('./SearchForm')));
  13. const EventTable = Loadable(React.lazy(() => import('./DataGrid')));
  14. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  15. import {FormattedMessage} from "react-intl";
  16. import { getSearchCriteria } from "auth/utils";
  17. const BackgroundHead = {
  18. backgroundImage: `url(${titleBackgroundImg})`,
  19. width: '100%',
  20. height: '100%',
  21. backgroundSize:'contain',
  22. backgroundRepeat: 'no-repeat',
  23. backgroundColor: '#0C489E',
  24. backgroundPosition: 'right'
  25. }
  26. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  27. const Index = () => {
  28. const [searchCriteria, setSearchCriteria] = React.useState({
  29. dateTo: DateUtils.dateValue(new Date()),
  30. dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate()-14)),
  31. });
  32. const [onReady, setOnReady] = React.useState(false);
  33. const [onGridReady, setGridOnReady] = React.useState(false);
  34. React.useEffect(() => {
  35. if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){
  36. setSearchCriteria(getSearchCriteria(window.location.pathname))
  37. }else{
  38. localStorage.setItem('searchCriteria',"")
  39. setSearchCriteria({
  40. dateTo: DateUtils.dateValue(new Date()),
  41. dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate()-14)),
  42. })
  43. }
  44. }, []);
  45. React.useEffect(() => {
  46. if(Object.keys(searchCriteria).length>0){
  47. setOnReady(true);
  48. }
  49. }, [searchCriteria]);
  50. function applySearch(input) {
  51. setGridOnReady(true)
  52. setSearchCriteria(input);
  53. localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input}))
  54. }
  55. function applyGridOnReady(input) {
  56. setGridOnReady(input);
  57. }
  58. return (
  59. !onReady ?
  60. <Grid container sx={{ minHeight: '87vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center">
  61. <Grid item>
  62. <LoadingComponent />
  63. </Grid>
  64. </Grid>
  65. :
  66. <Grid container sx={{minHeight: '85vh',backgroundColor:'#ffffff'}} direction="column">
  67. <Grid item xs={12}>
  68. <div style={BackgroundHead}>
  69. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  70. <Typography ml={15} color='#FFF' variant="h4" sx={{display: { xs: 'none', sm: 'none', md: 'block' }}}>
  71. <FormattedMessage id="onlinePaymentHistory"/>
  72. </Typography>
  73. </Stack>
  74. </div>
  75. </Grid>
  76. {/*row 1*/}
  77. <Grid item xs={12} md={12} lg={12}>
  78. <SearchForm
  79. applySearch={applySearch}
  80. searchCriteria={searchCriteria}
  81. onGridReady={onGridReady}
  82. />
  83. </Grid>
  84. {/*row 2*/}
  85. <Grid item xs={12} md={12} lg={12}>
  86. <MainCard elevation={0}
  87. border={false}
  88. content={false}
  89. sx={{width: "-webkit-fill-available"}}
  90. >
  91. <EventTable
  92. searchCriteria={searchCriteria}
  93. applyGridOnReady={applyGridOnReady}
  94. applySearch={applySearch}
  95. />
  96. </MainCard>
  97. </Grid>
  98. </Grid>
  99. );
  100. };
  101. export default Index;