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.

122 lines
4.2 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 HttpUtils from "utils/HttpUtils";
  10. import * as DateUtils from "utils/DateUtils";
  11. import {GET_ISSUE_COMBO} from "utils/ApiPathConst";
  12. import { getSearchCriteria } from "auth/utils";
  13. import Loadable from 'components/Loadable';
  14. const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/LoadingComponent')));
  15. const SearchForm = Loadable(React.lazy(() => import('./SearchForm')));
  16. const EventTable = Loadable(React.lazy(() => import('./DataGrid')));
  17. import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png'
  18. const BackgroundHead = {
  19. backgroundImage: `url(${titleBackgroundImg})`,
  20. width: '100%',
  21. height: '100%',
  22. backgroundSize: 'contain',
  23. backgroundRepeat: 'no-repeat',
  24. backgroundColor: '#0C489E',
  25. backgroundPosition: 'right'
  26. }
  27. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  28. const UserSearchPage_Individual = () => {
  29. const [issueCombo, setIssueCombo] = React.useState([]);
  30. const [searchCriteria, setSearchCriteria] = React.useState({});
  31. const [onReady, setOnReady] = React.useState(false);
  32. const [onGridReady, setGridOnReady] = React.useState(false);
  33. React.useEffect(() => {
  34. getIssueCombo();
  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. setOnReady(true);
  47. }, [searchCriteria]);
  48. function getIssueCombo() {
  49. HttpUtils.get({
  50. url: GET_ISSUE_COMBO,
  51. onSuccess: function (responseData) {
  52. let combo = responseData;
  53. setIssueCombo(combo);
  54. }
  55. });
  56. }
  57. function applySearch(input) {
  58. setGridOnReady(true)
  59. setSearchCriteria(input);
  60. localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input}))
  61. }
  62. function applyGridOnReady(input) {
  63. setGridOnReady(input);
  64. }
  65. return (
  66. !onReady ?
  67. <Grid container sx={{ minHeight: '87vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center">
  68. <Grid item>
  69. <LoadingComponent />
  70. </Grid>
  71. </Grid>
  72. :
  73. <Grid container sx={{ minHeight: '87vh', backgroundColor: 'backgroundColor.default' }} direction="column">
  74. <Grid item xs={12}>
  75. <div style={BackgroundHead}>
  76. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  77. <Typography ml={15} color='#FFF' variant="h4" sx={{ "textShadow": "0px 0px 25px #0C489E" }}>Proof</Typography>
  78. </Stack>
  79. </div>
  80. </Grid>
  81. {/*row 1*/}
  82. <Grid item xs={12} md={12} lg={12} sx={{mb:-1}}>
  83. <SearchForm
  84. applySearch={applySearch}
  85. issueComboData={issueCombo}
  86. searchCriteria={searchCriteria}
  87. onGridReady={onGridReady}
  88. />
  89. </Grid>
  90. {/*row 2*/}
  91. <Grid item xs={12} md={12} lg={12}>
  92. <MainCard elevation={0}
  93. border={false}
  94. content={false}
  95. sx={{backgroundColor:"#fff"}}
  96. >
  97. <EventTable
  98. searchCriteria={searchCriteria}
  99. applyGridOnReady={applyGridOnReady}
  100. applySearch={applySearch}
  101. />
  102. </MainCard>
  103. </Grid>
  104. </Grid>
  105. );
  106. };
  107. export default UserSearchPage_Individual;