Add user deletion functionality: Implement DELETE API endpoint for user management, allowing admins to remove users while preventing self-deletion. Enhance UserManagement component with delete confirmation and error handling for improved user experience.

This commit is contained in:
Julien Froidefond
2025-12-10 05:55:52 +01:00
parent 125e9b345d
commit 88d377e7b2
3 changed files with 139 additions and 21 deletions

View File

@@ -1,6 +1,7 @@
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { calculateEventStatus } from "@/lib/eventStatus";
export async function POST(
request: Request,
@@ -30,7 +31,8 @@ export async function POST(
);
}
if (event.status !== "UPCOMING") {
const eventStatus = calculateEventStatus(event.date);
if (eventStatus !== "UPCOMING") {
return NextResponse.json(
{ error: "Vous ne pouvez vous inscrire qu'aux événements à venir" },
{ status: 400 }