-
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 #51 from game-node-app/dev
HLTB playtime MVP
- Loading branch information
Showing
15 changed files
with
117 additions
and
26 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
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,56 @@ | ||
import React from "react"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { SyncHltbService } from "@/wrapper/server"; | ||
import { DetailsBox } from "@/components/general/DetailsBox"; | ||
import GameInfoPlaytimeItem from "@/components/game/info/playtime/GameInfoPlaytimeItem"; | ||
import { Space, Text } from "@mantine/core"; | ||
|
||
interface Props { | ||
gameId: number; | ||
} | ||
|
||
const GameInfoPlaytime = ({ gameId }: Props) => { | ||
const playtimeQuery = useQuery({ | ||
queryKey: ["game", "playtime", gameId], | ||
queryFn: () => { | ||
return SyncHltbService.hltbControllerFindPlaytimeForGameId(gameId); | ||
}, | ||
enabled: !!gameId, | ||
staleTime: Infinity, | ||
retry: 1, | ||
}); | ||
const playtime = playtimeQuery.data; | ||
return ( | ||
<DetailsBox | ||
title={"Playtime"} | ||
withBorder | ||
withDimmedTitle | ||
enabled={playtimeQuery.isLoading || playtimeQuery.isSuccess} | ||
stackProps={{ | ||
gap: 1, | ||
}} | ||
> | ||
<Space h={"0.8rem"} /> | ||
<GameInfoPlaytimeItem | ||
name={"Main"} | ||
isLoading={playtimeQuery.isLoading} | ||
value={playtime?.timeMain} | ||
/> | ||
<GameInfoPlaytimeItem | ||
name={"Main + Extras"} | ||
isLoading={playtimeQuery.isLoading} | ||
value={playtime?.timePlus} | ||
/> | ||
<GameInfoPlaytimeItem | ||
name={"100%"} | ||
isLoading={playtimeQuery.isLoading} | ||
value={playtime?.time100} | ||
/> | ||
<Text className={"text-center text-xs mt-4"} c={"dimmed"}> | ||
Data provided by <a href={"https://howlongtobeat.com"}>HLTB</a> | ||
</Text> | ||
</DetailsBox> | ||
); | ||
}; | ||
|
||
export default GameInfoPlaytime; |
36 changes: 36 additions & 0 deletions
36
src/components/game/info/playtime/GameInfoPlaytimeItem.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,36 @@ | ||
import React from "react"; | ||
import { Group, Stack, Text } from "@mantine/core"; | ||
|
||
interface Props { | ||
name: string; | ||
// Assumed to be in seconds | ||
value: number | null | undefined; | ||
isLoading: boolean; | ||
} | ||
|
||
const GameInfoPlaytimeItem = ({ name, value, isLoading }: Props) => { | ||
if (!value) { | ||
return null; | ||
} | ||
const valueHours = Math.ceil(value / 3600); | ||
return ( | ||
<Group className={"flex-nowrap gap-0 w-full"}> | ||
<Stack | ||
className={ | ||
"items-center w-1/2 h-10 justify-center bg-[#1F1F1F] border-[#2E2E2E] border-[1px] rounded-l" | ||
} | ||
> | ||
{name} | ||
</Stack> | ||
<Stack | ||
className={ | ||
"items-center font-bold w-1/2 h-10 justify-center bg-[#F15025] border-[#2E2E2E] border-[1px] rounded-r" | ||
} | ||
> | ||
{valueHours} Hours | ||
</Stack> | ||
</Group> | ||
); | ||
}; | ||
|
||
export default GameInfoPlaytimeItem; |
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,7 @@ | ||
import React from "react"; | ||
|
||
const GameSearchFilters = () => { | ||
return <div></div>; | ||
}; | ||
|
||
export default GameSearchFilters; |
File renamed without changes.
File renamed without changes.
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
Large diffs are not rendered by default.
Oops, something went wrong.