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.
 
 

127 line
4.8 KiB

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