This commit is contained in:
2026-05-03 17:01:46 +03:30
parent b5ad5420b2
commit 9c30295b4b
76 changed files with 7891 additions and 461 deletions

View File

@@ -0,0 +1,30 @@
import { NextRequest, NextResponse } from "next/server";
import { db } from "@/lib/db";
import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth";
const validTiers = new Set(["GOLD", "SILVER", "BRONZE"]);
export async function PATCH(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const session = await getServerSession(authOptions);
if (!session || (session.user as any).role !== "ADMIN") {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const { id } = await params;
const { cardTier } = await req.json();
if (!validTiers.has(cardTier)) {
return NextResponse.json({ error: "Invalid card tier" }, { status: 400 });
}
const updated = await db.player.update({
where: { id },
data: {
cardTier,
isGoldenCardEligible: cardTier === "GOLD",
},
});
return NextResponse.json(updated);
}

View File

@@ -0,0 +1,24 @@
import { NextRequest, NextResponse } from "next/server";
import { db } from "@/lib/db";
import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth";
// PATCH /api/admin/players/[id]/golden-toggle
export async function PATCH(req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const session = await getServerSession(authOptions);
if (!session || (session.user as any).role !== "ADMIN") {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const { id } = await params;
const player = await db.player.findUnique({ where: { id } });
if (!player) return NextResponse.json({ error: "Player not found" }, { status: 404 });
const updated = await db.player.update({
where: { id },
data: { isGoldenCardEligible: !player.isGoldenCardEligible },
});
return NextResponse.json({ isGoldenCardEligible: updated.isGoldenCardEligible });
}