diff --git a/src/components/Utils/SearchArea/SearchArea.tsx b/src/components/Utils/SearchArea/SearchArea.tsx index 5dfe506..2c61083 100644 --- a/src/components/Utils/SearchArea/SearchArea.tsx +++ b/src/components/Utils/SearchArea/SearchArea.tsx @@ -1,14 +1,24 @@ -import React, { ChangeEvent, FC, useEffect, useState } from 'react'; -import styled from 'styled-components'; -import SearchIcon from '@mui/icons-material/Search'; -import CloseIcon from '@mui/icons-material/Close'; -import { Autocomplete, Button, Dialog, DialogActions, DialogContent, DialogTitle, FormControl, InputLabel, MenuItem, Select, SelectChangeEvent, TextField } from '@mui/material'; -import FungiService from '../../../services/FungiService'; -import getClassificationName from '../../../Utils/Enums/BemClassification'; -import SelectInterface from '../../../Interfaces/Select'; -import SelectStates from '../../../Utils/SelectStates'; -import SelectBemClassification from '../../../Utils/SelectBemClassification'; -import SelectHabitat from '../../../Utils/selectHabitat'; +import React, { ChangeEvent, FC, useEffect, useState } from "react"; +import styled from "styled-components"; +import SearchIcon from "@mui/icons-material/Search"; +import CloseIcon from "@mui/icons-material/Close"; +import { + Button, + Dialog, + DialogActions, + DialogContent, + DialogTitle, + FormControl, + InputLabel, + MenuItem, + Select, + SelectChangeEvent, +} from "@mui/material"; +import FungiService from "../../../services/FungiService"; +import getClassificationName from "../../../Utils/Enums/BemClassification"; +import SelectInterface from "../../../Interfaces/Select"; +import SelectStates from "../../../Utils/SelectStates"; +import SelectBemClassification from "../../../Utils/SelectBemClassification"; interface SearchAreaProps { onChange?: (event: ChangeEvent) => void; @@ -16,13 +26,13 @@ interface SearchAreaProps { } const FilterBox = styled.div` - border: 2px solid #fff; /* Borda branca */ - border-radius: 8px; /* Bordas arredondadas */ - padding: -1px; /* Espaçamento interno */ + border: 2px solid #fff; + border-radius: 8px; + padding: 0; display: flex; align-items: center; justify-content: center; - background-color: transparent; /* Fundo transparente */ + background-color: transparent; `; const Container = styled.div` @@ -66,36 +76,20 @@ const FilterContainer = styled.div` display: flex; gap: 10px; justify-content: space-between; + margin-top: 20px; `; const SearchArea: FC = ({ onChange, placeholder }) => { const fungiService: FungiService = new FungiService(); const states: SelectInterface = SelectStates(); const bemClassifications: SelectInterface = SelectBemClassification(); - const habitats: SelectInterface = SelectHabitat(); // Inicializando SelectHabitat + const [fungis, setFungis] = useState>([]); const [state, setState] = useState(""); - const [bem, setBem] = useState(""); + const [classification, setClassification] = useState(""); const [taxon, setTaxon] = useState(""); - const [habitatValue, setHabitatValue] = useState(""); const [isDialogOpen, setIsDialogOpen] = useState(false); - const handleOpenDialog = () => { - setIsDialogOpen(true); - }; - - const handleCloseDialog = () => { - setIsDialogOpen(false); - }; - - const handleChangeState = (event: SelectChangeEvent) => { - setState(event.target.value); - }; - - const handleChangeBem = (event: SelectChangeEvent) => { - setBem(event.target.value); - }; - useEffect(() => { getFungis(); }, []); @@ -111,18 +105,16 @@ const SearchArea: FC = ({ onChange, placeholder }) => { } }; - const handleChangeHabitatValue = (event: SelectChangeEvent) => { - setHabitatValue(event.target.value); - }; + const handleOpenDialog = () => setIsDialogOpen(true); + const handleCloseDialog = () => setIsDialogOpen(false); - const onClickSearchButton = async () => { - let habitatTextField = document.getElementById( - "input-habitat" - ) as HTMLInputElement; - let habitatValue = habitatTextField?.value; + const handleChangeState = (event: SelectChangeEvent) => setState(event.target.value); + const handleChangeClassification = (event: SelectChangeEvent) => + setClassification(event.target.value); + const handleChangeTaxon = (event: SelectChangeEvent) => setTaxon(event.target.value); - window.location.href = `/list?taxonomy=${taxon ?? ""}&state=${state ?? "" - }&bem=${bem ?? ""}&habitat=${habitatValue ?? ""}`; + const onClickSearchButton = () => { + window.location.href = `/list?taxonomy=${taxon ?? ""}&state=${state ?? ""}&classification=${classification ?? ""}`; }; return ( @@ -131,174 +123,137 @@ const SearchArea: FC = ({ onChange, placeholder }) => { - - + + Pesquisa e Filtros - - - - - - a.bem - b.bem)} - onInputChange={(event, value) => (value ? setTaxon(value) : null)} - groupBy={(option: any) => option?.bemName} - getOptionLabel={(option: any) => option?.scientific_name} - renderInput={(params) => ( - + + {/* Estado */} + + + + Estado + + - - Nenhum + > + + Nenhum + + {states.options.map((s) => ( + + {s.value} - {states.options.map((state) => ( - - {state.value} - - ))} - - - - - - BEM - + + + + {/* Espécie */} + + + + Espécie + + - - + ))} + + + - - - Habitat - + + Nenhum + + {bemClassifications.options.map((b) => ( + + {`${b.id}`} - {habitats.options.map((habitat) => ( - - {habitat.value} - - ))} - - - - - + ))} + + + + - -