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.
 
 

101 regels
3.2 KiB

  1. // material-ui
  2. import {
  3. // Box,
  4. Stack,
  5. // Button,
  6. Grid, Typography
  7. } from '@mui/material';
  8. import MainCard from "../../components/MainCard";
  9. import {useEffect, useState} from "react";
  10. import axios from "axios";
  11. import {apiPath} from "../../auth/utils";
  12. import {GET_GROUP_LIST_PATH} from "../../utils/ApiPathConst";
  13. import * as React from "react";
  14. //import LoadingComponent from "../extra-pages/LoadingComponent";
  15. // import UserGroupSearchForm from "./UserGroupSearchForm";
  16. // import UserGroupTable from "./UserGroupTable";
  17. import Loadable from 'components/Loadable';
  18. import { lazy } from 'react';
  19. const LoadingComponent = Loadable(lazy(() => import('../extra-pages/LoadingComponent')));
  20. const UserGroupSearchForm = Loadable(lazy(() => import('./UserGroupSearchForm')));
  21. const UserGroupTable = Loadable(lazy(() => import('./UserGroupTable')));
  22. // import {useNavigate} from "react-router";
  23. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  24. const UserGroupSearchPanel = () => {
  25. const [record, setRecord] = useState([]);
  26. const [searchCriteria, setSearchCriteria] = useState({});
  27. const [onReady, setOnReady] = useState(false);
  28. // const navigate = useNavigate();
  29. useEffect(() => {
  30. getGroupList();
  31. }, []);
  32. useEffect(() => {
  33. setOnReady(true);
  34. }, [record]);
  35. useEffect(() => {
  36. getGroupList();
  37. }, [searchCriteria]);
  38. function getGroupList() {
  39. axios.get(`${apiPath}${GET_GROUP_LIST_PATH}`,
  40. {params: searchCriteria}
  41. )
  42. .then((response) => {
  43. if (response.status === 200) {
  44. setRecord(response.data.records);
  45. }
  46. })
  47. .catch(error => {
  48. console.log(error);
  49. return false;
  50. });
  51. }
  52. function applySearch(input) {
  53. setSearchCriteria(input);
  54. }
  55. return (
  56. !onReady ?
  57. <LoadingComponent/>
  58. :
  59. <Grid container sx={{minHeight: '90vh', paddingTop: '53px'}}>
  60. <Grid item xs={12} md={12} lg={12}>
  61. <Grid direction="row" container justifyContent="flex-start" alignItems="center" ml={2}>
  62. <Grid item xs={2} height='50px'>
  63. <Stack direction="row" height='100%' justifyContent="space-between" alignItems="center">
  64. <Typography align="center" variant="h5">View User Group</Typography>
  65. </Stack>
  66. </Grid>
  67. </Grid>
  68. </Grid>
  69. {/*row 1*/}
  70. <Grid item xs={12} md={12} lg={12}>
  71. <UserGroupSearchForm applySearch={applySearch}/>
  72. </Grid>
  73. {/*row 2*/}
  74. <Grid item xs={12} md={12} lg={12}>
  75. <MainCard elevation={0}
  76. border={false}
  77. content={false}
  78. >
  79. <UserGroupTable
  80. recordList={record}
  81. />
  82. </MainCard>
  83. </Grid>
  84. </Grid>
  85. );
  86. };
  87. export default UserGroupSearchPanel;