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.
 
 

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