diff --git a/front/components/V2/SearchBar.tsx b/front/components/V2/SearchBar.tsx index 63116b2..85f1cce 100644 --- a/front/components/V2/SearchBar.tsx +++ b/front/components/V2/SearchBar.tsx @@ -50,14 +50,12 @@ const SearchBarComponent = (props: { onValidate: (searchData: searchProps) => vo const isMobileView = screenSize == 'small'; const handleValidate = () => { - // Construct an object with the data you want to pass to the parent component const searchData = { 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 props.onValidate(searchData); }; diff --git a/front/views/V2/SearchView.tsx b/front/views/V2/SearchView.tsx index e958316..9910be9 100644 --- a/front/views/V2/SearchView.tsx +++ b/front/views/V2/SearchView.tsx @@ -16,35 +16,28 @@ export type searchProps = { // eslint-disable-next-line @typescript-eslint/ban-types const SearchView = (props: RouteProps<{}>) => { const navigation = useNavigation(); - const [searchResult, setSearchResult] = React.useState([] as MusicItemType[]); + // const [searchResult, setSearchResult] = React.useState([] as MusicItemType[]); const [searchQuery, setSearchQuery] = React.useState({artist: undefined, genre: undefined, query: ''} as searchProps) - const rawResult = useQuery(API.searchSongs(searchQuery), en); - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const handleSearch = async (searchQuery: searchProps) => { - // const rawResult = useQuery(API.searchSongs(searchQuery)); - setSearchQuery(searchQuery); - const result = - rawResult.data?.map((song) => ({ - artist: song.artist!.name, - song: song.name, - image: song.cover, - level: 42, - lastScore: 42, - bestScore: 42, - liked: true, - onLike: () => { - console.log('onLike'); - }, - onPlay: () => navigation.navigate('Play', { songId: song.id }), - })) ?? []; - setSearchResult(result ?? []); - }; + const rawResult = useQuery(API.searchSongs(searchQuery), { enabled: !!searchQuery }); + const result = + rawResult.data?.map((song) => ({ + artist: song.artist!.name, + song: song.name, + image: song.cover, + level: 42, + lastScore: 42, + bestScore: 42, + liked: true, + onLike: () => { + console.log('onLike'); + }, + onPlay: () => navigation.navigate('Play', { songId: song.id }), + })) ?? []; return ( - - + + ); };