From 7b86fb9d82292cd2614de23cffc688365780af56 Mon Sep 17 00:00:00 2001 From: Andres Date: Sat, 5 Jul 2025 23:39:14 +0200 Subject: [PATCH] show transcripts in a modal instead of a pop-up --- .../players/[id]/_components/games-table.tsx | 197 +++++++++++------- 1 file changed, 117 insertions(+), 80 deletions(-) diff --git a/src/app/(home)/players/[id]/_components/games-table.tsx b/src/app/(home)/players/[id]/_components/games-table.tsx index 24251fe..5b68ff9 100644 --- a/src/app/(home)/players/[id]/_components/games-table.tsx +++ b/src/app/(home)/players/[id]/_components/games-table.tsx @@ -2,6 +2,12 @@ import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, +} from '@/components/ui/dialog' import { Table, TableBody, @@ -41,24 +47,8 @@ function getTranscript(gameNumber: number) { `https://api.neatqueue.com/api/transcript/1226193436521267223/${gameNumber}` ).then((res) => res.json()) } -function openTranscript(gameNumber: number): void { - getTranscript(gameNumber) - .then((html: string) => { - const newWindow = window.open('', '_blank') - if (newWindow) { - newWindow.document.write(html) - newWindow.document.close() - } else { - console.error( - 'Failed to open new window - popup blocker may be enabled' - ) - } - }) - .catch((err) => { - console.error('Failed to load transcript:', err) - }) -} -const useColumns = () => { +// This function is now moved inside the GamesTable component +const useColumns = (openTranscriptFn?: (gameNumber: number) => void) => { const format = useFormatter() const timeZone = useTimeZone() const session = useSession() @@ -186,7 +176,9 @@ const useColumns = () => { cell: (info) => ( + + + ) + })} + + ))} + + + {table.getRowModel().rows.map((row) => ( + + {row.getVisibleCells().map((cell) => ( + + {flexRender(cell.column.columnDef.cell, cell.getContext())} + + ))} + + ))} + + + + + {/* Transcript Dialog */} + + + + + {transcriptGameNumber + ? `Game Transcript #${transcriptGameNumber}` + : 'Game Transcript'} + + + {/* Use iframe to isolate the transcript content and prevent style leakage */} +
+