Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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