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.

125 lines
4.6 KiB

  1. // material-ui
  2. import {
  3. Button,
  4. CardContent,
  5. Grid, TextField,
  6. Typography
  7. } from '@mui/material';
  8. import MainCard from "../../components/MainCard";
  9. import { useForm } from "react-hook-form";
  10. import * as React from "react";
  11. import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline';
  12. import { useNavigate } from "react-router";
  13. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  14. const UserGroupSearchForm = ({ applySearch }) => {
  15. const navigate = useNavigate();
  16. const { reset, register, handleSubmit } = useForm()
  17. const onSubmit = (data) => {
  18. applySearch(data);
  19. };
  20. function resetForm() {
  21. reset();
  22. }
  23. const handleNewGroupClick = (id) => {
  24. // console.log(id)
  25. navigate('/userGroup/' + id);
  26. };
  27. return (
  28. <MainCard xs={12} md={12} lg={12}
  29. border={false}
  30. content={false}
  31. >
  32. <form onSubmit={handleSubmit(onSubmit)}>
  33. {/*row 1*/}
  34. <CardContent sx={{ px: 2.5, pt: 3 }}>
  35. <Grid item justifyContent="space-between" alignItems="center">
  36. <Typography variant="h4">Search Form</Typography>
  37. </Grid>
  38. </CardContent>
  39. {/*row 2*/}
  40. <Grid container alignItems={"center"}>
  41. <Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}>
  42. <TextField
  43. fullWidth
  44. {...register("name")}
  45. id='userGroupName'
  46. label="User Group Name"
  47. InputLabelProps={{
  48. shrink: true
  49. }}
  50. />
  51. </Grid>
  52. <Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}>
  53. <TextField
  54. fullWidth
  55. {...register("description")}
  56. id="userGroupDescription"
  57. label="User Group Description"
  58. InputLabelProps={{
  59. shrink: true
  60. }}
  61. />
  62. </Grid>
  63. </Grid>
  64. {/*last row*/}
  65. <Grid container direction="row"
  66. justifyContent="space-between"
  67. alignItems="center"
  68. sx={{ mt: 3 }}
  69. >
  70. <Grid item xs={3} md={3} sx={{ ml: 3, mr: 1 }}>
  71. <Button
  72. variant="contained"
  73. onClick={handleNewGroupClick}
  74. startIcon={<AddCircleOutlineIcon sx={{alignItems:"center"}}/>}
  75. >
  76. <Typography variant="h5">New Group</Typography>
  77. </Button>
  78. </Grid>
  79. <Grid item xs={8} md={8} sx={{ ml: 3, mr: 3 }}>
  80. <Grid container maxWidth justifyContent="flex-end">
  81. <Grid item sx={{ ml: 3, mr: 3 }}>
  82. <Button
  83. size="large"
  84. variant="contained"
  85. onClick={resetForm}
  86. sx={{
  87. textTransform: 'capitalize',
  88. alignItems: 'end'
  89. }}>
  90. <Typography variant="h5">Clear</Typography>
  91. </Button>
  92. </Grid>
  93. <Grid item sx={{ ml: 3, mr: 3 }}>
  94. <Button
  95. size="large"
  96. variant="contained"
  97. type="submit"
  98. sx={{
  99. textTransform: 'capitalize',
  100. alignItems: 'end'
  101. }}>
  102. <Typography variant="h5">Search</Typography>
  103. </Button>
  104. </Grid>
  105. </Grid>
  106. </Grid>
  107. </Grid>
  108. </form>
  109. </MainCard>
  110. );
  111. };
  112. export default UserGroupSearchForm;