diff --git a/front/Navigation.tsx b/front/Navigation.tsx index 66ccd0f..17b119d 100644 --- a/front/Navigation.tsx +++ b/front/Navigation.tsx @@ -90,7 +90,7 @@ const protectedRoutes = () => }, Leaderboard: { component: Leaderboardiew, - options: { title: translate('leaderboardTitle') }, + options: { title: translate('leaderboardTitle'), headerShown: false }, link: '/leaderboard', }, Error: { diff --git a/front/components/UI/ScaffoldCC.tsx b/front/components/UI/ScaffoldCC.tsx index c761200..c6070a0 100644 --- a/front/components/UI/ScaffoldCC.tsx +++ b/front/components/UI/ScaffoldCC.tsx @@ -13,7 +13,7 @@ const menu = [ { type: 'main', title: 'menuProfile', icon: User, link: 'User' }, { type: 'main', title: 'menuMusic', icon: Music, link: 'Music' }, { type: 'main', title: 'menuSearch', icon: SearchNormal1, link: 'Search' }, - { type: 'main', title: 'menuLeaderBoard', icon: Cup, link: 'Score' }, + { type: 'main', title: 'menuLeaderBoard', icon: Cup, link: 'Leaderboard' }, { type: 'sub', title: 'menuSettings', icon: Setting2, link: 'Settings' }, ] as const; diff --git a/front/models/User.ts b/front/models/User.ts index c59bab5..929a265 100644 --- a/front/models/User.ts +++ b/front/models/User.ts @@ -18,6 +18,7 @@ export const UserValidator = yup googleID: yup.string().required().nullable(), isGuest: yup.boolean().required(), partyPlayed: yup.number().required(), + totalScore: yup.number().required(), }) .concat(ModelValidator); @@ -30,6 +31,7 @@ export const UserHandler: ResponseHandler, U premium: false, data: { gamesPlayed: value.partyPlayed as number, + totalScore: value.totalScore as number, xp: 0, createdAt: new Date('2023-04-09T00:00:00.000Z'), avatar: `${API.baseUrl}/users/${value.id}/picture`, @@ -51,7 +53,7 @@ interface User extends Model { interface UserData { gamesPlayed: number; xp: number; - totalScore: number; + totalScore: number; avatar: string; createdAt: Date; } diff --git a/front/views/HomeView.tsx b/front/views/HomeView.tsx index 1023bd1..b057acd 100644 --- a/front/views/HomeView.tsx +++ b/front/views/HomeView.tsx @@ -122,7 +122,7 @@ const HomeView = (props: RouteProps<{}>) => { translate={{ translationKey: 'leaderboardTitle' }} colorScheme="primary" size="sm" - onPress={() => navigation.navigate('Leaderboard')} + onPress={() => navigation.navigate('Leaderboard', {})} /> { +const PodiumCardComponent = ({ + offset, + medalColor, + userAvatarUrl, + userPseudo, + userLvl, +}: PodiumCardProps) => { return ( - @@ -68,22 +77,25 @@ const PodiumCardComponent = ({ offset, medalColor, userAvatarUrl, userPseudo, us fontWeight: '500', }} > - {userXp} LVL + {userLvl} LVL ); }; type BoardRowProps = { + userAvatarUrl: string; userPseudo: string; - userXp: number; -} + userLvl: number; + index: number; +}; -const BoardRowComponent = () => { +const BoardRowComponent = ({ userAvatarUrl, userPseudo, userLvl, index }: BoardRowProps) => { return ( { > @@ -115,12 +132,12 @@ const BoardRowComponent = () => { style={{ fontSize: 16, fontStyle: 'normal', - flex: '1 1 0', + flex: 1, marginHorizontal: 10, fontWeight: '500', }} > - Momo est boutain + {userPseudo} { marginHorizontal: 10, }} > - 200 LVL + {userLvl} LVL { textAlign: 'center', }} > - 8 + {index + 4} ); }; -const dummyScores = [ - { - id: 1, - }, - { - id: 2, - }, - { - id: 3, - }, - { - id: 4, - }, - { - id: 5, - }, - { - id: 6, - }, - { - id: 7, - }, - { - id: 8, - }, - { - id: 9, - }, -]; +const Leaderboardiew = (props: RouteProps>) => { + const navigation = useNavigation(); + const scoresQuery = useQuery(API.getTopTwentyPlayers()); + const screenSize = useBreakpointValue({ base: 'small', md: 'big' }); + const isPhone = screenSize === 'small'; -const Leaderboardiew = () => { - const scoresQuery = useQuery(API.getTopTwentyPlayers); + if (scoresQuery.isError) { + navigation.navigate('Error'); + return <>; + } + if (scoresQuery.data === undefined) { + return ( + + + + ); + } return ( - - - + + - - - + {!isPhone ? ( + + + + + + ) : ( + + + + + + + + )} + {scoresQuery.data.slice(3).map((comp: User, index: number) => ( + + ))} - {dummyScores.map((comp, index) => ( - - ))} - - + + ); };