fix: update API routes to handle Next.js 15+ params as Promise
This commit is contained in:
@@ -4,7 +4,7 @@ import { hasRole } from "@/lib/permissions";
|
|||||||
|
|
||||||
export async function PUT(
|
export async function PUT(
|
||||||
request: Request,
|
request: Request,
|
||||||
{ params }: { params: { id: string } }
|
{ params }: { params: Promise<{ id: string }> }
|
||||||
) {
|
) {
|
||||||
// Check permissions
|
// Check permissions
|
||||||
const permission = await hasRole("club_admin");
|
const permission = await hasRole("club_admin");
|
||||||
@@ -16,7 +16,7 @@ export async function PUT(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { id } = params;
|
const { id } = await params;
|
||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
const { email, name, role, playerId } = body;
|
const { email, name, role, playerId } = body;
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ export async function PUT(
|
|||||||
|
|
||||||
export async function DELETE(
|
export async function DELETE(
|
||||||
request: Request,
|
request: Request,
|
||||||
{ params }: { params: { id: string } }
|
{ params }: { params: Promise<{ id: string }> }
|
||||||
) {
|
) {
|
||||||
// Check permissions - only site_admin can delete users
|
// Check permissions - only site_admin can delete users
|
||||||
const permission = await hasRole("site_admin");
|
const permission = await hasRole("site_admin");
|
||||||
@@ -95,7 +95,7 @@ export async function DELETE(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { id } = params;
|
const { id } = await params;
|
||||||
|
|
||||||
// Check if user exists
|
// Check if user exists
|
||||||
const existingUser = await prisma.user.findUnique({
|
const existingUser = await prisma.user.findUnique({
|
||||||
@@ -149,7 +149,7 @@ export async function DELETE(
|
|||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
request: Request,
|
request: Request,
|
||||||
{ params }: { params: { id: string } }
|
{ params }: { params: Promise<{ id: string }> }
|
||||||
) {
|
) {
|
||||||
// Check permissions
|
// Check permissions
|
||||||
const permission = await hasRole("club_admin");
|
const permission = await hasRole("club_admin");
|
||||||
@@ -161,7 +161,7 @@ export async function GET(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { id } = params;
|
const { id } = await params;
|
||||||
|
|
||||||
const user = await prisma.user.findUnique({
|
const user = await prisma.user.findUnique({
|
||||||
where: { id },
|
where: { id },
|
||||||
|
|||||||
Reference in New Issue
Block a user