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.
 
 
 

98 rivejä
3.3 KiB

  1. // material-ui
  2. import {
  3. Box,
  4. Grid, Typography
  5. } from '@mui/material';
  6. import MainCard from "../../components/MainCard";
  7. import {useEffect, useState} from "react";
  8. import * as React from "react";
  9. import axios from "axios";
  10. import {apiPath} from "../../auth/utils";
  11. import {GET_APPRECIATION_CATEGORY_LIST} from "../../utils/ApiPathConst";
  12. import LoadingComponent from "../extra-pages/LoadingComponent";
  13. import {LIONER_FORM_THEME, CARD_MAX_WIDTH} from "../../themes/themeConst";
  14. import {ThemeProvider} from "@emotion/react";
  15. import AppreciationCategorySearchForm from "./AppreciationCategorySearchForm";
  16. import AppreciationCategoryTable from "./AppreciationCategoryTable";
  17. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  18. const AppreciationCategoryIndex = () => {
  19. const [record, setRecord] = useState([]);
  20. const [searchCriteria, setSearchCriteria] = useState({});
  21. const [onReady, setOnReady] = useState(false);
  22. useEffect(() => {
  23. getGroupList();
  24. }, []);
  25. useEffect(() => {
  26. setOnReady(true);
  27. }, [record]);
  28. useEffect(() => {
  29. getGroupList();
  30. }, [searchCriteria]);
  31. function getGroupList() {
  32. axios.get(`${apiPath}${GET_APPRECIATION_CATEGORY_LIST}`,
  33. {params: searchCriteria}
  34. )
  35. .then((response) => {
  36. if (response.status === 200) {
  37. if(response.data.records !== record){
  38. setRecord(response.data.records);
  39. }
  40. }
  41. })
  42. .catch(error => {
  43. console.log(error);
  44. return false;
  45. });
  46. }
  47. function applySearch(input) {
  48. setSearchCriteria(input);
  49. }
  50. return (
  51. !onReady ?
  52. <LoadingComponent/>
  53. :
  54. <Grid container rowSpacing={3} columnSpacing={2.75} sx={{marginTop: '0px'}}>
  55. <ThemeProvider theme={LIONER_FORM_THEME}>
  56. <Grid item xs={12} md={12} lg={12}>
  57. <Grid container justifyContent="flex-start" alignItems="center" >
  58. <Grid item xs={3} sx={{mt:-2.25, mb: -2.25}} >
  59. <Box sx={{ display: 'flex', alignItems: 'center'}}>
  60. <Typography align="center" variant="h5" >View Appreciation Category</Typography>
  61. </Box>
  62. </Grid>
  63. </Grid>
  64. </Grid>
  65. {/*row 1*/}
  66. <Grid item xs={12} md={12} lg={12}>
  67. <AppreciationCategorySearchForm applySearch={applySearch}/>
  68. </Grid>
  69. {/*row 2*/}
  70. <Grid item xs={12} md={12} lg={12} sx={{mt:{lg:-1.5}}}>
  71. <MainCard elevation={0}
  72. content={false}
  73. sx={{width:CARD_MAX_WIDTH}}
  74. >
  75. <AppreciationCategoryTable
  76. recordList={record}
  77. />
  78. </MainCard>
  79. </Grid>
  80. </ThemeProvider>
  81. </Grid>
  82. );
  83. };
  84. export default AppreciationCategoryIndex;