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.
 
 

143 lines
5.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 UrlUtils from "utils/ApiPathConst";
  10. import * as HttpUtils from "utils/HttpUtils";
  11. import * as DateUtils from "utils/DateUtils";
  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 [orgCombo, setOrgCombo] = React.useState([]);
  30. const [issueCombo, setIssueCombo] = React.useState([]);
  31. const [searchCriteria, setSearchCriteria] = React.useState({
  32. // dateTo: DateUtils.dateValue(new Date()),
  33. // dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate() - 14)),
  34. // dueDateTo: DateUtils.dateValue(new Date()),
  35. // dueDateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate() - 14)),
  36. });
  37. const [onReady, setOnReady] = React.useState(false);
  38. const [onGridReady, setGridOnReady] = React.useState(false);
  39. React.useEffect(() => {
  40. getOrgCombo();
  41. getIssueCombo();
  42. if (Object.keys(getSearchCriteria(window.location.pathname)).length>0){
  43. setSearchCriteria(getSearchCriteria(window.location.pathname))
  44. }else{
  45. localStorage.setItem('searchCriteria',"")
  46. setSearchCriteria({
  47. dateTo: DateUtils.dateValue(new Date()),
  48. dateFrom: DateUtils.dateValue(new Date().setDate(new Date().getDate()-14)),
  49. })
  50. }
  51. }, []);
  52. React.useEffect(() => {
  53. setOnReady(true);
  54. }, [searchCriteria]);
  55. function getOrgCombo() {
  56. HttpUtils.get({
  57. url: UrlUtils.GET_ORG_COMBO,
  58. onSuccess: function (responseData) {
  59. let combo = responseData;
  60. setOrgCombo(combo);
  61. }
  62. });
  63. }
  64. function getIssueCombo() {
  65. HttpUtils.get({
  66. url: UrlUtils.GET_ISSUE_COMBO,
  67. onSuccess: function (responseData) {
  68. let combo = responseData;
  69. setIssueCombo(combo);
  70. }
  71. });
  72. }
  73. function applySearch(input) {
  74. setGridOnReady(true)
  75. setSearchCriteria(input);
  76. localStorage.setItem('searchCriteria', JSON.stringify({path:window.location.pathname,data:input}))
  77. }
  78. function applyGridOnReady(input) {
  79. setGridOnReady(input);
  80. }
  81. return (
  82. !onReady ?
  83. <Grid container sx={{ minHeight: '87vh', mb: 3 }} direction="column" justifyContent="center" alignItems="center">
  84. <Grid item>
  85. <LoadingComponent />
  86. </Grid>
  87. </Grid>
  88. :
  89. <Grid container sx={{ minHeight: '87vh', backgroundColor: 'backgroundColor.default' }} direction="column">
  90. <Grid item xs={12}>
  91. <div style={BackgroundHead}>
  92. <Stack direction="row" height='70px' justifyContent="flex-start" alignItems="center">
  93. <Typography ml={15} color='#FFF' variant="h4" sx={{ "textShadow": "0px 0px 25px #0C489E" }}>
  94. Demand Note
  95. </Typography>
  96. </Stack>
  97. </div>
  98. </Grid>
  99. {/*row 1*/}
  100. <Grid item xs={12} md={12} lg={12} sx={{mb: -1}}>
  101. <SearchForm
  102. applySearch={applySearch}
  103. orgComboData={orgCombo}
  104. issueComboData={issueCombo}
  105. searchCriteria={searchCriteria}
  106. onGridReady={onGridReady}
  107. />
  108. </Grid>
  109. {/*row 2*/}
  110. <Grid item xs={12} md={12} lg={12}>
  111. <MainCard elevation={0}
  112. border={false}
  113. content={false}
  114. sx={{ backgroundColor: '#fff' }}
  115. >
  116. <EventTable
  117. applySearch={applySearch}
  118. searchCriteria={searchCriteria}
  119. applyGridOnReady={applyGridOnReady}
  120. />
  121. </MainCard>
  122. </Grid>
  123. </Grid>
  124. );
  125. }
  126. export default UserSearchPage_Individual;