feat(search histo v2): created search history component + historyRow + fetching da things

This commit is contained in:
danis
2023-12-06 22:41:02 +01:00
parent 1c1596b44a
commit 3353a17611
4 changed files with 84 additions and 2 deletions

View File

@@ -149,7 +149,7 @@ const SearchBarComponent = () => {
setArtist(artist.name);
}}
/>
))
))
: null}
</View>
</ScrollView>

View File

@@ -0,0 +1,69 @@
import { View } from 'react-native';
import { Text } from 'native-base';
import { useQuery } from '../../Queries';
import API from '../../API';
import { translate } from '../../i18n/i18n';
import { LoadingView } from '../Loading';
type historyRowProps = {
type: string;
query: string;
timestamp: Date;
};
const HistoryRowComponent = (props: historyRowProps) => {
return (
<View
style={{
borderTopWidth: 1,
borderTopColor: '#9E9E9E',
paddingTop: 5,
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
gap: 10,
}}
>
<View>
<View
style={{
backgroundColor: 'gray',
borderRadius: 8,
paddingVertical: 4,
paddingHorizontal: 12,
}}
>
<Text>{props.type}</Text>
</View>
<Text>{props.query}</Text>
</View>
<Text>{props.timestamp.toLocaleDateString()}</Text>
</View>
);
};
const SearchHistoryComponent = () => {
const historyQuery = useQuery(API.getSearchHistory(0, 12));
if (historyQuery.isLoading) {
return <LoadingView />;
}
return (
<View style={{ display: 'flex', gap: 10 }}>
<Text fontSize={20}>{translate('histoHeading')}</Text>
<Text>{translate('histoDesc')}</Text>
{historyQuery.data?.map((data, index) => (
<HistoryRowComponent
key={index}
type={data.type}
query={data.query}
timestamp={data.timestamp}
/>
))}
</View>
);
};
export default SearchHistoryComponent;

View File

@@ -85,6 +85,8 @@ export const en = {
genreFilter: 'Genres',
favoriteFilter: 'Favorites',
searchBarPlaceholder: 'What are you looking for ?',
histoHeading: 'Your last researches',
histoDesc: 'Quickly find the tracks that you recently searched. Search and play away !',
// profile page
user: 'Profile',
@@ -398,6 +400,9 @@ export const fr: typeof en = {
genreFilter: 'Genres',
favoriteFilter: 'Favoris',
searchBarPlaceholder: 'Que recherchez vous ?',
histoHeading: 'Vos Dernières Recherches',
histoDesc:
'Retrouvez rapidement les morceaux que vous avez cherchés récemment. Continuez à explorer et à jouer !',
// Difficulty settings
diffBtn: 'Difficulté',
@@ -725,6 +730,9 @@ export const sp: typeof en = {
genreFilter: 'géneros',
favoriteFilter: 'Favorites',
searchBarPlaceholder: 'Qué estás buscando ?',
histoHeading: 'Tus últimas investigaciones',
histoDesc:
'Encuentra rápidamente las canciones que has estado buscando recientemente. ¡Sigue explorando y jugando!',
// Difficulty settings
diffBtn: 'Dificultad',

View File

@@ -2,12 +2,17 @@ import React from 'react';
import ScaffoldCC from '../../components/UI/ScaffoldCC';
import SearchBarComponent from '../../components/V2/SearchBar';
import { RouteProps } from '../../Navigation';
import SearchHistory from '../../components/V2/SearchHistory';
import { View } from 'react-native';
// eslint-disable-next-line @typescript-eslint/ban-types
const SearchView = (props: RouteProps<{}>) => {
return (
<ScaffoldCC routeName={props.route.name}>
<SearchBarComponent />
<View style={{ display: 'flex', gap: 50 }}>
<SearchBarComponent />
<SearchHistory />
</View>
</ScaffoldCC>
);
};