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.
 
 

205 line
7.9 KiB

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