From 5d103c66876974315f884dffc19cdd3968582515 Mon Sep 17 00:00:00 2001 From: danis Date: Thu, 7 Dec 2023 17:18:00 +0100 Subject: [PATCH] feat(search): proper data passing through handler --- front/components/V2/SearchBar.tsx | 18 ++++++------------ front/views/V2/SearchView.tsx | 4 ++-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/front/components/V2/SearchBar.tsx b/front/components/V2/SearchBar.tsx index 931c67c..8de5b62 100644 --- a/front/components/V2/SearchBar.tsx +++ b/front/components/V2/SearchBar.tsx @@ -43,7 +43,7 @@ const ArtistChipComponent = (props: ArtistChipProps) => { const SearchBarComponent = (props: { onValidate: (searchData: searchProps) => void }) => { const [query, setQuery] = React.useState(''); - const [genre, setGenre] = React.useState({} as Genre | undefined); + const [genre, setGenre] = React.useState(''); const [artist, setArtist] = React.useState(''); const artistsQuery = useQuery(API.getAllArtists()); const genresQuery = useQuery(API.getAllGenres()); @@ -53,9 +53,9 @@ const SearchBarComponent = (props: { onValidate: (searchData: searchProps) => vo const handleValidate = () => { // Construct an object with the data you want to pass to the parent component const searchData = { - query: "test", - artist: 1, - genre: 1, + query: query, + artist: artistsQuery.data?.find((a) => a.name === artist)?.id ?? undefined, + genre: genresQuery.data?.find((g) => g.name === genre)?.id ?? undefined, }; // Call the parent's onValidate callback with the searchData @@ -169,16 +169,10 @@ const SearchBarComponent = (props: { onValidate: (searchData: searchProps) => vo