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.7 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 Form
  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. sx={{ mb: 3 }}
  71. >
  72. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  73. <Grid item xs={3} md={3} sx={{ ml: 3}}>
  74. <Button
  75. variant="contained"
  76. onClick={handleNewGroupClick}
  77. startIcon={<AddCircleOutlineIcon sx={{alignItems:"center"}}/>}
  78. >
  79. New Group
  80. </Button>
  81. </Grid>
  82. <Grid item xs={8} md={8}>
  83. <Grid container maxWidth justifyContent="flex-end">
  84. <Grid item sx={{mr:3}}>
  85. <Button
  86. variant="contained"
  87. onClick={resetForm}
  88. >
  89. Clear
  90. </Button>
  91. </Grid>
  92. <Grid item >
  93. <Button
  94. variant="contained"
  95. type="submit"
  96. sx={{
  97. textTransform: 'capitalize',
  98. alignItems: 'end'
  99. }}>
  100. Search
  101. </Button>
  102. </Grid>
  103. </Grid>
  104. </Grid>
  105. </ThemeProvider>
  106. </Grid>
  107. </Grid>
  108. </form>
  109. </MainCard>
  110. );
  111. };
  112. export default UserGroupSearchForm;