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

109 рядки
3.4 KiB

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