Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

206 wiersze
7.4 KiB

  1. // material-ui
  2. import {
  3. Button,
  4. CardContent, Autocomplete,
  5. Grid, TextField,
  6. Typography
  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_Organization = ({applySearch}) => {
  14. const [type, setType] = useState([]);
  15. const [accountFilter, setAccountFilter] = useState("All");
  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. brNoStr: data.brNoStr,
  28. orgName: data.orgName,
  29. accountFilter: accountFilter=="All"?null:accountFilter,
  30. };
  31. applySearch(temp);
  32. };
  33. function resetForm(){
  34. setType([]);
  35. setAccountFilter("All");
  36. reset();
  37. }
  38. return (
  39. <MainCard xs={12} md={12} lg={12}
  40. border={false}
  41. content={false}>
  42. <form onSubmit={handleSubmit(onSubmit)}>
  43. {/*row 1*/}
  44. <CardContent sx={{ px: 2.5, pt: 3 }}>
  45. <Grid item justifyContent="space-between" alignItems="center">
  46. <Typography variant="h5">Search Form</Typography>
  47. </Grid>
  48. </CardContent>
  49. {/*row 2*/}
  50. <Grid container alignItems={"center"}>
  51. <Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>
  52. <TextField
  53. fullWidth
  54. {...register("orgName")}
  55. id="orgName"
  56. label="Org Name"
  57. InputLabelProps={{
  58. shrink: true
  59. }}
  60. />
  61. </Grid>
  62. <Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>
  63. <TextField
  64. fullWidth
  65. {...register("brNoStr")}
  66. id="brNoStr"
  67. label="BR No."
  68. InputLabelProps={{
  69. shrink: true
  70. }}
  71. />
  72. </Grid>
  73. <Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>
  74. <TextField
  75. fullWidth
  76. {...register("userName")}
  77. id='userName'
  78. label="Username"
  79. InputLabelProps={{
  80. shrink: true
  81. }}
  82. />
  83. </Grid>
  84. <Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>
  85. <TextField
  86. fullWidth
  87. {...register("contactPerson")}
  88. id="contactPerson"
  89. label="Name"
  90. InputLabelProps={{
  91. shrink: true
  92. }}
  93. />
  94. </Grid>
  95. <Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>
  96. <TextField
  97. fullWidth
  98. {...register("email")}
  99. id="email"
  100. label="Email"
  101. InputLabelProps={{
  102. shrink: true
  103. }}
  104. />
  105. </Grid>
  106. <Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>
  107. <TextField
  108. fullWidth
  109. {...register("phone")}
  110. id="phone"
  111. label="Phone"
  112. InputLabelProps={{
  113. shrink: true
  114. }}
  115. />
  116. </Grid>
  117. <Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>
  118. <Autocomplete
  119. {...register("accountFilter")}
  120. disablePortal
  121. id="accountFilter"
  122. options={["All", "Active","Locked","Not verified"]}
  123. value={accountFilter}
  124. onChange={(event, newValue) => {
  125. if (newValue !== null){
  126. setAccountFilter(newValue);
  127. }
  128. }}
  129. renderInput={(params) => (
  130. <TextField {...params}
  131. label="Status"
  132. InputLabelProps={{
  133. shrink: true
  134. }}
  135. />
  136. )}
  137. />
  138. </Grid>
  139. {/*<Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>*/}
  140. {/* <TextField*/}
  141. {/* fullWidth*/}
  142. {/* {...register("subDivisionId")}*/}
  143. {/* id="subDivision"*/}
  144. {/* label="Sub-Division"*/}
  145. {/* />*/}
  146. {/*</Grid>*/}
  147. </Grid>
  148. {/*last row*/}
  149. <Grid container maxWidth justifyContent="flex-end">
  150. <Grid item sx={{ml:3, mr:3, mb:3, mt:3}}>
  151. <Button
  152. size="large"
  153. variant="contained"
  154. onClick={resetForm}
  155. sx={{
  156. textTransform: 'capitalize',
  157. alignItems: 'end'
  158. }}>
  159. <Typography variant="h5">Clear</Typography>
  160. </Button>
  161. </Grid>
  162. <Grid item sx={{ml:3, mr:3, mb:3, mt:3}}>
  163. <Button
  164. size="large"
  165. variant="contained"
  166. type="submit"
  167. sx={{
  168. textTransform: 'capitalize',
  169. alignItems: 'end'
  170. }}>
  171. <Typography variant="h5">Submit</Typography>
  172. </Button>
  173. </Grid>
  174. </Grid>
  175. </form>
  176. </MainCard>
  177. );
  178. };
  179. export default UserSearchForm_Organization;