player card added

This commit is contained in:
2026-05-12 13:35:19 +05:30
parent 40ee0df6d9
commit 13d4414c37
13 changed files with 924 additions and 37 deletions
+36 -13
View File
@@ -2,6 +2,7 @@
import Link from "next/link";
import { useEffect, useMemo, useState } from "react";
import { ClickableUserId } from "@/components/clickable-user-id";
import { AdminLedger } from "@/components/admin-ledger";
import { MatchHistoryBattleCard } from "@/components/match-history-battle-card";
import type { DashboardStatsBundle } from "@/lib/dashboard-stats";
@@ -11,8 +12,16 @@ import {
type AdminDashboardTab,
} from "@/lib/dashboard-search-url";
import type { MatchmakerLogSource } from "@/lib/matchmaker-log-source";
import type { DbMatch, DbTransaction, DbUser } from "@/types/database";
import type { SerializedLedgerGlobalSummary } from "@/lib/ledger-integrity";
import type {
AdminMatchRow,
DbMatch,
DbTransaction,
DbUser,
} from "@/types/database";
import {
txAmountToBigInt,
type SerializedLedgerGlobalSummary,
} from "@/lib/ledger-integrity";
import type { LedgerSortKey, LedgerSortOrder } from "@/lib/ledger-table-view";
/** Bigint columns often arrive as strings from PostgREST / JSON. */
@@ -56,9 +65,24 @@ function formatTs(value: string | null): string {
}
}
function matchEntryFeeCoinString(v: DbMatch["entry_fee"]): string | null {
if (v == null) return null;
return txAmountToBigInt(v).toString();
}
function formatPrizeCcChip(v: DbMatch["prize_cc"]): string {
if (v == null) return "—";
const b = txAmountToBigInt(v);
try {
return b.toLocaleString("en-US");
} catch {
return String(v);
}
}
type Props = {
users: DbUser[];
matches: DbMatch[];
matches: AdminMatchRow[];
usersError: string | null;
matchesError: string | null;
transactionsError: string | null;
@@ -378,12 +402,8 @@ export function AdminDashboard({
{i + 1}
</td>
<td className="px-4 py-2">
<Link
href={`/?tab=players&highlight=${row.userId}`}
className="font-mono text-xs text-sky-700 underline decoration-sky-400/60 underline-offset-2 hover:text-sky-900 dark:text-sky-300 dark:hover:text-sky-100"
scroll={false}
>
{row.userId}
<span className="font-mono text-xs">
<ClickableUserId id={row.userId} />
{row.username != null && row.username !== "" ? (
<span className="text-zinc-700 dark:text-zinc-300">
{" "}
@@ -392,7 +412,7 @@ export function AdminDashboard({
) : (
<span className="text-zinc-500"> ()</span>
)}
</Link>
</span>
</td>
<td className="px-4 py-2 text-right font-mono tabular-nums">
{row.totalPrizeCc.toLocaleString("en-US")}
@@ -448,7 +468,9 @@ export function AdminDashboard({
: "text-zinc-800 dark:text-zinc-200"
}
>
<td className="px-4 py-2 font-mono text-xs">{u.id}</td>
<td className="px-4 py-2 font-mono text-xs">
<ClickableUserId id={u.id} />
</td>
<td className="px-4 py-2">{u.username ?? "—"}</td>
<td className="px-4 py-2">{u.cc ?? "—"}</td>
<td className="px-4 py-2">{u.rc ?? "—"}</td>
@@ -622,8 +644,9 @@ export function AdminDashboard({
matchId={m.id}
statusLabel={statusLabel(m.status)}
createdAtLabel={formatTs(m.created_at)}
entryFee={m.entry_fee}
prizeCc={m.prize_cc}
entryFeeCoins={matchEntryFeeCoinString(m.entry_fee)}
entryHoldPerPlayerCoins={m.entryHoldPerPlayerCoins}
prizeCcLabel={formatPrizeCcChip(m.prize_cc)}
winnerId={m.winner_id}
left={{
id: redId,