-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from game-node-app/dev
Profile stats screen
- Loading branch information
Showing
24 changed files
with
678 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Game } from "@/wrapper/server"; | ||
|
||
/** | ||
* Based on a game's category id, retrieves its readable name. | ||
* @param category | ||
*/ | ||
export function getGameCategoryName(category?: number) { | ||
const CATEGORY_TO_TEXT = { | ||
[Game.category._1.valueOf()]: "DLC", | ||
[Game.category._2.valueOf()]: "DLC", | ||
[Game.category._3.valueOf()]: "Bundle", | ||
[Game.category._4.valueOf()]: "Expansion", | ||
[Game.category._5.valueOf()]: "Mod", | ||
[Game.category._6.valueOf()]: "Episode", | ||
[Game.category._7.valueOf()]: "Season", | ||
[Game.category._8.valueOf()]: "Remake", | ||
[Game.category._9.valueOf()]: "Remaster", | ||
[Game.category._10.valueOf()]: "Expanded Game", | ||
[Game.category._11.valueOf()]: "Port", | ||
[Game.category._12.valueOf()]: "Fork", | ||
[Game.category._13.valueOf()]: "Pack", | ||
[Game.category._14.valueOf()]: "Update", | ||
}; | ||
if (!category) return undefined; | ||
return CATEGORY_TO_TEXT[category]; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { | ||
ExoticComponent, | ||
PropsWithChildren, | ||
PropsWithoutRef, | ||
} from "react"; | ||
import { IconBrandXbox, IconProps } from "@tabler/icons-react"; | ||
import { Box, BoxProps, ThemeIcon, ThemeIconProps } from "@mantine/core"; | ||
|
||
interface RoundedIconProps { | ||
icon: ExoticComponent<PropsWithoutRef<IconProps>>; | ||
iconProps?: PropsWithoutRef<IconProps>; | ||
wrapperProps?: PropsWithoutRef<ThemeIconProps>; | ||
} | ||
|
||
const RoundedIcon = (props: RoundedIconProps) => { | ||
return ( | ||
<ThemeIcon | ||
radius={"50%"} | ||
variant={"outline"} | ||
p={12} | ||
className={"w-fit h-fit min-w-fit bg-[#161616] border-[#161616]"} | ||
{...props.wrapperProps} | ||
> | ||
<props.icon size={"3rem"} {...props.iconProps} /> | ||
</ThemeIcon> | ||
); | ||
}; | ||
|
||
export default RoundedIcon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/components/profile/hooks/useProfileMetricsDistributionByType.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { ProfileMetricsService } from "@/wrapper/server"; | ||
|
||
export type ProfileMetricsDistributionTypeBy = | ||
| "genre" | ||
| "category" | ||
| "mode" | ||
| "platform"; | ||
|
||
export function useProfileMetricsDistributionByType( | ||
userId: string, | ||
by: ProfileMetricsDistributionTypeBy, | ||
) { | ||
return useQuery({ | ||
queryKey: ["profile", "metrics", "distribution", "type", userId, by], | ||
queryFn: async () => { | ||
return ProfileMetricsService.profileMetricsControllerGetTypeDistribution( | ||
userId, | ||
by, | ||
); | ||
}, | ||
}); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/components/profile/hooks/useProfileMetricsDistributionByYear.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { ProfileMetricsService } from "@/wrapper/server"; | ||
|
||
export type ProfileMetricsDistributionYearBy = "release_year" | "finish_year"; | ||
|
||
export function useProfileMetricsDistributionByYear( | ||
userId: string | undefined, | ||
by: ProfileMetricsDistributionYearBy, | ||
) { | ||
return useQuery({ | ||
queryKey: ["profile", "metrics", "distribution", userId, by], | ||
queryFn: async () => { | ||
if (!userId) return null; | ||
return ProfileMetricsService.profileMetricsControllerGetYearDistribution( | ||
userId, | ||
by, | ||
); | ||
}, | ||
enabled: !!userId, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/components/profile/view/stats/ProfileStatsDataIcon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { ExoticComponent, PropsWithoutRef } from "react"; | ||
import { IconDeviceGamepad2, IconProps } from "@tabler/icons-react"; | ||
import { Group, Stack, Text, Title } from "@mantine/core"; | ||
import RoundedIcon from "@/components/general/RoundedIcon"; | ||
|
||
interface ProfileStatsDataIconProps { | ||
description: string; | ||
count?: number; | ||
icon: ExoticComponent<PropsWithoutRef<IconProps>>; | ||
} | ||
|
||
const ProfileStatsDataIcon = ({ | ||
description, | ||
count = 0, | ||
icon, | ||
}: ProfileStatsDataIconProps) => { | ||
return ( | ||
<Group className={"gap-2 flex-nowrap"}> | ||
<RoundedIcon | ||
icon={icon} | ||
iconProps={{ | ||
size: "3rem", | ||
}} | ||
/> | ||
<Stack className={"gap-0.5"}> | ||
<Title size={"h2"} className={"text-brand-4"}> | ||
{count} | ||
</Title> | ||
<Text className={"text-md"}>{description}</Text> | ||
</Stack> | ||
</Group> | ||
); | ||
}; | ||
|
||
export default ProfileStatsDataIcon; |
Oops, something went wrong.