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
+12
View File
@@ -0,0 +1,12 @@
"use server";
import { fetchPlayerCardData } from "@/lib/player-card-server";
import { createAdminSupabase } from "@/lib/supabase/admin";
export async function loadPlayerCardAction(userId: number) {
const supabase = createAdminSupabase();
if (!supabase) {
return { ok: false as const, error: "Supabase is not configured." };
}
return fetchPlayerCardData(supabase, userId);
}
+4 -1
View File
@@ -1,5 +1,6 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import { PlayerCardRoot } from "@/components/player-card-root";
import "./globals.css";
const geistSans = Geist({
@@ -27,7 +28,9 @@ export default function RootLayout({
lang="en"
className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
>
<body className="min-h-full flex flex-col">{children}</body>
<body className="flex min-h-full flex-col">
<PlayerCardRoot>{children}</PlayerCardRoot>
</body>
</html>
);
}
+26 -3
View File
@@ -18,7 +18,13 @@ import {
type MatchmakerLogSource,
} from "@/lib/matchmaker-log-source";
import { readMatchmakerLogFile } from "@/lib/matchmaker-logs-server";
import type { DbMatch, DbTransaction, DbUser } from "@/types/database";
import { fetchEntryHoldPerPlayerCoinsByMatchIds } from "@/lib/match-entry-hold-from-ledger";
import type {
AdminMatchRow,
DbMatch,
DbTransaction,
DbUser,
} from "@/types/database";
import {
normalizeLedgerPage,
normalizeLedgerPageSize,
@@ -79,7 +85,7 @@ export default async function Home({
const supabase = createAdminSupabase();
let users: DbUser[] = [];
let matches: DbMatch[] = [];
let matches: AdminMatchRow[] = [];
let configError: string | null = null;
let usersError: string | null = null;
let matchesError: string | null = null;
@@ -137,7 +143,24 @@ export default async function Home({
if (matchesRes.error) {
matchesError = matchesRes.error.message;
} else {
matches = (matchesRes.data ?? []) as DbMatch[];
const rawMatches = (matchesRes.data ?? []) as DbMatch[];
const holdByMatch = await fetchEntryHoldPerPlayerCoinsByMatchIds(
supabase,
rawMatches
.map((m) => Number(m.id))
.filter((id) => Number.isFinite(id)),
);
matches = rawMatches.map((m) => {
const idNum = Number(m.id);
const hold = Number.isFinite(idNum)
? holdByMatch.get(idNum)
: undefined;
return {
...m,
entryHoldPerPlayerCoins:
hold !== undefined ? hold.toString() : null,
};
});
}
statsBundle = await loadDashboardStatsBundle(supabase);