From 3353a17611a357ad602a26ad1b6902b3b4bf3cff Mon Sep 17 00:00:00 2001 From: danis Date: Wed, 6 Dec 2023 22:41:02 +0100 Subject: [PATCH 1/6] feat(search histo v2): created search history component + historyRow + fetching da things --- front/components/V2/SearchBar.tsx | 2 +- front/components/V2/SearchHistory.tsx | 69 +++++++++++++++++++++++++++ front/i18n/Translations.ts | 8 ++++ front/views/V2/SearchView.tsx | 7 ++- 4 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 front/components/V2/SearchHistory.tsx diff --git a/front/components/V2/SearchBar.tsx b/front/components/V2/SearchBar.tsx index 0ec2e9f..4af042e 100644 --- a/front/components/V2/SearchBar.tsx +++ b/front/components/V2/SearchBar.tsx @@ -149,7 +149,7 @@ const SearchBarComponent = () => { setArtist(artist.name); }} /> - )) + )) : null} diff --git a/front/components/V2/SearchHistory.tsx b/front/components/V2/SearchHistory.tsx new file mode 100644 index 0000000..19773bd --- /dev/null +++ b/front/components/V2/SearchHistory.tsx @@ -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 ( + + + + {props.type} + + {props.query} + + {props.timestamp.toLocaleDateString()} + + ); +}; + +const SearchHistoryComponent = () => { + const historyQuery = useQuery(API.getSearchHistory(0, 12)); + + if (historyQuery.isLoading) { + return ; + } + + return ( + + {translate('histoHeading')} + {translate('histoDesc')} + {historyQuery.data?.map((data, index) => ( + + ))} + + ); +}; + +export default SearchHistoryComponent; diff --git a/front/i18n/Translations.ts b/front/i18n/Translations.ts index 491366e..c4dfc59 100644 --- a/front/i18n/Translations.ts +++ b/front/i18n/Translations.ts @@ -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', diff --git a/front/views/V2/SearchView.tsx b/front/views/V2/SearchView.tsx index ca52594..a4034e7 100644 --- a/front/views/V2/SearchView.tsx +++ b/front/views/V2/SearchView.tsx @@ -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 ( - + + + + ); }; From 5c4847ae2c51594d43777f8fafeba6ec12a39e09 Mon Sep 17 00:00:00 2001 From: danis Date: Tue, 2 Jan 2024 20:24:48 +0100 Subject: [PATCH 2/6] style(searchBarV2): fixed coding style eslint error --- front/components/V2/SearchBar.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/front/components/V2/SearchBar.tsx b/front/components/V2/SearchBar.tsx index 4af042e..ab14dbe 100644 --- a/front/components/V2/SearchBar.tsx +++ b/front/components/V2/SearchBar.tsx @@ -149,6 +149,7 @@ const SearchBarComponent = () => { setArtist(artist.name); }} /> + // eslint-disable-next-line no-mixed-spaces-and-tabs )) : null} From ef57eb752dfd3492085e31b8f2222ba03d04ebf3 Mon Sep 17 00:00:00 2001 From: danis Date: Thu, 4 Jan 2024 18:41:44 +0100 Subject: [PATCH 3/6] fix(../V2/SearchHistory): fixed background width of history type prop --- front/components/V2/SearchHistory.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/front/components/V2/SearchHistory.tsx b/front/components/V2/SearchHistory.tsx index 19773bd..634282a 100644 --- a/front/components/V2/SearchHistory.tsx +++ b/front/components/V2/SearchHistory.tsx @@ -32,6 +32,7 @@ const HistoryRowComponent = (props: historyRowProps) => { borderRadius: 8, paddingVertical: 4, paddingHorizontal: 12, + alignSelf: 'flex-start', }} > {props.type} From 851ee7420f6849adddd1770cf6bc8a8c3bdfafce Mon Sep 17 00:00:00 2001 From: danis Date: Thu, 4 Jan 2024 19:31:36 +0100 Subject: [PATCH 4/6] fix(../V2/SearchHistory): fixed hard coded color + lightmode thing --- front/components/V2/SearchHistory.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/front/components/V2/SearchHistory.tsx b/front/components/V2/SearchHistory.tsx index 634282a..71ea3d7 100644 --- a/front/components/V2/SearchHistory.tsx +++ b/front/components/V2/SearchHistory.tsx @@ -1,9 +1,10 @@ import { View } from 'react-native'; -import { Text } from 'native-base'; +import { Text, theme } from 'native-base'; import { useQuery } from '../../Queries'; import API from '../../API'; import { translate } from '../../i18n/i18n'; import { LoadingView } from '../Loading'; +import useColorScheme from '../../hooks/colorScheme'; type historyRowProps = { type: string; @@ -12,11 +13,14 @@ type historyRowProps = { }; const HistoryRowComponent = (props: historyRowProps) => { + const colorScheme = useColorScheme(); + return ( { Date: Thu, 4 Jan 2024 22:21:11 +0100 Subject: [PATCH 5/6] Now using european date format --- front/components/V2/SearchHistory.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/components/V2/SearchHistory.tsx b/front/components/V2/SearchHistory.tsx index 71ea3d7..ad5356e 100644 --- a/front/components/V2/SearchHistory.tsx +++ b/front/components/V2/SearchHistory.tsx @@ -46,7 +46,7 @@ const HistoryRowComponent = (props: historyRowProps) => { {props.query} - {props.timestamp.toLocaleDateString()} + {props.timestamp.toLocaleDateString(["fr-FR", "en-GB"])} ); }; From f46c2cfb4aeceaf065893dcd3dd92c053b13472b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Thu, 4 Jan 2024 22:22:56 +0100 Subject: [PATCH 6/6] fix ci --- front/components/V2/SearchHistory.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/components/V2/SearchHistory.tsx b/front/components/V2/SearchHistory.tsx index ad5356e..f6b011d 100644 --- a/front/components/V2/SearchHistory.tsx +++ b/front/components/V2/SearchHistory.tsx @@ -46,7 +46,7 @@ const HistoryRowComponent = (props: historyRowProps) => { {props.query} - {props.timestamp.toLocaleDateString(["fr-FR", "en-GB"])} + {props.timestamp.toLocaleDateString(['fr-FR', 'en-GB'])} ); };