-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated leaderboard #29
Conversation
…ka/zkube into update-leaderboard
@josephchimebuka is attempting to deploy a commit to the z-korp Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe recent changes enhance the leaderboard component to display potential winnings and buy-in amounts for players. Key modifications include updates to the Game interface, new calculation logic for winnings, and UI adjustments for clarity and responsiveness. Additional scripts and dependencies have been introduced to bolster the development environment and testing capabilities. Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Outside diff range, codebase verification and nitpick comments (1)
client/src/ui/modules/Leaderboard.tsx (1)
Line range hint
253-271
: Improve readability and maintainability.Consider extracting the table cells into separate components for better readability and maintainability.
Apply this diff to extract the table cells into separate components:
const TableCellComponent = ({ className, children }) => ( <TableCell className={className}>{children}</TableCell> ); export const Row = ({ rank, game }: { rank: number; game: Game & { potentialWinnings: number }}) => { const { player } = usePlayer({ playerId: game.player_id }); console.log(player); return ( <TableRow className="hover:bg-slate-100 dark:hover:bg-slate-800"> <TableCellComponent className="text-center font-semibold">{`#${rank}`}</TableCellComponent> <TableCellComponent className="text-left sm:max-w-36 truncate"> {player?.name || "-"} </TableCellComponent> <TableCellComponent className="text-center"> {player?.points ? Level.fromPoints(player?.points).value : ""} </TableCellComponent> <TableCellComponent className="text-center font-bold">{game.score}</TableCellComponent> <TableCellComponent className="text-center font-bold">{game.combo}</TableCellComponent> <TableCellComponent className="text-center font-bold">{game.max_combo}</TableCellComponent> <TableCellComponent className="text-center font-bold">{game.buyIn.toFixed(2)}</TableCellComponent> <TableCellComponent className="text-center font-bold">{game.potentialWinnings.toFixed(2)}</TableCellComponent> </TableRow> ); };
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
client/package-lock.json
is excluded by!**/package-lock.json
Files selected for processing (10)
- client/package.json (5 hunks)
- client/src/App.tsx (1 hunks)
- client/src/dojo/game/models/game.ts (2 hunks)
- client/src/hooks/useGames.tsx (1 hunks)
- client/src/ui/components/GameBoard.tsx (1 hunks)
- client/src/ui/elements/dialog.tsx (1 hunks)
- client/src/ui/elements/table.tsx (1 hunks)
- client/src/ui/elements/tooltip.tsx (1 hunks)
- client/src/ui/modules/Leaderboard.tsx (7 hunks)
- client/src/ui/screens/Home.tsx (1 hunks)
Files skipped from review due to trivial changes (6)
- client/src/hooks/useGames.tsx
- client/src/ui/components/GameBoard.tsx
- client/src/ui/elements/dialog.tsx
- client/src/ui/elements/table.tsx
- client/src/ui/elements/tooltip.tsx
- client/src/ui/screens/Home.tsx
Additional comments not posted (15)
client/src/App.tsx (1)
4-5
: LGTM!The
TooltipProvider
is correctly integrated and enhances the application's UI by allowing tooltip functionality throughout the routing context.The code changes are approved.
Also applies to: 10-11, 17-18
client/src/dojo/game/models/game.ts (2)
37-37
: LGTM!The
buyIn
property is correctly added to theGame
class with a default value of 100.The code changes are approved.
65-65
: LGTM!The
buyIn
property is correctly set to 100 in the constructor.The code changes are approved.
client/package.json (11)
17-17
: LGTM!The new script
"test": "jest"
enhances the project's testing capabilities.The code changes are approved.
32-32
: LGTM!The new dependency
@emotion/react
enhances the project's UI capabilities.The code changes are approved.
33-33
: LGTM!The new dependency
@emotion/styled
enhances the project's UI capabilities.The code changes are approved.
34-34
: LGTM!The new dependency
@fortawesome/fontawesome-svg-core
enhances the project's UI capabilities.The code changes are approved.
37-37
: LGTM!The new dependency
@headlessui/react
enhances the project's UI capabilities.The code changes are approved.
40-40
: LGTM!The new dependency
@mui/material
enhances the project's UI capabilities.The code changes are approved.
70-70
: LGTM!The new dependency
react-tooltip
enhances the project's UI capabilities.The code changes are approved.
88-88
: LGTM!The new dependency
@types/jest
enhances the project's testing capabilities by providing improved type definitions for Jest.The code changes are approved.
99-99
: LGTM!The new dependency
jest
enhances the project's testing capabilities.The code changes are approved.
102-102
: LGTM!The new dependency
ts-jest
enhances the project's testing capabilities by providing TypeScript support for Jest.The code changes are approved.
103-103
: LGTM!The new dependency
typescript
enhances the project's development capabilities by providing TypeScript support.The code changes are approved.
client/src/ui/modules/Leaderboard.tsx (1)
94-103
: Verify the function usage.Ensure that all function calls to
Content
are updated to handle the new logic fortotalBuyIn
andwinningPool
.Run the following script to verify the function usage:
Verification successful
Function Usage Verified
The
Content
function is correctly utilized within theLeaderboard.tsx
file, and the new logic fortotalBuyIn
andwinningPool
is appropriately managed. No issues were found in the usage of this function.
client/src/ui/modules/Leaderboard.tsx
: Verified usage withinTabsContent
components.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `Content` handle the new logic. # Test: Search for the function usage. Expect: Only occurrences of the new logic. rg --type tsx -A 5 $'Content'Length of output: 56
Script:
#!/bin/bash # Description: Verify all function calls to `Content` handle the new logic. # Test: Search for the function usage without specifying the file type. rg -A 5 'Content'Length of output: 34389
<DialogContent className="sm:max-w-[500px] "> | ||
<DialogHeader className="flex items-center text-2xl"> | ||
<DialogTitle>Leaderboards</DialogTitle> | ||
</DialogHeader> | ||
<Tabs | ||
value={activeTab} | ||
onValueChange={(value) => setActiveTab(value as ModeType)} | ||
> | ||
<TabsList className="grid w-full grid-cols-2"> | ||
<TabsList className="grid w-[80%] mx-auto sm:w-full grid-cols-2"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve readability and maintainability.
Consider extracting the tab list and tab content into separate components for better readability and maintainability.
Apply this diff to extract the tab list and tab content into separate components:
const TabList = ({ activeTab, setActiveTab }) => (
<TabsList className="grid w-[80%] mx-auto sm:w-full grid-cols-2">
<TabsTrigger value={ModeType.Daily}>Daily</TabsTrigger>
<TabsTrigger value={ModeType.Normal}>Normal</TabsTrigger>
</TabsList>
);
const TabContent = ({ modeType }) => (
<>
<TabsContent value={ModeType.Daily}>
<Content modeType={ModeType.Daily} />
</TabsContent>
<TabsContent value={ModeType.Normal}>
<Content modeType={ModeType.Normal} />
</TabsContent>
</>
);
export const Leaderboard = () => {
const [activeTab, setActiveTab] = useState<ModeType>(ModeType.Daily);
return (
<Dialog>
<DialogTrigger asChild>
<Button variant="outline">Leaderboards</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-[500px] ">
<DialogHeader className="flex items-center text-2xl">
<DialogTitle>Leaderboards</DialogTitle>
</DialogHeader>
<Tabs value={activeTab} onValueChange={(value) => setActiveTab(value as ModeType)}>
<TabList activeTab={activeTab} setActiveTab={setActiveTab} />
<TabContent modeType={activeTab} />
</Tabs>
</DialogContent>
</Dialog>
);
};
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
<DialogContent className="sm:max-w-[500px] "> | |
<DialogHeader className="flex items-center text-2xl"> | |
<DialogTitle>Leaderboards</DialogTitle> | |
</DialogHeader> | |
<Tabs | |
value={activeTab} | |
onValueChange={(value) => setActiveTab(value as ModeType)} | |
> | |
<TabsList className="grid w-full grid-cols-2"> | |
<TabsList className="grid w-[80%] mx-auto sm:w-full grid-cols-2"> | |
const TabList = ({ activeTab, setActiveTab }) => ( | |
<TabsList className="grid w-[80%] mx-auto sm:w-full grid-cols-2"> | |
<TabsTrigger value={ModeType.Daily}>Daily</TabsTrigger> | |
<TabsTrigger value={ModeType.Normal}>Normal</TabsTrigger> | |
</TabsList> | |
); | |
const TabContent = ({ modeType }) => ( | |
<> | |
<TabsContent value={ModeType.Daily}> | |
<Content modeType={ModeType.Daily} /> | |
</TabsContent> | |
<TabsContent value={ModeType.Normal}> | |
<Content modeType={ModeType.Normal} /> | |
</TabsContent> | |
</> | |
); | |
export const Leaderboard = () => { | |
const [activeTab, setActiveTab] = useState<ModeType>(ModeType.Daily); | |
return ( | |
<Dialog> | |
<DialogTrigger asChild> | |
<Button variant="outline">Leaderboards</Button> | |
</DialogTrigger> | |
<DialogContent className="sm:max-w-[500px] "> | |
<DialogHeader className="flex items-center text-2xl"> | |
<DialogTitle>Leaderboards</DialogTitle> | |
</DialogHeader> | |
<Tabs value={activeTab} onValueChange={(value) => setActiveTab(value as ModeType)}> | |
<TabList activeTab={activeTab} setActiveTab={setActiveTab} /> | |
<TabContent modeType={activeTab} /> | |
</Tabs> | |
</DialogContent> | |
</Dialog> | |
); | |
}; |
Hello @josephchimebuka thank you for your work! |
& can we remove the buy in column in the leaderboard plz? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
client/package-lock.json
is excluded by!**/package-lock.json
Files selected for processing (3)
- client/package.json (5 hunks)
- client/src/ui/modules/Leaderboard.tsx (7 hunks)
- client/src/ui/screens/Home.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
- client/src/ui/screens/Home.tsx
Files skipped from review as they are similar to previous changes (2)
- client/package.json
- client/src/ui/modules/Leaderboard.tsx
Hello @Cheelax I have removed the buy in column in the Leaderboard and I fixed the bugs and updated the PR ser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- client/src/ui/modules/Leaderboard.tsx (7 hunks)
Additional comments not posted (6)
client/src/ui/modules/Leaderboard.tsx (6)
35-36
: LGTM!The new imports for FontAwesome icons and Tooltip components are appropriate for the new features.
The code changes are approved.
Also applies to: 43-44
56-66
: LGTM!The
TabList
component is implemented correctly and improves the readability and maintainability of the code.The code changes are approved.
68-81
: LGTM!The
TabContent
component is implemented correctly and improves the readability and maintainability of the code.The code changes are approved.
129-138
: LGTM!The new logic for calculating total buy-in and winning pool is implemented correctly. The
gamesWithWinnings
variable is correctly created to iterate over the sorted games and append the calculated potential winnings to each game object.The code changes are approved.
Also applies to: 145-153
Line range hint
287-304
: LGTM!The modification to include the
potentialWinnings
property in thegame
object is implemented correctly and ensures that the potential winnings are displayed for each player.The code changes are approved.
129-138
: Refactor the distribution logic for better readability and maintainability.Consider using a mapping for the distribution percentages.
Apply this diff to refactor the distribution logic:
const distributionPercentages = [0.4, 0.25, 0.15, 0.1, 0.1]; const gamesWithWinnings = useMemo(() => { return sortedGames.map((game, index) => { let potentialWinnings = 0; if (index < distributionPercentages.length) { potentialWinnings = winningPool * distributionPercentages[index]; } return { ...game, potentialWinnings, isOver: () => game.over }; }); }, [sortedGames, winningPool]);Likely invalid or redundant comment.
Fix #18
Key changes:
Summary by CodeRabbit
Summary by CodeRabbit
New Features
TooltipProvider
to enhance UI with tooltip functionality.buyIn
property to the game class for improved gameplay mechanics.Bug Fixes
Chores