Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

109 рядки
3.5 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. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  23. const UserGroupSearchPanel = () => {
  24. const [record, setRecord] = useState([]);
  25. const [searchCriteria, setSearchCriteria] = useState({});
  26. const [onReady, setOnReady] = useState(false);
  27. useEffect(() => {
  28. getGroupList();
  29. }, []);
  30. useEffect(() => {
  31. setOnReady(true);
  32. }, [record]);
  33. useEffect(() => {
  34. getGroupList();
  35. }, [searchCriteria]);
  36. function getGroupList() {
  37. axios.get(`${apiPath}${GET_GROUP_LIST_PATH}`,
  38. {params: searchCriteria}
  39. )
  40. .then((response) => {
  41. if (response.status === 200) {
  42. setRecord(response.data.records);
  43. }
  44. })
  45. .catch(error => {
  46. console.log(error);
  47. return false;
  48. });
  49. }
  50. function applySearch(input) {
  51. setSearchCriteria(input);
  52. }
  53. return (
  54. !onReady ?
  55. <LoadingComponent/>
  56. :
  57. <Grid container sx={{minHeight: '90vh', paddingTop: '53px'}}>
  58. <Grid item xs={12} md={12} lg={12}>
  59. <Grid container justifyContent="flex-start" alignItems="center">
  60. <Grid item xs={12} height='50px'>
  61. <Stack direction="row" height='100%' justifyContent="flex-start" alignItems="center">
  62. <Typography ml={2} align="center" variant="h5">View User Group</Typography>
  63. </Stack>
  64. </Grid>
  65. {/* <Grid item xs={1} sx={{ml: 3, mr: 3}}>
  66. <Button
  67. size="large"
  68. variant="contained"
  69. type="submit"
  70. >
  71. Create
  72. </Button>
  73. </Grid> */}
  74. </Grid>
  75. </Grid>
  76. {/*row 1*/}
  77. <Grid item xs={12} md={12} lg={12}>
  78. <UserGroupSearchForm applySearch={applySearch}/>
  79. </Grid>
  80. {/*row 2*/}
  81. <Grid item xs={12} md={12} lg={12}>
  82. <MainCard elevation={0}
  83. border={false}
  84. content={false}
  85. >
  86. <UserGroupTable
  87. recordList={record}
  88. />
  89. </MainCard>
  90. </Grid>
  91. </Grid>
  92. );
  93. };
  94. export default UserGroupSearchPanel;