|
- // material-ui
- import {
- Button,
- CardContent,
- Grid, TextField,
- Typography
- } from '@mui/material';
- import MainCard from "../../components/MainCard";
- import { useForm } from "react-hook-form";
- import * as React from "react";
- import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline';
- import { useNavigate } from "react-router";
-
- // ==============================|| DASHBOARD - DEFAULT ||============================== //
-
- const UserGroupSearchForm = ({ applySearch }) => {
- const navigate = useNavigate();
-
- const { reset, register, handleSubmit } = useForm()
- const onSubmit = (data) => {
- applySearch(data);
- };
-
- function resetForm() {
- reset();
- }
-
- const handleNewGroupClick = (id) => {
- // console.log(id)
- navigate('/userGroup/' + id);
- };
-
- return (
- <MainCard xs={12} md={12} lg={12}
- border={false}
- content={false}
- >
-
- <form onSubmit={handleSubmit(onSubmit)}>
- {/*row 1*/}
- <CardContent sx={{ px: 2.5, pt: 3 }}>
- <Grid item justifyContent="space-between" alignItems="center">
- <Typography variant="h4">Search Form</Typography>
- </Grid>
- </CardContent>
-
- {/*row 2*/}
- <Grid container alignItems={"center"}>
- <Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <TextField
- fullWidth
- {...register("name")}
- id='userGroupName'
- label="User Group Name"
- InputLabelProps={{
- shrink: true
- }}
- />
- </Grid>
-
- <Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}>
- <TextField
- fullWidth
- {...register("description")}
- id="userGroupDescription"
- label="User Group Description"
- InputLabelProps={{
- shrink: true
- }}
- />
- </Grid>
- </Grid>
-
- {/*last row*/}
- <Grid container direction="row"
- justifyContent="space-between"
- alignItems="center"
- sx={{ mt: 3 }}
- >
- <Grid item xs={3} md={3} sx={{ ml: 3, mr: 1 }}>
- <Button
- variant="contained"
- onClick={handleNewGroupClick}
- startIcon={<AddCircleOutlineIcon sx={{alignItems:"center"}}/>}
- >
- <Typography variant="h5">New Group</Typography>
- </Button>
- </Grid>
- <Grid item xs={8} md={8} sx={{ ml: 3, mr: 3 }}>
- <Grid container maxWidth justifyContent="flex-end">
- <Grid item sx={{ ml: 3, mr: 3 }}>
- <Button
- size="large"
- variant="contained"
- onClick={resetForm}
- sx={{
- textTransform: 'capitalize',
- alignItems: 'end'
- }}>
- <Typography variant="h5">Clear</Typography>
- </Button>
- </Grid>
-
- <Grid item sx={{ ml: 3, mr: 3 }}>
- <Button
- size="large"
- variant="contained"
- type="submit"
- sx={{
- textTransform: 'capitalize',
- alignItems: 'end'
- }}>
- <Typography variant="h5">Search</Typography>
- </Button>
- </Grid>
- </Grid>
- </Grid>
- </Grid>
- </form>
- </MainCard>
- );
- };
-
- export default UserGroupSearchForm;
|