Fix admin user id from URL params, raise landing logo/buttons
This commit is contained in:
@@ -3,12 +3,17 @@ import { prisma } from "@/lib/prisma";
|
||||
import { requireAdmin } from "@/lib/session";
|
||||
import bcrypt from "bcryptjs";
|
||||
|
||||
export async function PATCH(req: NextRequest) {
|
||||
export async function PATCH(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
const admin = await requireAdmin();
|
||||
if (!admin) return NextResponse.json({ error: "Admin requis" }, { status: 403 });
|
||||
|
||||
const { id, ...data } = await req.json();
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const id = params?.id || body.id;
|
||||
if (!id) return NextResponse.json({ error: "id requis" }, { status: 400 });
|
||||
const { id: _bodyId, ...data } = body;
|
||||
|
||||
const allowed = [
|
||||
"name", "email", "isMuayThai", "isYoga", "role", "phone", "avatar", "password"
|
||||
@@ -59,11 +64,15 @@ export async function PATCH(req: NextRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(req: NextRequest) {
|
||||
export async function DELETE(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
const admin = await requireAdmin();
|
||||
if (!admin) return NextResponse.json({ error: "Admin requis" }, { status: 403 });
|
||||
|
||||
const { id } = await req.json();
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const id = params?.id || body.id;
|
||||
if (!id) return NextResponse.json({ error: "id requis" }, { status: 400 });
|
||||
|
||||
try {
|
||||
|
||||
+8
-8
@@ -12,9 +12,9 @@ export default function LandingPage() {
|
||||
return (
|
||||
<main className="min-h-screen flex flex-col">
|
||||
<Header />
|
||||
<div className="flex flex-1 flex-col items-center justify-center px-4 py-8">
|
||||
<div className="mb-8 mt-4 text-center">
|
||||
<div className="mx-auto mb-4 h-24 w-24 overflow-hidden rounded-full border-2 border-primary-500">
|
||||
<div className="flex flex-1 flex-col items-center justify-center px-4 pt-2 pb-8">
|
||||
<div className="mb-6 mt-0 text-center">
|
||||
<div className="mx-auto mb-4 h-20 w-20 overflow-hidden rounded-full border-2 border-primary-500 sm:h-24 sm:w-24">
|
||||
<img
|
||||
src="/images/logo-muaythai.jpg"
|
||||
alt="Juanito Logo"
|
||||
@@ -32,9 +32,9 @@ export default function LandingPage() {
|
||||
<div className="grid w-full max-w-2xl grid-cols-2 gap-3 sm:gap-4">
|
||||
<Link
|
||||
href="/muay-thai"
|
||||
className="group flex flex-col items-center justify-center rounded-2xl border border-primary-600/40 bg-gradient-to-br from-primary-800/40 to-dark-800 px-3 py-5 text-center shadow-xl transition-all hover:scale-[1.02] hover:border-primary-500 active:scale-95 sm:rounded-3xl sm:px-6 sm:py-8"
|
||||
className="group flex flex-col items-center justify-center rounded-2xl border border-primary-600/40 bg-gradient-to-br from-primary-800/40 to-dark-800 px-3 py-4 text-center shadow-xl transition-all hover:scale-[1.02] hover:border-primary-500 active:scale-95 sm:rounded-3xl sm:px-6 sm:py-7"
|
||||
>
|
||||
<span className="mb-2 h-14 w-14 overflow-hidden rounded-full border-2 border-primary-500 sm:mb-3 sm:h-20 sm:w-20">
|
||||
<span className="mb-2 h-12 w-12 overflow-hidden rounded-full border-2 border-primary-500 sm:mb-3 sm:h-20 sm:w-20">
|
||||
<img
|
||||
src="/images/logo-muaythai.jpg"
|
||||
alt="Muay Thai"
|
||||
@@ -51,9 +51,9 @@ export default function LandingPage() {
|
||||
|
||||
<Link
|
||||
href="/yog4fight"
|
||||
className="group flex flex-col items-center justify-center rounded-2xl border border-emerald-500/40 bg-gradient-to-br from-emerald-800/40 to-dark-800 px-3 py-5 text-center shadow-xl transition-all hover:scale-[1.02] hover:border-emerald-400 active:scale-95 sm:rounded-3xl sm:px-6 sm:py-8"
|
||||
className="group flex flex-col items-center justify-center rounded-2xl border border-emerald-500/40 bg-gradient-to-br from-emerald-800/40 to-dark-800 px-3 py-4 text-center shadow-xl transition-all hover:scale-[1.02] hover:border-emerald-400 active:scale-95 sm:rounded-3xl sm:px-6 sm:py-7"
|
||||
>
|
||||
<span className="mb-2 h-14 w-14 overflow-hidden rounded-full border-2 border-emerald-500 sm:mb-3 sm:h-20 sm:w-20">
|
||||
<span className="mb-2 h-12 w-12 overflow-hidden rounded-full border-2 border-emerald-500 sm:mb-3 sm:h-20 sm:w-20">
|
||||
<img
|
||||
src="/images/logo-yoga.png"
|
||||
alt="Yog4Fight"
|
||||
@@ -72,7 +72,7 @@ export default function LandingPage() {
|
||||
{isAdmin && (
|
||||
<Link
|
||||
href="/admin"
|
||||
className="btn-secondary mt-8 text-sm"
|
||||
className="btn-secondary mt-6 text-sm"
|
||||
>
|
||||
⚙️ Tableau de bord admin
|
||||
</Link>
|
||||
|
||||
Reference in New Issue
Block a user