feat: add admin dashboard and core API routes with Docker configuration

This commit is contained in:
2026-10-29 19:46:37 +01:00
parent 2fdabe1dfd
commit 4f4856d9dc
89 changed files with 1984 additions and 1034 deletions

View File

@@ -1,7 +1,6 @@
import { NextRequest, NextResponse } from 'next/server'
import prisma from '../../../../lib/prisma'
type Params = { params: Promise<{ id: string }> }
import { isAdmin } from '@/lib/auth-utils'
// GET /api/interviews/[id]
export async function GET(
@@ -19,12 +18,16 @@ export async function GET(
}
}
// PATCH /api/interviews/[id]
// PATCH /api/interviews/[id] (Admin only)
export async function PATCH(
request: NextRequest,
context: { params: Promise<{ id: string }> }
): Promise<Response> {
try {
if (!(await isAdmin(request))) {
return NextResponse.json({ error: 'Accès réservé aux administrateurs' }, { status: 403 })
}
const { id } = await context.params
const body = await request.json()
const interview = await prisma.interview.update({ where: { id }, data: body })
@@ -35,12 +38,16 @@ export async function PATCH(
}
}
// DELETE /api/interviews/[id]
// DELETE /api/interviews/[id] (Admin only)
export async function DELETE(
_request: NextRequest,
request: NextRequest,
context: { params: Promise<{ id: string }> }
): Promise<Response> {
try {
if (!(await isAdmin(request))) {
return NextResponse.json({ error: 'Accès réservé aux administrateurs' }, { status: 403 })
}
const { id } = await context.params
await prisma.interview.delete({ where: { id } })
return NextResponse.json({ success: true })

View File

@@ -1,5 +1,6 @@
import { NextRequest, NextResponse } from 'next/server'
import prisma from '@/lib/prisma'
import { isAdmin } from '@/lib/auth-utils'
// GET /api/interviews
export async function GET() {
@@ -20,9 +21,13 @@ export async function GET() {
}
}
// POST /api/interviews
// POST /api/interviews (Admin only)
export async function POST(request: NextRequest) {
try {
if (!(await isAdmin(request))) {
return NextResponse.json({ error: 'Accès réservé aux administrateurs' }, { status: 403 })
}
const body = await request.json()
const interview = await prisma.interview.create({ data: body })
return NextResponse.json(interview, { status: 201 })