diff --git a/app/(manage)/manage/games/games-client.tsx b/app/(manage)/manage/games/games-client.tsx index cae72db..639cb0f 100644 --- a/app/(manage)/manage/games/games-client.tsx +++ b/app/(manage)/manage/games/games-client.tsx @@ -1,6 +1,7 @@ "use client" import { useEffect, useRef, useState } from "react" +import { createPortal } from "react-dom" import Image from "next/image" import Link from "next/link" import { @@ -71,6 +72,7 @@ export function GamesClient() { failed: 0, results: new Map(), }) + const [syncCompleted, setSyncCompleted] = useState(false) const handleSelectAll = (checked: boolean) => { if (checked) { @@ -182,6 +184,7 @@ export function GamesClient() { })) setSyncing(false) setSelectedIds(new Set()) + setSyncCompleted(true) } const handleSyncAll = async () => { @@ -277,6 +280,7 @@ export function GamesClient() { isRunning: false, currentGame: null, })) + setSyncCompleted(true) } catch (error) { console.error("Sync all failed:", error) alert("Sync failed. Check console for details.") @@ -285,6 +289,19 @@ export function GamesClient() { } } + const closeSyncOverlay = () => { + setSyncCompleted(false) + setSyncProgress({ + isRunning: false, + current: 0, + total: 0, + currentGame: null, + synced: 0, + failed: 0, + results: new Map(), + }) + } + const isSearchChangeRef = useRef(false) const handleSearchChange = (value: string) => { @@ -574,94 +591,126 @@ export function GamesClient() { - {/* Sync Progress Overlay */} - {syncProgress.isRunning && ( -
- {syncProgress.current} of {syncProgress.total} games -
-Currently syncing:
-{syncProgress.currentGame}
-Synced
-Failed
-Recent results:
- {Array.from(syncProgress.results.entries()).slice(-5).reverse().map(([gameId, result]) => { - const game = games.find((g) => g.id === gameId) - return ( -+ {syncProgress.current} of {syncProgress.total} games +
+Currently syncing:
+{syncProgress.currentGame}
++ {syncProgress.synced} synced, {syncProgress.failed} failed +
+Synced
+Failed
++ {syncCompleted ? "All results:" : "Recent results:"} +
+ {(syncCompleted + ? Array.from(syncProgress.results.entries()) + : Array.from(syncProgress.results.entries()).slice(-5).reverse() + ).map(([gameId, result]) => { + const game = games.find((g) => g.id === gameId) + return ( +