diff --git a/app/(manage)/manage/games/games-client.tsx b/app/(manage)/manage/games/games-client.tsx index 4d1afcf..1e97be3 100644 --- a/app/(manage)/manage/games/games-client.tsx +++ b/app/(manage)/manage/games/games-client.tsx @@ -9,6 +9,7 @@ import { ExternalLinkIcon, TrashIcon, Gamepad2Icon, + RefreshCwIcon, } from "lucide-react" interface Game { @@ -45,6 +46,7 @@ export function GamesClient() { const [search, setSearch] = useState("") const [offset, setOffset] = useState(0) const [deletingIds, setDeletingIds] = useState>(new Set()) + const [resyncingIds, setResyncingIds] = useState>(new Set()) const isSearchChangeRef = useRef(false) @@ -93,6 +95,32 @@ export function GamesClient() { } }, [search, offset]) + const handleResync = async (game: Game) => { + setResyncingIds((prev) => new Set(prev).add(game.id)) + try { + const res = await fetch(`/api/games/${game.id}/sync`, { + method: "POST", + }) + if (res.ok) { + setGames((prev) => + prev.map((g) => + g.id === game.id + ? { ...g, syncStatus: "synced", lastSync: new Date().toISOString() } + : g + ) + ) + } + } catch (error) { + console.error("Resync failed:", error) + } finally { + setResyncingIds((prev) => { + const next = new Set(prev) + next.delete(game.id) + return next + }) + } + } + const handleDelete = async (game: Game) => { if (!confirm(`Are you sure you want to delete "${game.title}"?`)) return setDeletingIds((prev) => new Set(prev).add(game.id)) @@ -237,6 +265,18 @@ export function GamesClient() { View +