diff --git a/front/API.ts b/front/API.ts index a7e30d4..e3de4d2 100644 --- a/front/API.ts +++ b/front/API.ts @@ -384,7 +384,6 @@ export default class API { }; } - public static getGenres(): Query { return { key: ['genres'], @@ -395,7 +394,7 @@ export default class API { }, { handler: PlageHandler(GenreHandler) } ).then(({ data }) => data), - } + }; } /** @@ -434,14 +433,14 @@ export default class API { public static getArtists(): Query { return { key: ['artists'], - exec: () => + exec: () => API.fetch( { route: `/artist`, }, { handler: PlageHandler(ArtistHandler) } - ).then(({ data }) => data) - } + ).then(({ data }) => data), + }; } /** diff --git a/front/components/V2/SearchBar.tsx b/front/components/V2/SearchBar.tsx index 9c4e372..b625ac3 100644 --- a/front/components/V2/SearchBar.tsx +++ b/front/components/V2/SearchBar.tsx @@ -1,58 +1,48 @@ -import React from "react"; -import { Button, Text, Select} from 'native-base' -import { ScrollView, TextInput, View } from "react-native"; -import ButtonBase from "../UI/ButtonBase"; -import { AddSquare, CloseCircle, SearchNormal1 } from "iconsax-react-native"; -import Artist from "../../models/Artist"; -import Song from "../../models/Song"; -import { useQuery } from "../../Queries"; -import API from "../../API"; -import { useNavigation } from "../../Navigation"; -import { LoadingView } from "../Loading"; -import Genre from "../../models/Genre"; - +import React from 'react'; +import { Button, Text, Select } from 'native-base'; +import { ScrollView, TextInput, View } from 'react-native'; +import ButtonBase from '../UI/ButtonBase'; +import { AddSquare, CloseCircle, SearchNormal1 } from 'iconsax-react-native'; +import { useQuery } from '../../Queries'; +import API from '../../API'; +import { LoadingView } from '../Loading'; +import Genre from '../../models/Genre'; type ArtistChipProps = { - name: string, - selected?: boolean, + name: string; + selected?: boolean; onPress: () => void; -} +}; const ArtistChipComponent = (props: ArtistChipProps) => { return ( - - ) -} - -type SearchBarComponentProps = { - query: string; + ); }; -const SearchBarComponent = (props: SearchBarComponentProps) => { - const navigation = useNavigation(); - const [isTriggered, setIsTriggered] = React.useState(false); +const SearchBarComponent = () => { const [query, setQuery] = React.useState(''); const [genre, setGenre] = React.useState({} as Genre | undefined); const [artist, setArtist] = React.useState(''); - const [artistSearch, setArtistSearch] = React.useState([] as Artist[]); - const [songSearch, setSongSearch] = React.useState([] as Song[]); const artistsQuery = useQuery(API.getArtists()); const genresQuery = useQuery(API.getGenres()); @@ -62,51 +52,73 @@ const SearchBarComponent = (props: SearchBarComponentProps) => { return ( - - {artist ? - setArtist('')} name={artist} selected={true} /> : null} - + {artist ? ( + setArtist('')} + name={artist} + selected={true} + /> + ) : null} + - + style={{ width: '100%', height: 30 }} + onChangeText={(value) => setQuery(value)} + /> + - - - {!artist ? artistsQuery.data?.map((artist, index) => ( - - { - setArtist(artist.name) - }} - /> - - )) : null} + + + {!artist + ? artistsQuery.data?.map((artist, index) => ( + { + setArtist(artist.name); + }} + /> + )) + : null} - - ) -} + ); +}; -export default SearchBarComponent; \ No newline at end of file +export default SearchBarComponent; diff --git a/front/views/HomeView.tsx b/front/views/HomeView.tsx index b057acd..4ebfb3d 100644 --- a/front/views/HomeView.tsx +++ b/front/views/HomeView.tsx @@ -110,7 +110,7 @@ const HomeView = (props: RouteProps<{}>) => { translate={{ translationKey: 'searchBtn' }} colorScheme="secondary" size="sm" - onPress={() => navigation.navigate('Search', {})} + onPress={() => navigation.navigate('Search')} /> ) => { size="xs" colorScheme="primary" label={query} - onPress={() => - navigation.navigate('Search', { query: query }) - } + onPress={() => navigation.navigate('Search')} /> ))} diff --git a/front/views/SearchView.tsx b/front/views/SearchView.tsx index 3094103..3af01fc 100644 --- a/front/views/SearchView.tsx +++ b/front/views/SearchView.tsx @@ -1,13 +1,12 @@ import React, { useState } from 'react'; import SearchBar from '../components/SearchBar'; -import SearchBarComponent from '../components/V2/SearchBar' import Artist from '../models/Artist'; import Song from '../models/Song'; import Genre from '../models/Genre'; import API from '../API'; import { useQuery } from '../Queries'; import { SearchResultComponent } from '../components/SearchResult'; -import { SafeAreaView, View } from 'react-native'; +import { SafeAreaView } from 'react-native'; import { Filter } from '../components/SearchBar'; import { ScrollView } from 'native-base'; import { RouteProps } from '../Navigation'; diff --git a/front/views/V2/SearchView.tsx b/front/views/V2/SearchView.tsx index b700702..812ce65 100644 --- a/front/views/V2/SearchView.tsx +++ b/front/views/V2/SearchView.tsx @@ -1,21 +1,17 @@ -import React from "react"; -import { View } from "react-native"; -import SearchBarComponent from "../../components/V2/SearchBar"; +import React from 'react'; +import { View } from 'react-native'; +import SearchBarComponent from '../../components/V2/SearchBar'; // search with all parameters from search bar function // return to search bar auto completion thing -export class SearchQueryObject { - -} - const SearchView = () => { return ( - - + + - ) -} + ); +}; -export default SearchView; \ No newline at end of file +export default SearchView;