Files
nobat724_front/components/searchHead/smSearch/AutoCompleteSearch.js
T

60 lines
1.5 KiB
JavaScript

import { Autocomplete, TextField } from "@mui/material";
function AutoCompleteSearch({
data,
inputValue,
placeholder,
handleSearch,
setInputValue,
setSelectedOption,
}) {
return (
<Autocomplete
freeSolo
options={data}
getOptionLabel={(option) => option.name}
inputValue={inputValue}
className="!w-full"
onInputChange={(event, newInputValue) => {
setInputValue && setInputValue(newInputValue);
handleSearch(newInputValue);
}}
onChange={(event, newValue) => {
setSelectedOption(newValue);
handleSearch(newValue ? newValue.name : "");
}}
sx={{
"& .MuiAutocomplete-input": {
background: "#ffffff !important",
},
}}
renderInput={(params) => (
<TextField
{...params}
variant="standard"
placeholder={placeholder}
dir="rtl"
InputProps={{
...params.InputProps,
disableUnderline: true,
style: { height: "100%" },
}}
sx={{
background: "transparent !important",
"& .MuiInputBase-input": {
background: "#FAFAFA",
color: "#6C757D",
padding: "0 16px",
fontSize: "14px",
fontFamily: "inherit",
},
}}
className="!shadow-none !w-full !px-5 !h-full !text-[14px] md:!text-[16px] !min-w-[50%] !rounded-0 !font-normal"
/>
)}
/>
);
}
export default AutoCompleteSearch;