From 98f08ece117239e4860b667b1ea9739925d63768 Mon Sep 17 00:00:00 2001 From: Mike Johnston Date: Wed, 18 Mar 2026 19:13:16 -0400 Subject: [PATCH] feat: add lottery reset functionality in admin user actions and API --- src/app/admin/users/AdminUserActions.tsx | 35 ++++++++++++++++++++++- src/app/api/admin/users/[userId]/route.ts | 8 +++++- src/components/Navbar.tsx | 10 +------ 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/app/admin/users/AdminUserActions.tsx b/src/app/admin/users/AdminUserActions.tsx index 402cc2d..6fa2485 100644 --- a/src/app/admin/users/AdminUserActions.tsx +++ b/src/app/admin/users/AdminUserActions.tsx @@ -19,6 +19,7 @@ export function AdminUserActions({ user }: { user: UserData }) { const [points, setPoints] = useState(String(user.researchPoints)) const [loading, setLoading] = useState(false) const [resetUrl, setResetUrl] = useState(null) + const [lotteryReset, setLotteryReset] = useState(false) const [error, setError] = useState('') async function handleSave() { @@ -57,6 +58,23 @@ export function AdminUserActions({ user }: { user: UserData }) { } } + async function handleResetLottery() { + setLoading(true) + setError('') + const res = await fetch(`/api/admin/users/${user.id}`, { + method: 'PATCH', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ resetLotteryAt: true }), + }) + const data = await res.json() + setLoading(false) + if (!res.ok) { + setError(data.error ?? 'Reset failed.') + } else { + setLotteryReset(true) + } + } + return ( <> + {lotteryReset && ( +

Player can play again today.

+ )} + + + {/* Password reset */}

Password reset