mirror of
https://github.com/mudabbir-ahmad/peworkshop.git
synced 2026-10-08 03:50:21 +00:00
Add hunts table and default row; improve error handling and UI for team management
This commit is contained in:
1 parent
cd9c106ba1
commit
a6ed24b2e6
8 files changed
+156
-52
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { getServerSession } from "next-auth/next";
|
||||
import { authOptions } from "../auth/[...nextauth]/route";
|
||||
import { run } from "@/lib/db";
|
||||
|
||||
export async function POST(request) {
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session || session.user.role !== "admin") {
|
||||
return new Response(JSON.stringify({ error: "Unauthorized" }), {
|
||||
status: 401,
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
// Add a WHERE clause or provide an ID if you're updating a specific hunt record
|
||||
await run("UPDATE hunts SET active = 1, start_time = NOW() WHERE id = ?", [1]);
|
||||
// Or if you just have one hunt record: "UPDATE hunts SET active = 1, start_time = NOW()"
|
||||
|
||||
return new Response(JSON.stringify({ success: true }), { status: 200 });
|
||||
} catch (err) {
|
||||
console.error("Hunt start error:", err); // Add logging for better debugging
|
||||
return new Response(JSON.stringify({ error: err.message }), {
|
||||
status: 500,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user