// material-ui import { Button, Grid, TextField, Autocomplete, Typography } from '@mui/material'; import MainCard from "components/MainCard"; import { useForm } from "react-hook-form"; import { useState,useEffect } from "react"; import {PNSPS_BUTTON_THEME} from "themes/buttonConst"; import {ThemeProvider} from "@emotion/react"; // ==============================|| DASHBOARD - DEFAULT ||============================== // const UserSearchForm_Individual = ({ applySearch, onGridReady, searchCriteria }) => { const [type, setType] = useState([]); const [accountFilter, setAccountFilter] = useState("All"); const { reset, register, handleSubmit } = useForm() useEffect(() => { if(searchCriteria.accountFilter!=undefined){ if(searchCriteria.accountFilter === ""){ setAccountFilter("All") }else{ setAccountFilter(searchCriteria.accountFilter) } }else{ setAccountFilter("All") } }, [searchCriteria]); const onSubmit = (data) => { let typeArray = []; for (let i = 0; i < type.length; i++) { typeArray.push(type[i].label); } const temp = { username: data.userName, fullName: data.fullenName, email: data.email, phone: data.phone, }; if(accountFilter!="All"){ temp["accountFilter"] = accountFilter; } applySearch(temp); }; function resetForm() { setType([]); setAccountFilter("All"); reset({ userName:"", fullenName:"", email:"", phone:"", }); } return (
{/*row 1*/} Search {/*row 2*/} { if (newValue !== null) { setAccountFilter(newValue); }else{ setAccountFilter("All"); } }} renderInput={(params) => ( )} /> {/**/} {/* */} {/**/} {/*last row*/}
); }; export default UserSearchForm_Individual;