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