Repository: edtan094/poker-tracker
Pull request #32: Make enter new game easier
Author: login: edtan094
Created: 2025-04-01T22:13:53Z | Merged: 2025-04-01T22:31:40Z

-made a toggle that allows to change the values from dollar to chip amounts and vice versa
-updated styling and new messages for total buyins in chips and dollars, and missing gains

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Enhanced game interface displays buy-ins and gains with automatic conversion between chips and dollars.
  - Introduced a settings panel to toggle between chip and dollar modes with adjustable conversion rates.
  - Updated the player submission form with a toggle for new or existing players and a streamlined input layout.
  - Added clear user messaging for gains discrepancies.
  
- **Refactor**
  - Simplified player data handling by removing redundant fields for buy-ins and gains.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->


Diff:
diff --git a/apps/web/src/app/(navigation)/games/components/GameTable.tsx b/apps/web/src/app/(navigation)/games/components/GameTable.tsx
index e8e85ea..7ea4f63 100644
--- a/apps/web/src/app/(navigation)/games/components/GameTable.tsx
+++ b/apps/web/src/app/(navigation)/games/components/GameTable.tsx
@@ -12,33 +12,63 @@ import {
 import { Input } from "@/components/ui/input";
 import { Player } from "@prisma/client";
 import { debounce } from "lodash";
+import { Trash2 } from "lucide-react";
 
 type GameTableProps = {
   players: Player[];
   handleDelete: (index: number) => void;
   setPlayers: React.Dispatch<React.SetStateAction<Player[]>>;
+  chipMode: boolean;
+  chipsPerBuyIn: number;
+  dollarPerBuyIn: number;
 };
 
 export default function GameTable({
   players,
   handleDelete,
   setPlayers,
+  chipMode,
+  chipsPerBuyIn,
+  dollarPerBuyIn,
 }: GameTableProps) {
+  const [gainsInputs, setGainsInputs] = useState<string[]>(
+    players.map((p) => {
+      if (p.gains) {
+        return p.gains?.toString();
+      }
+      return "";
+    })
+  );
+
   const debouncedUpdate = useCallback(
     debounce((newPlayers) => {
       localStorage.setItem("players", JSON.stringify(newPlayers));
       setPlayers(newPlayers);
     }, 500),
-    []
+    [setPlayers]
   );
 
-  const handleChange = (index: number, field: keyof Player, value: string) => {
-    setPlayers((prevPlayers) => {
-      const newPlayers = prevPlayers.map((player, i) =>
+  const convertToDollars = (chips: number) =>
+    (chips / chipsPerBuyIn) * dollarPerBuyIn;
+
+  const convertToChips = (dollars: number) =>
+    (dollars / dollarPerBuyIn) * chipsPerBuyIn;
+
+  const handleChange = (
+    index: number,
+    field: "buyIns" | "gains",
+    rawValue: string
+  ) => {
+    const parsed = parseFloat(rawValue);
+    const numericValue = isNaN(parsed) ? 0 : parsed;
+    const converted = chipMode ? convertToDollars(numericValue) : numericValue;
+
+    setPlayers((prev) => {
+      const newPlayers = prev.map((player, i) =>
         i === index
           ? {
               ...player,
-              [field]: (field === "buyIns" && parseFloat(value)) || 0,
+              [field]: converted,
             }
           : player
       );
@@ -49,21 +79,55 @@ export default function GameTable({
   };
 
   const handleChangeGains = (index: number, value: string) => {
-    if (/^-?\d*\.?\d*$/.test(value) || value === "") {
-      setPlayers((prevPlayers) => {
-        const newPlayers = prevPlayers.map((player, i) =>
-          i === index
-            ? {
-                ...player,
-                gains: value,
-              }
-            : player
-        );
+    if (!/^[-]?\d*\.?\d*$/.test(value)) return;
+
+    setGainsInputs((prev) => {
+      const newInputs = [...prev];
+      newInputs[index] = value;
+      return newInputs;
+    });
 
+    const updatePlayerGains = (gainValue: number) => {
+      setPlayers((prevPlayers) => {
+        const newPlayers = [...prevPlayers];
+        newPlayers[index] = {
+          ...newPlayers[index],
+          gains: gainValue,
+        };
         debouncedUpdate(newPlayers);
         return newPlayers;
       });
+    };
+
+    const parsed = parseFloat(value);
+    if (!isNaN(parsed)) {
+      const dollarValue = chipMode
+        ? (parsed / chipsPerBuyIn) * dollarPerBuyIn
+        : parsed;
+
+      updatePlayerGains(dollarValue);
     }
+    if (isNaN(parsed) && value !== "-" && value !== "-." && value !== ".") {
+      updatePlayerGains(0);
+    }
+  };
+
+  useEffect(() => {
+    setGainsInputs(() => {
+      return players.map((p) => {
+        if (!p.gains) return "";
+        return chipMode
+          ? ((p.gains / dollarPerBuyIn) * chipsPerBuyIn).toString()
+          : p.gains.toString();
+      });
+    });
+  }, [players, chipMode, chipsPerBuyIn, dollarPerBuyIn]);
+
+  const displayBuyIns = (player: Player) => {
+    if (!player.buyIns) return 0;
+    return chipMode
+      ? convertToChips(player.buyIns).toString()
+      : player.buyIns.toString();
   };
 
   return (
@@ -71,48 +135,55 @@ export default function GameTable({
       <TableHeader>
         <TableRow>
           <TableHead>Player</TableHead>
-          <TableHead>Buy Ins</TableHead>
-          <TableHead>Gains</TableHead>
+          <TableHead>Buy Ins {chipMode ? "(chips)" : "(dollars)"}</TableHead>
+          <TableHead>Gains {chipMode ? "(chips)" : "(dollars)"}</TableHead>
           <TableHead>Actions</TableHead>
         </TableRow>
       </TableHeader>
       <TableBody>
-        {players.map((player, index) => (
-          <TableRow key={index}>
-            <TableCell>
-              <Input
-                type="text"
-                value={player.name}
-                onChange={(e) => handleChange(index, "name", e.target.value)}
-                className="border p-1 w-full"
-              />
-            </TableCell>
-            <TableCell>
-              <Input
-                type="text"
-                inputMode="decimal"
-                value={player.buyIns.toString()}
-                onChange={(e) => handleChange(index, "buyIns", e.target.value)}
-                className="border p-1 w-full"
-              />
-            </TableCell>
-            <TableCell>
-              <Input
-                type="text"
-                value={player.gains === 0 ? "" : player.gains.toString()}
-                onChange={(e) =>
-                  handleChangeGains(index, e.target.value.toString())
-                }
-                className="border p-1 w-full"
-              />
-            </TableCell>
-            <TableCell>
-              <Button variant="destructive" onClick={() => handleDelete(index)}>
-                Delete
-              </Button>
-            </TableCell>
-          </TableRow>
-        ))}
+        {players.map((player, index) => {
+          return (
+            <TableRow key={player.id}>
+              <TableCell className=" p-2">
+                <p>{player.name}</p>
+              </TableCell>
+              <TableCell className=" p-2">
+                <Input
+                  type="number"
+                  value={displayBuyIns(player)}
+                  onChange={(e) =>
+                    handleChange(index, "buyIns", e.target.value)
+                  }
+                  className="border p-1 w-full"
+                />
+              </TableCell>
+              <TableCell className=" p-2">
+                <Input
+                  type="text"
+                  value={gainsInputs[index]}
+                  onChange={(e) => handleChangeGains(index, e.target.value)}
+                />
+              </TableCell>
+              <TableCell>
+                <Button
+                  variant="ghost"
+                  size="icon"
+                  className="text-red-500 hover:bg-red-100 md:hidden"
+                  onClick={() => handleDelete(index)}
+                >
+                  <Trash2 className="w-4 h-4" />
+                </Button>
+                <Button
+                  variant="destructive"
+                  className="hidden md:inline-flex"
+                  onClick={() => handleDelete(index)}
+                >
+                  Delete
+                </Button>
+              </TableCell>
+            </TableRow>
+          );
+        })}
       </TableBody>
     </Table>
   );
diff --git a/apps/web/src/app/(navigation)/games/new-game/component/GameSettings.tsx b/apps/web/src/app/(navigation)/games/new-game/component/GameSettings.tsx
new file mode 100644
index 0000000..789bddd
--- /dev/null
+++ b/apps/web/src/app/(navigation)/games/new-game/component/GameSettings.tsx
@@ -0,0 +1,60 @@
+"use client";
+import { Label } from "@/components/ui/label";
+import { Input } from "@/components/ui/input";
+import { Switch } from "@/components/ui/switch";
+
+type GameSettingsProps = {
+  chipMode: boolean;
+  setChipMode: (v: boolean) => void;
+  chipsPerBuyIn: number;
+  setChipsPerBuyIn: (v: number) => void;
+  dollarPerBuyIn: number;
+  setDollarPerBuyIn: (v: number) => void;
+};
+
+export default function GameSettings({
+  chipMode,
+  setChipMode,
+  chipsPerBuyIn,
+  setChipsPerBuyIn,
+  dollarPerBuyIn,
+  setDollarPerBuyIn,
+}: GameSettingsProps) {
+  return (
+    <div className=" flex justify-center">
+      <div className="mb-6 space-y-4">
+        <div className="flex items-center space-x-2">
+          <Switch
+            id="toggle-chip-mode"
+            checked={chipMode}
+            onCheckedChange={setChipMode}
+          />
+          <Label htmlFor="toggle-chip-mode">
+            {chipMode ? "Chip Mode" : "Dollar Mode"}
+          </Label>
+        </div>
+
+        <div className="flex items-center gap-4">
+          <div>
+            <Label>Chips Per Buy-In</Label>
+            <Input
+              type="number"
+              min={1}
+              value={chipsPerBuyIn}
+              onChange={(e) => setChipsPerBuyIn(+e.target.value)}
+            />
+          </div>
+          <div>
+            <Label>Dollar Per Buy-In</Label>
+            <Input
+              type="number"
+              min={1}
+              value={dollarPerBuyIn}
+              onChange={(e) => setDollarPerBuyIn(+e.target.value)}
+            />
+          </div>
+        </div>
+      </div>
+    </div>
+  );
+}
diff --git a/apps/web/src/app/(navigation)/games/new-game/component/SubmitPlayerForm.tsx b/apps/web/src/app/(navigation)/games/new-game/component/SubmitPlayerForm.tsx
index d53c63d..4665fd5 100644
--- a/apps/web/src/app/(navigation)/games/new-game/component/SubmitPlayerForm.tsx
+++ b/apps/web/src/app/(navigation)/games/new-game/component/SubmitPlayerForm.tsx
@@ -12,6 +12,7 @@ import {
   SelectTrigger,
   SelectValue,
 } from "@/components/ui/select";
+import { Switch } from "@/components/ui/switch";
 
 const initialState: ActionResponse = {
   success: false,
@@ -26,6 +27,7 @@ type SubmitPlayerFormProps = {
   isPending: boolean;
   state: ActionResponse;
   setAllPlayers: (players: Player[]) => void;
+  toggleExistingOrNewPlayer: () => void;
 };
 
 export default function SubmitPlayerForm({
@@ -36,6 +38,7 @@ export default function SubmitPlayerForm({
   isPending,
   state,
   setAllPlayers,
+  toggleExistingOrNewPlayer,
 }: SubmitPlayerFormProps) {
   const [existingPlayerId, setExistingPlayerId] = useState("");
 
@@ -49,8 +52,6 @@ export default function SubmitPlayerForm({
             {
               id: state.data?.id,
               name: state.data?.name,
-              buyIns: parseFloat(state.data?.buyIns) || 0,
-              gains: parseFloat(state.data?.gains) || 0,
             },
           ])
         );
@@ -59,8 +60,6 @@ export default function SubmitPlayerForm({
           {
             id: state.data?.id,
             name: state.data?.name,
-            buyIns: parseFloat(state.data?.buyIns) || 0,
-            gains: parseFloat(state.data?.gains) || 0,
           },
         ];
       });
@@ -69,9 +68,18 @@ export default function SubmitPlayerForm({
   }, [state]);
 
   return (
-    <form action={action}>
-      <div className="grid gap-4 py-4">
-        <div className="grid grid-cols-4 items-center gap-4">
+    <div className=" flex justify-center">
+      <form action={action} className="mb-6 space-y-4 w-full md:w-[360px]">
+        <div className="flex items-center space-x-2">
+          <Label htmlFor="newOrExistingPlayer" className="text-right">
+            {isNewPlayer ? "New Player" : "Existing Player"}
+          </Label>
+          <Switch
+            onCheckedChange={toggleExistingOrNewPlayer}
+            checked={!isNewPlayer}
+          />
+        </div>
+        <div className="flex items-center space-x-2">
           <Label htmlFor="name" className="text-right">
             Name
           </Label>
@@ -99,61 +107,23 @@ export default function SubmitPlayerForm({
             </p>
           )}
         </div>
-        <div className="grid grid-cols-4 items-center gap-4">
-          <Label htmlFor="buyIns" className="text-right">
-            Buy Ins
-          </Label>
-          <Input
-            id="buyIns"
-            type="number"
-            name="buyIns"
-            required
-            className="col-span-3 md:w-1/2"
-            placeholder="Enter Buy Ins"
-            defaultValue={state.inputs?.buyIns}
-          />
-          {state?.errors?.buyIns && (
-            <p id="streetAddress-error" className="text-sm text-red-500">
-              {state.errors.buyIns[0]}
-            </p>
-          )}
-        </div>
-        <div className="grid grid-cols-4 items-center gap-4">
-          <Label htmlFor="gains" className="text-right">
-            <span>Gains</span>
-          </Label>
-          <Input
-            id="gains"
-            type="text"
-            name="gains"
-            className="col-span-3 md:w-1/2"
-            pattern="-?[0-9]*\.?[0-9]*"
-            placeholder="Enter Gains"
-            defaultValue={state.inputs?.gains}
-          />
-          {state?.errors?.gains && (
-            <p id="streetAddress-error" className="text-sm text-red-500">
-              {state.errors.gains[0]}
-            </p>
+        <div className="flex justify-between">
+          <Button variant="default" type="submit" disabled={isPending}>
+            {isPending ? "Submitting..." : "Submit"}
+          </Button>
+
+          {state.message && (
+            <>
+              {state.success ? (
+                <p className="text-center text-primary">{state.message}</p>
+              ) : (
+                <p className="text-center text-red-500">{state.message}</p>
+              )}
+            </>
           )}
         </div>
-      </div>
-      <div className="flex justify-between">
-        <Button variant="default" type="submit" disabled={isPending}>
-          {isPending ? "Submitting..." : "Submit"}
-        </Button>
-
-        {state.message && (
-          <>
-            {state.success ? (
-              <p className="text-center text-primary">{state.message}</p>
-            ) : (
-              <p className="text-center text-red-500">{state.message}</p>
-            )}
-          </>
-        )}
-      </div>
-    </form>
+      </form>
+    </div>
   );
 }
 
diff --git a/apps/web/src/app/(navigation)/games/new-game/lib/calculateMissingGains.ts b/apps/web/src/app/(navigation)/games/new-game/lib/calculateMissingGains.ts
new file mode 100644
index 0000000..c1f3bdf
--- /dev/null
+++ b/apps/web/src/app/(navigation)/games/new-game/lib/calculateMissingGains.ts
@@ -0,0 +1,46 @@
+import { Player } from "@prisma/client";
+
+export const showMissingGainsMessage = (
+  players: Player[],
+  chipMode: boolean,
+  dollarPerBuyIn: number,
+  chipsPerBuyIn: number
+) => {
+  const totalGains = players.reduce((acc, player) => {
+    if (player.gains === undefined) {
+      return acc;
+    }
+    return acc + player.gains;
+  }, 0);
+
+  if (totalGains > 0) {
+    if (chipMode) {
+      return (
+        "You have an excess of " +
+        Math.abs(totalGains * (chipsPerBuyIn / dollarPerBuyIn)) +
+        " in chips. Please check your inputs."
+      );
+    }
+    return (
+      "You have an excess of " +
+      totalGains +
+      " in gains. Please check your inputs."
+    );
+  }
+
+  if (totalGains < 0) {
+    if (chipMode) {
+      return (
+        "You are missing " +
+        Math.abs(totalGains * (chipsPerBuyIn / dollarPerBuyIn)) +
+        " in chips. Please check your inputs."
+      );
+    }
+    return (
+      "You are missing " +
+      Math.abs(totalGains) +
+      " in gains. Please check your inputs."
+    );
+  }
+  return null;
+};
diff --git a/apps/web/src/app/(navigation)/games/new-game/page.tsx b/apps/web/src/app/(navigation)/games/new-game/page.tsx
index 8f9f15c..e01c6b1 100644
--- a/apps/web/src/app/(navigation)/games/new-game/page.tsx
+++ b/apps/web/src/app/(navigation)/games/new-game/page.tsx
@@ -1,13 +1,13 @@
 "use client";
 import GameTable from "../components/GameTable";
 import { Button } from "@/components/ui/button";
-import { useActionState, useEffect, useState } from "react";
-import { Label } from "@/components/ui/label";
+import { useActionState, useEffect, useMemo, useState } from "react";
 import { createGame } from "@/app/actions/GameActions";
 import { getPlayers, submitPlayer } from "@/app/actions/PlayerActions";
-import { Switch } from "@/components/ui/switch";
 import { Player } from "@prisma/client";
 import SubmitPlayerForm from "./component/SubmitPlayerForm";
+import GameSettings from "./component/GameSettings";
+import { showMissingGainsMessage } from "./lib/calculateMissingGains";
 
 export type UserFormData = {
   name: string;
@@ -24,13 +24,9 @@ export type ActionResponse = {
   data?: {
     id: string;
     name: string;
-    buyIns?: string | undefined;
-    gains?: string | undefined;
   };
   inputs?: {
     name: string;
-    buyIns?: string | undefined;
-    gains?: string | undefined;
   };
 };
 
@@ -46,6 +42,9 @@ export default function NewGamePage() {
   const [isNewPlayer, setIsNewPlayer] = useState(true);
   const [loading, setIsLoading] = useState(false);
   const [error, setError] = useState("");
+  const [chipMode, setChipMode] = useState(true);
+  const [chipsPerBuyIn, setChipsPerBuyIn] = useState(500);
+  const [dollarPerBuyIn, setDollarPerBuyIn] = useState(5);
 
   const toggleExistingOrNewPlayer = () => {
     setIsNewPlayer(!isNewPlayer);
@@ -75,7 +74,12 @@ export default function NewGamePage() {
     }
   };
 
-  const totalBuyIns = players.reduce((acc, player) => acc + player.buyIns, 0);
+  const totalBuyIns = players.reduce((acc, player) => {
+    if (player.buyIns === undefined) {
+      return acc;
+    }
+    return acc + player.buyIns;
+  }, 0);
 
   useEffect(() => {
     async function fetchAllPlayers() {
@@ -99,29 +103,45 @@ export default function NewGamePage() {
     }
   }, []);
 
+  const missingGainsMessage = useMemo(() => {
+    return showMissingGainsMessage(
+      players,
+      chipMode,
+      dollarPerBuyIn,
+      chipsPerBuyIn
+    );
+  }, [players, chipMode, dollarPerBuyIn, chipsPerBuyIn]);
+
+  const totalBuyInsInChips = (totalBuyIns / dollarPerBuyIn) * chipsPerBuyIn;
+
   return (
     <div>
+      <div className=" flex justify-center">
+        <h2 className=" font-bold text-3xl">New Game</h2>
+      </div>
       <div className="mb-4 border-b pb-4">
-        <div className="flex justify-center items-center">
-          <div className="flex items-center space-x-2">
-            <Switch
-              onCheckedChange={toggleExistingOrNewPlayer}
-              checked={!isNewPlayer}
-            />
-            <Label htmlFor="newOrExistingPlayer">
-              {isNewPlayer ? "New Player" : "Existing Player"}
-            </Label>
-          </div>
+        <div className=" my-8">
+          <SubmitPlayerForm
+            setPlayers={setPlayers}
+            isNewPlayer={isNewPlayer}
+            allPlayers={allPlayers}
+            action={action}
+            isPending={isPending}
+            state={state}
+            setAllPlayers={setAllPlayers}
+            toggleExistingOrNewPlayer={toggleExistingOrNewPlayer}
+          />
+        </div>
+        <div className=" my-8">
+          <GameSettings
+            chipMode={chipMode}
+            setChipMode={setChipMode}
+            chipsPerBuyIn={chipsPerBuyIn}
+            setChipsPerBuyIn={setChipsPerBuyIn}
+            dollarPerBuyIn={dollarPerBuyIn}
+            setDollarPerBuyIn={setDollarPerBuyIn}
+          />
         </div>
-        <SubmitPlayerForm
-          setPlayers={setPlayers}
-          isNewPlayer={isNewPlayer}
-          allPlayers={allPlayers}
-          action={action}
-          isPending={isPending}
-          state={state}
-          setAllPlayers={setAllPlayers}
-        />
       </div>
 
       <div>
@@ -129,12 +149,22 @@ export default function NewGamePage() {
           players={players}
           handleDelete={handleDelete}
           setPlayers={setPlayers}
+          chipMode={chipMode}
+          chipsPerBuyIn={chipsPerBuyIn}
+          dollarPerBuyIn={dollarPerBuyIn}
         />
       </div>
-      <div className=" border-t mt-4 pt-4">
-        <p>Total Buy Ins: ${totalBuyIns}</p>
+      <div className=" border-t mt-4 pt-4 text-green-500">
+        <p className=" mb-2">Total Buy Ins in $$$: ${totalBuyIns}</p>
+        <p className=" mb-2">
+          Total Buy Ins in Chips: {totalBuyInsInChips} Chips
+        </p>
+        {missingGainsMessage && (
+          <p className="text-red-500">{missingGainsMessage}</p>
+        )}
       </div>
-      <div className="mt-4">
+
+      <div className=" mt-4">
         <Button
           variant="default"
           type="button"
diff --git a/apps/web/src/app/actions/PlayerActions.ts b/apps/web/src/app/actions/PlayerActions.ts
index 768e5a7..b1a2bf2 100644
--- a/apps/web/src/app/actions/PlayerActions.ts
+++ b/apps/web/src/app/actions/PlayerActions.ts
@@ -40,8 +40,6 @@ const playerSchema = z
   .object({
     name: z.string().min(1, "Name is required").nullable().optional(),
     existingPlayerId: z.string().uuid().nullable().optional(),
-    buyIns: z.string().regex(/^\d+(\.\d{1,2})?$/, "Invalid buy-in amount"),
-    gains: z.string().regex(/^-?\d+(\.\d{1,2})?$/, "Invalid gains amount"),
   })
   .refine((data) => data.name || data.existingPlayerId, {
     message: "Either name or existingPlayerId is required",
@@ -56,8 +54,6 @@ export async function submitPlayer(
     const rawData = {
       name: formData.get("name") as string,
       existingPlayerId: formData.get("existingPlayerId") as string,
-      buyIns: formData.get("buyIns") as string,
-      gains: formData.get("gains") as string,
     };
 
     const validatedData = playerSchema.safeParse(rawData);
@@ -86,8 +82,6 @@ export async function submitPlayer(
       return {
         data: {
           ...player,
-          buyIns: validatedData.data.buyIns,
-          gains: validatedData.data.gains,
         },
         success: true,
         message: "User saved successfully!",


Reviews:
user: login: coderabbitai[bot]
body: **Actionable comments posted: 2**

<details>
<summary>🧹 Nitpick comments (6)</summary><blockquote>

<details>
<summary>apps/web/src/app/(navigation)/games/new-game/component/SubmitPlayerForm.tsx (1)</summary><blockquote>

`116-122`: **Remove unnecessary Fragment.**

The Fragment wrapper is redundant since it only contains one child element. This was also flagged by static analysis.

```diff
-          {state.message && (
-            <>
-              {state.success ? (
-                <p className="text-center text-primary">{state.message}</p>
-              ) : (
-                <p className="text-center text-red-500">{state.message}</p>
-              )}
-            </>
+          {state.message && (
+            state.success ? (
+              <p className="text-center text-primary">{state.message}</p>
+            ) : (
+              <p className="text-center text-red-500">{state.message}</p>
+            )
+          )}
```

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 Biome (1.9.4)</summary>

[error] 116-122: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment


(lint/complexity/noUselessFragments)

</details>

</details>

</blockquote></details>
<details>
<summary>apps/web/src/app/(navigation)/games/new-game/lib/calculateMissingGains.ts (1)</summary><blockquote>

`16-44`: **Improve numeric formatting in messages.**

The message displays raw numbers that might include many decimal places, which can be confusing to users.

Consider using `toFixed(2)` or a similar formatting function to limit decimal places in the displayed amounts:

```diff
-        Math.abs(totalGains * (chipsPerBuyIn / dollarPerBuyIn)) +
+        Math.abs(totalGains * (chipsPerBuyIn / dollarPerBuyIn)).toFixed(2) +
```

Similarly for other numeric outputs in the messages.

</blockquote></details>
<details>
<summary>apps/web/src/app/(navigation)/games/new-game/page.tsx (1)</summary><blockquote>

`164-164`: **Redundant paragraph tag inside paragraph.**

There's a nested `<p>` tag inside another `<p>` tag which is not valid HTML.

```diff
-        <p className=" text-red-500">
-          {missingGainsMessage && (
-            <p className="text-red-500">{missingGainsMessage}</p>
-          )}
-        </p>
+        {missingGainsMessage && (
+          <p className="text-red-500">{missingGainsMessage}</p>
+        )}
```

</blockquote></details>
<details>
<summary>apps/web/src/app/(navigation)/games/components/GameTable.tsx (3)</summary><blockquote>

`81-117`: **Improve handleChangeGains function**

The function contains some complex validation and state updates that could be refactored for better maintainability.


Consider extracting shared logic between the two conditional blocks (lines 91-105 and 106-116) to reduce duplication. Also, the validation regex could be more explicit about what it's checking.

```diff
 const handleChangeGains = (index: number, value: string) => {
   if (!/^[-]?\d*\.?\d*$/.test(value)) return;

   setGainsInputs((prev) => {
     const newInputs = [...prev];
     newInputs[index] = value;
     return newInputs;
   });

+  // Helper function to update player gains
+  const updatePlayerGains = (gainValue: number) => {
+    setPlayers((prevPlayers) => {
+      const newPlayers = [...prevPlayers];
+      newPlayers[index] = {
+        ...newPlayers[index],
+        gains: gainValue,
+      };
+      debouncedUpdate(newPlayers);
+      return newPlayers;
+    });
+  };
+
   const parsed = parseFloat(value);
   if (!isNaN(parsed)) {
     const dollarValue = chipMode
       ? (parsed / chipsPerBuyIn) * dollarPerBuyIn
       : parsed;
-
-    setPlayers((prevPlayers) => {
-      const newPlayers = [...prevPlayers];
-      newPlayers[index] = {
-        ...newPlayers[index],
-        gains: dollarValue,
-      };
-      debouncedUpdate(newPlayers);
-      return newPlayers;
-    });
+    updatePlayerGains(dollarValue);
   }
   if (isNaN(parsed) && value !== "-" && value !== "-." && value !== ".") {
-    setPlayers((prevPlayers) => {
-      const newPlayers = [...prevPlayers];
-      newPlayers[index] = {
-        ...newPlayers[index],
-        gains: 0,
-      };
-      debouncedUpdate(newPlayers);
-      return newPlayers;
-    });
+    updatePlayerGains(0);
   }
 };
```

---

`141-189`: **Extract displayBuyIns outside the render loop**

The displayBuyIns function is defined inside the map function, which could impact performance as it will be recreated on each render.


Consider moving this function outside the render loop:

```diff
+ const getDisplayBuyIns = (player: Player) => {
+   if (!player.buyIns) return 0;
+   return chipMode
+     ? convertToChips(player.buyIns).toString()
+     : player.buyIns.toString();
+ };

 return (
   <Table>
     {/* ... */}
     <TableBody>
       {players.map((player, index) => {
-        const displayBuyIns = () => {
-          if (!player.buyIns) return 0;
-          return chipMode
-            ? convertToChips(player.buyIns).toString()
-            : player.buyIns.toString();
-        };
         return (
           <TableRow key={player.id}>
             {/* ... */}
             <TableCell className=" p-2">
               <Input
                 type="number"
-                value={displayBuyIns()}
+                value={getDisplayBuyIns(player)}
                 onChange={(e) =>
                   handleChange(index, "buyIns", e.target.value)
                 }
                 className="border p-1 w-full"
               />
             </TableCell>
             {/* ... */}
           </TableRow>
         );
       })}
     </TableBody>
   </Table>
 );
```

---

`166-166`: **Consider showing "0" instead of empty string**

Clearing the input when the value is "0" might be confusing for users - they may not know if it's actually zero or empty.


```diff
- value={gainsInputs[index] === "0" ? "" : gainsInputs[index]}
+ value={gainsInputs[index]}
```

Let users see the actual "0" value for clarity, unless there's a specific UI requirement to keep it empty.

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between f62f657527dab444b11da0a0f93fb3a341d744f9 and 150b227735ceac7820180e0c1aa5bda2634dfe09.

</details>

<details>
<summary>📒 Files selected for processing (6)</summary>

* `apps/web/src/app/(navigation)/games/components/GameTable.tsx` (2 hunks)
* `apps/web/src/app/(navigation)/games/new-game/component/GameSettings.tsx` (1 hunks)
* `apps/web/src/app/(navigation)/games/new-game/component/SubmitPlayerForm.tsx` (5 hunks)
* `apps/web/src/app/(navigation)/games/new-game/lib/calculateMissingGains.ts` (1 hunks)
* `apps/web/src/app/(navigation)/games/new-game/page.tsx` (4 hunks)
* `apps/web/src/app/actions/PlayerActions.ts` (0 hunks)

</details>

<details>
<summary>💤 Files with no reviewable changes (1)</summary>

* apps/web/src/app/actions/PlayerActions.ts

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Definitions (1)</summary>

<details>
<summary>apps/web/src/app/(navigation)/games/new-game/page.tsx (3)</summary><blockquote>

<details>
<summary>apps/web/src/app/(navigation)/games/new-game/lib/calculateMissingGains.ts (1)</summary>

* `showMissingGainsMessage` (3-45)

</details>
<details>
<summary>apps/web/src/app/(navigation)/games/new-game/component/GameSettings.tsx (1)</summary>

* `GameSettings` (15-58)

</details>
<details>
<summary>apps/web/src/app/(navigation)/games/components/GameTable.tsx (1)</summary>

* `GameTable` (26-193)

</details>

</blockquote></details>

</details><details>
<summary>🪛 Biome (1.9.4)</summary>

<details>
<summary>apps/web/src/app/(navigation)/games/new-game/component/SubmitPlayerForm.tsx</summary>

[error] 116-122: Avoid using unnecessary Fragment.

A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment


(lint/complexity/noUselessFragments)

</details>

</details>

</details>

<details>
<summary>🔇 Additional comments (26)</summary><blockquote>

<details>
<summary>apps/web/src/app/(navigation)/games/new-game/component/SubmitPlayerForm.tsx (5)</summary>

`15-15`: **Added UI component import.**

The Switch component has been imported to support the new toggle functionality between existing and new player modes.

---

`30-30`: **Added new prop for player mode toggle.**

The new prop `toggleExistingOrNewPlayer` allows the parent component to handle toggling between existing and new player modes.

---

`41-41`: **Destructured new toggle function from props.**

This correctly integrates the new toggle functionality into the component.

---

`71-81`: **Improved UI with player mode toggle.**

The form has been enhanced with a Switch component that toggles between New Player and Existing Player modes, making the interface more intuitive.

---

`110-114`: **Improved form layout with responsive design.**

Button and message layout has been improved with better spacing and responsiveness.

</details>
<details>
<summary>apps/web/src/app/(navigation)/games/new-game/lib/calculateMissingGains.ts (2)</summary>

`1-8`: **New utility function for gains validation.**

This function helps track and validate the balance of gains in the game, supporting both chip and dollar modes.

---

`9-14`: **Safe accumulation of player gains.**

The function safely handles undefined gains by skipping them in the accumulation, preventing potential NaN issues.

</details>
<details>
<summary>apps/web/src/app/(navigation)/games/new-game/component/GameSettings.tsx (2)</summary>

`1-13`: **Well-defined props interface for game settings.**

The component has a clear, type-safe interface that properly defines all the necessary props for controlling game settings.

---

`15-36`: **Clean UI implementation for mode toggle.**

The component provides a well-structured interface for toggling between chip and dollar modes with appropriate labeling.

</details>
<details>
<summary>apps/web/src/app/(navigation)/games/new-game/page.tsx (9)</summary>

`4-10`: **Added necessary imports for new functionality.**

The imports have been updated to support the new chip/dollar conversion and game settings features.

---

`45-47`: **Added state variables for game settings.**

These state variables manage the chip mode and conversion ratios, providing the necessary data for the new features.

---

`77-82`: **Improved totalBuyIns calculation.**

The calculation now properly handles undefined buyIns values, preventing potential NaN issues.

---

`106-115`: **Added memoized message for missing gains.**

The memoization helps optimize performance by only recalculating when relevant values change. The function uses the utility created in calculateMissingGains.ts.

---

`119-121`: **Improved page title styling.**

The heading now has better alignment and styling.

---

`123-134`: **Updated SubmitPlayerForm integration.**

The player form now includes the toggle function and is positioned with appropriate spacing.

---

`135-144`: **Added GameSettings component.**

The new GameSettings component is integrated with proper props binding to manage chip/dollar mode and conversion ratios.

---

`152-154`: **Updated GameTable with conversion props.**

The GameTable component now receives the necessary props to handle chip/dollar conversion.

---

`157-166`: **Enhanced display of game totals.**

The UI now shows both dollar and chip totals, along with any validation messages for missing gains.

</details>
<details>
<summary>apps/web/src/app/(navigation)/games/components/GameTable.tsx (8)</summary>

`21-23`: **Good addition of chip conversion properties**

These new props provide the necessary configuration for the chip/dollar conversion functionality, making the component more flexible.

---

`30-32`: **LGTM - Props destructuring matches the interface**

The props destructuring correctly implements the interface defined above.

---

`34-41`: **Good initialization of gainsInputs state**

The initialization of gainsInputs state is properly derived from the existing player data, with appropriate handling for undefined values.

---

`48-48`: **Dependencies for debouncedUpdate callback**

The dependency array only includes `setPlayers`, but the callback also uses `localStorage`. Consider if this is intentional or if you should use a ref for `localStorage` access if it's meant to avoid recreating the function.

---

`51-56`: **Well-implemented conversion functions**

These utility functions provide clear logic for converting between chips and dollars based on the provided rates.

---

`57-79`: **Enhanced handleChange with field parameter**

Good implementation of the handleChange function that now handles multiple fields and performs conversion based on chipMode.

---

`119-128`: **Good synchronization of gainsInputs with player data**

The useEffect correctly keeps the gainsInputs state in sync with the players' gains and conversion parameters.

---

`135-136`: **Clear labeling for buy-ins and gains**

Good addition of dynamic labels that indicate whether values are in chips or dollars, improving user understanding.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-01T22:16:44Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 0**

<details>
<summary>🧹 Nitpick comments (4)</summary><blockquote>

<details>
<summary>apps/web/src/app/(navigation)/games/new-game/lib/calculateMissingGains.ts (4)</summary><blockquote>

`16-29`: **Consider using template literals and number formatting.**

The string concatenation could be replaced with template literals for better readability. Additionally, the chip calculation might produce floating-point numbers with many decimal places, which could be better presented with formatting.


```diff
  if (totalGains > 0) {
    if (chipMode) {
      return (
-        "You have an excess of " +
-        Math.abs(totalGains * (chipsPerBuyIn / dollarPerBuyIn)) +
-        " in chips. Please check your inputs."
+        `You have an excess of ${Math.abs(totalGains * (chipsPerBuyIn / dollarPerBuyIn)).toFixed(2)} in chips. Please check your inputs.`
      );
    }
    return (
-      "You have an excess of " +
-      totalGains +
-      " in gains. Please check your inputs."
+      `You have an excess of ${totalGains.toFixed(2)} in gains. Please check your inputs.`
    );
  }
```

---

`31-44`: **Consider using template literals and safeguarding against division by zero.**

Similar to the previous section, use template literals for better readability. Additionally, add a check to prevent division by zero in case dollarPerBuyIn is 0.


```diff
  if (totalGains < 0) {
    if (chipMode) {
+     const conversionRatio = dollarPerBuyIn === 0 ? 0 : chipsPerBuyIn / dollarPerBuyIn;
      return (
-        "You are missing " +
-        Math.abs(totalGains * (chipsPerBuyIn / dollarPerBuyIn)) +
-        " in chips. Please check your inputs."
+        `You are missing ${Math.abs(totalGains * conversionRatio).toFixed(2)} in chips. Please check your inputs.`
      );
    }
    return (
-      "You are missing " +
-      Math.abs(totalGains) +
-      " in gains. Please check your inputs."
+      `You are missing ${Math.abs(totalGains).toFixed(2)} in gains. Please check your inputs.`
    );
  }
```

---

`3-8`: **Input validation could be improved.**

The function lacks validation for the numeric inputs. Consider adding checks to ensure dollarPerBuyIn and chipsPerBuyIn are positive numbers.


```diff
export const showMissingGainsMessage = (
  players: Player[],
  chipMode: boolean,
  dollarPerBuyIn: number,
  chipsPerBuyIn: number
) => {
+  // Validate inputs
+  if (dollarPerBuyIn <= 0 || chipsPerBuyIn <= 0) {
+    console.warn('Invalid conversion rates: dollarPerBuyIn and chipsPerBuyIn must be positive');
+    return null;
+  }
+
  const totalGains = players.reduce((acc, player) => {
```

---

`1-46`: **Consider adding JSDoc comments for better documentation.**

Adding JSDoc comments would help other developers understand the purpose and usage of this function, especially detailing the expected shape of inputs and outputs.


```diff
import { Player } from "@prisma/client";

+/**
+ * Generates a message about missing or excess gains based on player data.
+ * @param players - Array of Player objects with gains property
+ * @param chipMode - Whether to display values in chips (true) or dollars (false)
+ * @param dollarPerBuyIn - Dollar amount per buy-in
+ * @param chipsPerBuyIn - Chip amount per buy-in
+ * @returns A message string if there's a discrepancy in gains, or null if balanced
+ */
export const showMissingGainsMessage = (
  players: Player[],
  chipMode: boolean,
  dollarPerBuyIn: number,
  chipsPerBuyIn: number
) => {
```

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 150b227735ceac7820180e0c1aa5bda2634dfe09 and b13338e0f721ad4e6c44b8132468ef04b1aef6fc.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `apps/web/src/app/(navigation)/games/new-game/component/GameSettings.tsx` (1 hunks)
* `apps/web/src/app/(navigation)/games/new-game/lib/calculateMissingGains.ts` (1 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* apps/web/src/app/(navigation)/games/new-game/component/GameSettings.tsx

</details>

<details>
<summary>🔇 Additional comments (2)</summary><blockquote>

<details>
<summary>apps/web/src/app/(navigation)/games/new-game/lib/calculateMissingGains.ts (2)</summary>

`9-14`: **The totalGains calculation correctly handles undefined values.**

The reduce function properly checks for undefined gains values and skips them in the calculation. This is a good defensive programming practice.

---

`45-46`: **Explicit return for balanced gains implements previous feedback correctly.**

The addition of an explicit return when totalGains is zero addresses the previous review comment. This ensures the function has a clear return value in all cases.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-01T22:21:58Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 0**

<details>
<summary>🧹 Nitpick comments (2)</summary><blockquote>

<details>
<summary>apps/web/src/app/(navigation)/games/new-game/page.tsx (1)</summary><blockquote>

`115-115`: **Consider handling edge case for zero dollarPerBuyIn.**

The current calculation could cause division by zero if `dollarPerBuyIn` is 0.

```diff
-const totalBuyInsInChips = (totalBuyIns / dollarPerBuyIn) * chipsPerBuyIn;
+const totalBuyInsInChips = dollarPerBuyIn === 0 ? 0 : (totalBuyIns / dollarPerBuyIn) * chipsPerBuyIn;
```

</blockquote></details>
<details>
<summary>apps/web/src/app/(navigation)/games/components/GameTable.tsx (1)</summary><blockquote>

`115-124`: **Consider handling possible division by zero.**

Similar to the issue in NewGamePage, there's a risk of division by zero if dollarPerBuyIn is 0.

```diff
return chipMode
-  ? ((p.gains / dollarPerBuyIn) * chipsPerBuyIn).toString()
+  ? (dollarPerBuyIn === 0 ? 0 : ((p.gains / dollarPerBuyIn) * chipsPerBuyIn)).toString()
  : p.gains.toString();
```

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between b13338e0f721ad4e6c44b8132468ef04b1aef6fc and 920e15e44194247bd3e9d04efda87d6bf356da17.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `apps/web/src/app/(navigation)/games/components/GameTable.tsx` (2 hunks)
* `apps/web/src/app/(navigation)/games/new-game/page.tsx` (4 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Definitions (1)</summary>

<details>
<summary>apps/web/src/app/(navigation)/games/new-game/page.tsx (3)</summary><blockquote>

<details>
<summary>apps/web/src/app/(navigation)/games/new-game/lib/calculateMissingGains.ts (1)</summary>

* `showMissingGainsMessage` (3-46)

</details>
<details>
<summary>apps/web/src/app/(navigation)/games/new-game/component/GameSettings.tsx (1)</summary>

* `GameSettings` (15-60)

</details>
<details>
<summary>apps/web/src/app/(navigation)/games/components/GameTable.tsx (1)</summary>

* `GameTable` (26-190)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>🔇 Additional comments (15)</summary><blockquote>

<details>
<summary>apps/web/src/app/(navigation)/games/new-game/page.tsx (7)</summary>

`4-4`: **Improved imports for new chip/dollar functionality.**

The imports for `useMemo`, `GameSettings`, and `showMissingGainsMessage` are correctly added to support the new functionality.



Also applies to: 9-10

---

`45-47`: **Good default values for game settings.**

The initial states are well-chosen with sensible defaults:
- `chipMode` defaults to `true` to show chip values first
- Default ratio of 500 chips per $5 (100:1) is a common poker chip valuation

---

`77-82`: **Improved null safety in totalBuyIns calculation.**

The updated calculation correctly handles undefined buyIns values, preventing potential NaN errors.

---

`106-113`: **Good use of useMemo for calculated message.**

Using `useMemo` prevents unnecessary recalculations of the missing gains message when unrelated state changes.

---

`135-144`: **Good implementation of GameSettings component.**

The `GameSettings` component is correctly implemented with all necessary props to manage the chip/dollar conversion functionality.

---

`152-154`: **Properly passed game settings to GameTable.**

The chip mode and conversion ratio properties are correctly passed to the GameTable component.

---

`157-164`: **Improved financial feedback with dual display.**

Showing both dollar and chip values gives users clear insight into their game finances. The error message for missing gains provides helpful guidance.

</details>
<details>
<summary>apps/web/src/app/(navigation)/games/components/GameTable.tsx (8)</summary>

`21-23`: **Properly typed GameTable props.**

The new properties for chip mode functionality are correctly typed in the GameTableProps interface.

---

`34-41`: **Well-implemented state for gains input display.**

The `gainsInputs` state allows for showing formatted values to users while maintaining proper data types in the actual player state.

---

`51-55`: **Clear conversion functions with correct formulas.**

The utility functions for converting between chips and dollars use the appropriate mathematical formulas.

---

`57-79`: **Improved field handling with type safety.**

The updated `handleChange` function now handles both buy-ins and gains with proper type checking, and correctly converts between chips and dollars.

---

`81-113`: **Robust input validation and state management.**

The `handleChangeGains` function:
1. Validates input with regex to only allow numeric values
2. Properly manages the display state separately from the actual data
3. Handles negative values and partial inputs (like "-" or ".")
4. Correctly converts between chips and dollars

---

`126-131`: **Consistent display formatting of buy-ins.**

The `displayBuyIns` function ensures consistent formatting of buy-in values based on the selected mode.

---

`138-139`: **Improved column headers with mode indicators.**

The table headers now clearly indicate whether values are displayed in chips or dollars.

---

`168-182`: **Good responsive design for delete buttons.**

The implementation shows a text button on larger screens and an icon button on mobile devices, improving the user experience across different device sizes.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: NONE
submitted_at: 2025-04-01T22:30:34Z

Review comments:
diff_hunk: @@ -0,0 +1,45 @@
+import { Player } from "@prisma/client";
+
+export const showMissingGainsMessage = (
+  players: Player[],
+  chipMode: boolean,
+  dollarPerBuyIn: number,
+  chipsPerBuyIn: number
+) => {
+  const totalGains = players.reduce((acc, player) => {
+    if (player.gains === undefined) {
+      return acc;
+    }
+    return acc + player.gains;
+  }, 0);
+
+  if (totalGains > 0) {
+    if (chipMode) {
+      return (
+        "You have an excess of " +
+        Math.abs(totalGains * (chipsPerBuyIn / dollarPerBuyIn)) +
+        " in chips. Please check your inputs."
+      );
+    }
+    return (
+      "You have an excess of " +
+      totalGains +
+      " in gains. Please check your inputs."
+    );
+  }
+
+  if (totalGains < 0) {
+    if (chipMode) {
+      return (
+        "You are missing " +
+        Math.abs(totalGains * (chipsPerBuyIn / dollarPerBuyIn)) +
+        " in chips. Please check your inputs."
+      );
+    }
+    return (
+      "You are missing " +
+      Math.abs(totalGains) +
+      " in gains. Please check your inputs."
+    );
+  }
+};
path: apps/web/src/app/(navigation)/games/new-game/lib/calculateMissingGains.ts
user: login: coderabbitai[bot]
body: _🛠️ Refactor suggestion_

**Function doesn't return anything when totalGains is zero.**

The function doesn't have an explicit return value when totalGains is exactly zero. This might lead to unexpected behavior in the UI.

```diff
  if (totalGains < 0) {
    // existing code...
  }
+ 
+ return null; // Explicit return when totalGains is zero
};
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **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.

`````suggestion
  if (totalGains < 0) {
    // existing code...
  }
  
  return null; // Explicit return when totalGains is zero
};
`````

</details>

<!-- suggestion_end -->

<!-- This is an auto-generated comment by CodeRabbit -->

✅ Addressed in commit b13338e
created_at: 2025-04-01T22:16:43Z
author_association: NONE
diff_hunk: @@ -0,0 +1,58 @@
+"use client";
+import { Label } from "@/components/ui/label";
+import { Input } from "@/components/ui/input";
+import { Switch } from "@/components/ui/switch";
+
+type GameSettingsProps = {
+  chipMode: boolean;
+  setChipMode: (v: boolean) => void;
+  chipsPerBuyIn: number;
+  setChipsPerBuyIn: (v: number) => void;
+  dollarPerBuyIn: number;
+  setDollarPerBuyIn: (v: number) => void;
+};
+
+export default function GameSettings({
+  chipMode,
+  setChipMode,
+  chipsPerBuyIn,
+  setChipsPerBuyIn,
+  dollarPerBuyIn,
+  setDollarPerBuyIn,
+}: GameSettingsProps) {
+  return (
+    <div className=" flex justify-center">
+      <div className="mb-6 space-y-4">
+        <div className="flex items-center space-x-2">
+          <Switch
+            id="toggle-chip-mode"
+            checked={chipMode}
+            onCheckedChange={setChipMode}
+          />
+          <Label htmlFor="toggle-chip-mode">
+            {chipMode ? "Chip Mode" : "Dollar Mode"}
+          </Label>
+        </div>
+
+        <div className="flex items-center gap-4">
+          <div>
+            <Label>Chips Per Buy-In</Label>
+            <Input
+              type="number"
+              value={chipsPerBuyIn}
+              onChange={(e) => setChipsPerBuyIn(+e.target.value)}
+            />
+          </div>
+          <div>
+            <Label>Dollar Per Buy-In</Label>
+            <Input
+              type="number"
+              value={dollarPerBuyIn}
+              onChange={(e) => setDollarPerBuyIn(+e.target.value)}
+            />
+          </div>
+        </div>
path: apps/web/src/app/(navigation)/games/new-game/component/GameSettings.tsx
user: login: coderabbitai[bot]
body: _🛠️ Refactor suggestion_

**Input validation for numeric inputs.**

The numeric inputs for chips and dollars per buy-in don't have validation for minimum values, which could lead to division by zero errors or other unexpected behavior if users enter zero or negative values.

```diff
            <Input
              type="number"
+             min="1"
              value={chipsPerBuyIn}
              onChange={(e) => setChipsPerBuyIn(+e.target.value)}
            />

            <Input
              type="number"
+             min="1"
              value={dollarPerBuyIn}
              onChange={(e) => setDollarPerBuyIn(+e.target.value)}
            />
```


<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **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.

`````suggestion
        <div className="flex items-center gap-4">
          <div>
            <Label>Chips Per Buy-In</Label>
            <Input
              type="number"
              min="1"
              value={chipsPerBuyIn}
              onChange={(e) => setChipsPerBuyIn(+e.target.value)}
            />
          </div>
          <div>
            <Label>Dollar Per Buy-In</Label>
            <Input
              type="number"
              min="1"
              value={dollarPerBuyIn}
              onChange={(e) => setDollarPerBuyIn(+e.target.value)}
            />
          </div>
        </div>
`````

</details>

<!-- suggestion_end -->

<!-- This is an auto-generated comment by CodeRabbit -->

✅ Addressed in commit b13338e
created_at: 2025-04-01T22:16:43Z
author_association: NONE

PR comments:
user: login: vercel[bot]
created_at: 2025-04-01T22:13:57Z
body: [vc]: #6XPp3O0ef7jTzx06fOCJXOrfpWJLd4JQZSNKgp4uqAY=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJwb2tlci10cmFja2VyIiwiaW5zcGVjdG9yVXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL2VkdGFuMDk0cy1wcm9qZWN0cy9wb2tlci10cmFja2VyLzY2VWFqOTh6eVlLblUzSk40eFgyTmZSOTNYaWoiLCJwcmV2aWV3VXJsIjoicG9rZXItdHJhY2tlci1naXQtbWFrZS1lbnRlci1uZXctZ2FtZS1lYXNpZXItZWR0YW4wOTRzLXByb2plY3RzLnZlcmNlbC5hcHAiLCJuZXh0Q29tbWl0U3RhdHVzIjoiREVQTE9ZRUQiLCJsaXZlRmVlZGJhY2siOnsicmVzb2x2ZWQiOjAsInVucmVzb2x2ZWQiOjAsInRvdGFsIjowLCJsaW5rIjoicG9rZXItdHJhY2tlci1naXQtbWFrZS1lbnRlci1uZXctZ2FtZS1lYXNpZXItZWR0YW4wOTRzLXByb2plY3RzLnZlcmNlbC5hcHAifSwicm9vdERpcmVjdG9yeSI6ImFwcHMvd2ViIn1dfQ==
**The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)

| Name | Status | Preview | Comments | Updated (UTC) |
| :--- | :----- | :------ | :------- | :------ |
| **poker-tracker** | ✅ Ready ([Inspect](https://vercel.com/edtan094s-projects/poker-tracker/66Uaj98zyYKnU3JN4xX2NfR93Xij)) | [Visit Preview](https://poker-tracker-git-make-enter-new-game-easier-edtan094s-projects.vercel.app) | 💬 [**Add feedback**](https://vercel.live/open-feedback/poker-tracker-git-make-enter-new-game-easier-edtan094s-projects.vercel.app?via=pr-comment-feedback-link) | Apr 1, 2025 10:29pm |


author_association: NONE
user: login: coderabbitai[bot]
created_at: 2025-04-01T22:14:00Z
body: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- walkthrough_start -->

## Walkthrough
This update adds chip/dollar conversion capabilities and new game settings to various components. In the game table, new properties and conversion logic are introduced for handling buy-ins and gains. A new `GameSettings` component and updates in the player submission form allow users to toggle modes and adjust ratios. The new functionality is integrated into the `NewGamePage` with state management and a memoized gains message. Additionally, the player action schema is simplified by removing buy-ins and gains.

## Changes

| File(s) | Change Summary |
|---------|----------------|
| `apps/web/src/app/(navigation)/games/components/GameTable.tsx` | Added `chipMode`, `chipsPerBuyIn`, and `dollarPerBuyIn` to `GameTableProps`; modified `handleChange` and `handleChangeGains` to convert inputs based on `chipMode`; added a `useEffect` to sync gains inputs. |
| `apps/web/src/app/(navigation)/games/new-game/component/GameSettings.tsx`<br>`apps/web/src/app/(navigation)/games/new-game/component/SubmitPlayerForm.tsx` | Introduced new `GameSettings` component for chip/dollar UI controls; updated `SubmitPlayerForm` with a new `Switch` component for toggling new/existing players and removed buy-ins and gains fields. |
| `apps/web/src/app/(navigation)/games/new-game/lib/calculateMissingGains.ts` | Added the `showMissingGainsMessage` function to compute and return messages about missing gains based on chip settings. |
| `apps/web/src/app/(navigation)/games/new-game/page.tsx` | Added new state variables (`chipMode`, `chipsPerBuyIn`, `dollarPerBuyIn`); integrated `GameSettings` and memoized gains message; updated calculations for total buy-ins in chips; refined overall layout. |
| `apps/web/src/app/actions/PlayerActions.ts` | Removed `buyIns` and `gains` properties from the `playerSchema` and their usage in the `submitPlayer` function, simplifying the data structure. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant U as User
    participant GT as GameTable Component
    participant H as handleChange Function
    participant DS as Debounced Storage Update

    U->>GT: Enter value in buy-ins/gains field
    GT->>H: Call handleChange(value, field)
    H-->>GT: Convert value based on chipMode
    GT->>DS: Update player state and trigger storage update
```

```mermaid
sequenceDiagram
    participant U as User
    participant GS as GameSettings Component
    participant NP as NewGamePage
    participant CM as calculateMissingGains Function

    U->>GS: Toggle chipMode / update ratio inputs
    GS->>NP: Propagate updated chipMode and values via props
    NP->>CM: Compute missing gains message (via useMemo)
    CM-->>NP: Return formatted gains message
    NP->>U: Update UI with new settings and messages
```

## Poem
> Oh, I’m a rabbit in a code-filled glen,  
> Hoping through new settings again and then,  
> Chip mode whispers magic in each line,  
> Gains and buy-ins now perfectly align,  
> With toggles and switches, my joy does sprawl,  
> Leaping through changes—coding fun for all! 🐇✨

<!-- walkthrough_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpADK2VmgqyjcEj2wAbb5AokAI7Y0riQ4rjedJAARACyaADWnuyUkOQA7pBEaGyQJGiI8JQxkBmFkIjYAszqNPRykNiIaXS4mAAMAJwALOgY9KjwShjiAGbF9BUYTgJpAMwATBowsJ688Mwu8mP4DM38Y+EIyNjctNSeqAT5GLCYDJ64a00tfCQAHtyUxRiPZWssKkKPAMER0OkSFkcmwVh5GPcwdIUH9vNglMcrsxuFE2KNqPB8Fh8Ec0OF8EQiFFIGMCrhsAFjtR0L58BlTm9kDdEBl1AxYJA5rgMiQyJBaEgcWhZKDwRI0GjkaDxfhfC5kJh6Pz4Nx0Mx8NhRogVgBBWgS8REhXeWQAGkxlVwsm8ssg9xkoqwZwu9XJKGxFHwUgdEiQ2AVPACLXxluJR2eV1GlDGaEe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touch_checkbox_start -->

<details>
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=edtan094/poker-tracker&utm_content=32):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Generate unit testing code for this file.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai generate unit testing code for this file.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and generate unit testing code.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

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 using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai plan` to trigger planning for file edits and PR creation.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
author_association: NONE