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.
 
 

161 line
5.5 KiB

  1. // material-ui
  2. import {
  3. Button,
  4. CardContent,
  5. Grid, TextField,
  6. Autocomplete
  7. } from '@mui/material';
  8. import MainCard from "../../components/MainCard";
  9. import {useForm} from "react-hook-form";
  10. import { useState} from "react";
  11. import * as React from "react";
  12. // ==============================|| DASHBOARD - DEFAULT ||============================== //
  13. const UserSearchForm_Individual = ({applySearch}) => {
  14. const [type, setType] = useState([]);
  15. const [accountFilter, setAccountFilter] = useState("Active");
  16. const { reset, register, handleSubmit } = useForm()
  17. const onSubmit = (data) => {
  18. let typeArray = [];
  19. for(let i =0; i < type.length; i++){
  20. typeArray.push(type[i].label);
  21. }
  22. const temp = {
  23. username: data.userName,
  24. fullenName: data.fullenName,
  25. email: data.email,
  26. phone: data.phone,
  27. accountFilter: accountFilter,
  28. };
  29. applySearch(temp);
  30. };
  31. function resetForm(){
  32. setType([]);
  33. reset();
  34. }
  35. return (
  36. <MainCard xs={12} md={12} lg={12}
  37. border={false}
  38. content={false}>
  39. <form onSubmit={handleSubmit(onSubmit)}>
  40. {/*row 1*/}
  41. <CardContent sx={{ px: 2.5, pt: 3 }}>
  42. <Grid item justifyContent="space-between" alignItems="center">
  43. Search Form
  44. </Grid>
  45. </CardContent>
  46. {/*row 2*/}
  47. <Grid container alignItems={"center"}>
  48. <Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>
  49. <TextField
  50. fullWidth
  51. {...register("userName")}
  52. id='userName'
  53. label="Username"
  54. />
  55. </Grid>
  56. <Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>
  57. <TextField
  58. fullWidth
  59. {...register("fullenName")}
  60. id="fullenName"
  61. label="Full Name"
  62. />
  63. </Grid>
  64. <Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>
  65. <TextField
  66. fullWidth
  67. {...register("email")}
  68. id="email"
  69. label="Email"
  70. />
  71. </Grid>
  72. <Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>
  73. <TextField
  74. fullWidth
  75. {...register("phone")}
  76. id="phone"
  77. label="Phone"
  78. />
  79. </Grid>
  80. <Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>
  81. <Autocomplete
  82. {...register("accountFilter")}
  83. disablePortal
  84. id="accountFilter"
  85. options={["Active","Locked","Not verified"]}
  86. value={accountFilter}
  87. onChange={(event, newValue) => {
  88. if (newValue !== null){
  89. setAccountFilter(newValue);
  90. }
  91. }}
  92. renderInput={(params) => (
  93. <TextField {...params}
  94. label="Status"
  95. />
  96. )}
  97. />
  98. </Grid>
  99. {/*<Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>*/}
  100. {/* <TextField*/}
  101. {/* fullWidth*/}
  102. {/* {...register("subDivisionId")}*/}
  103. {/* id="subDivision"*/}
  104. {/* label="Sub-Division"*/}
  105. {/* />*/}
  106. {/*</Grid>*/}
  107. </Grid>
  108. {/*last row*/}
  109. <Grid container maxWidth justifyContent="flex-end">
  110. <Grid item sx={{ml:3, mr:3, mb:3, mt:3}}>
  111. <Button
  112. size="large"
  113. variant="contained"
  114. onClick={resetForm}
  115. sx={{
  116. textTransform: 'capitalize',
  117. alignItems: 'end'
  118. }}>
  119. Clear
  120. </Button>
  121. </Grid>
  122. <Grid item sx={{ml:3, mr:3, mb:3, mt:3}}>
  123. <Button
  124. size="large"
  125. variant="contained"
  126. type="submit"
  127. sx={{
  128. textTransform: 'capitalize',
  129. alignItems: 'end'
  130. }}>
  131. Submit
  132. </Button>
  133. </Grid>
  134. </Grid>
  135. </form>
  136. </MainCard>
  137. );
  138. };
  139. export default UserSearchForm_Individual;