Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

180 řádky
6.3 KiB

  1. // material-ui
  2. import {
  3. Button,
  4. Grid, TextField,
  5. Autocomplete,
  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_Individual = ({ 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. fullName: data.fullenName,
  27. email: data.email,
  28. phone: data.phone,
  29. };
  30. if(accountFilter!="All"){
  31. temp["accountFilter"] = 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={{ 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="pnspsFormHeader" >
  49. Search
  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("userName")}
  58. id='userName'
  59. label="Username"
  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("fullenName")}
  69. id="fullenName"
  70. label="Full Name"
  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("email")}
  80. id="email"
  81. label="Email"
  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("phone")}
  91. id="phone"
  92. label="Phone"
  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. <Autocomplete
  100. {...register("accountFilter")}
  101. disablePortal
  102. id="accountFilter"
  103. size="small"
  104. options={["All","Active", "Locked", "Not Verified"]}
  105. value={accountFilter}
  106. onChange={(event, newValue) => {
  107. if (newValue !== null) {
  108. setAccountFilter(newValue);
  109. }else{
  110. setAccountFilter("All");
  111. }
  112. }}
  113. renderInput={(params) => (
  114. <TextField {...params}
  115. label="Status"
  116. InputLabelProps={{
  117. shrink: true
  118. }}
  119. />
  120. )}
  121. />
  122. </Grid>
  123. {/*<Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>*/}
  124. {/* <TextField*/}
  125. {/* fullWidth*/}
  126. {/* {...register("subDivisionId")}*/}
  127. {/* id="subDivision"*/}
  128. {/* label="Sub-Division"*/}
  129. {/* />*/}
  130. {/*</Grid>*/}
  131. </Grid>
  132. {/*last row*/}
  133. <Grid container maxWidth justifyContent="flex-end">
  134. <ThemeProvider theme={PNSPS_BUTTON_THEME}>
  135. <Grid item sx={{ ml: 3, mr: 3, mb: 3 }}>
  136. <Button
  137. variant="contained"
  138. color="cancel"
  139. onClick={resetForm}
  140. >
  141. Reset
  142. </Button>
  143. </Grid>
  144. <Grid item sx={{ mb: 3}}>
  145. <Button
  146. variant="contained"
  147. type="submit"
  148. >
  149. Submit
  150. </Button>
  151. </Grid>
  152. </ThemeProvider>
  153. </Grid>
  154. </Grid>
  155. </form>
  156. </MainCard>
  157. );
  158. };
  159. export default UserSearchForm_Individual;