diff --git a/app/api/calendars/[id]/events/[eventId]/route.ts b/app/api/calendars/[id]/events/[eventId]/route.ts index 784f3d39..aac8d66e 100644 --- a/app/api/calendars/[id]/events/[eventId]/route.ts +++ b/app/api/calendars/[id]/events/[eventId]/route.ts @@ -26,8 +26,9 @@ import { prisma } from "@/lib/prisma"; */ export async function GET( req: NextRequest, - { params }: { params: { id: string; eventId: string } } + props: { params: Promise<{ id: string; eventId: string }> } ) { + const params = await props.params; const session = await getServerSession(authOptions); if (!session?.user?.username) { @@ -105,8 +106,9 @@ export async function GET( */ export async function PUT( req: NextRequest, - { params }: { params: { id: string; eventId: string } } + props: { params: Promise<{ id: string; eventId: string }> } ) { + const params = await props.params; const session = await getServerSession(authOptions); if (!session?.user?.username) { @@ -208,8 +210,9 @@ export async function PUT( */ export async function DELETE( req: NextRequest, - { params }: { params: { id: string; eventId: string } } + props: { params: Promise<{ id: string; eventId: string }> } ) { + const params = await props.params; const session = await getServerSession(authOptions); if (!session?.user?.username) { diff --git a/app/api/calendars/[id]/events/route.ts b/app/api/calendars/[id]/events/route.ts index 268ce1bc..b097a0a9 100644 --- a/app/api/calendars/[id]/events/route.ts +++ b/app/api/calendars/[id]/events/route.ts @@ -24,10 +24,8 @@ import { prisma } from "@/lib/prisma"; * - 404: Calendar not found. * - 500: Server error occurred while retrieving events. */ -export async function GET( - req: NextRequest, - { params }: { params: { id: string } } -) { +export async function GET(req: NextRequest, props: { params: Promise<{ id: string }> }) { + const params = await props.params; const session = await getServerSession(authOptions); if (!session?.user?.username) { @@ -105,10 +103,8 @@ export async function GET( * @throws {400} If the required fields (title, start, end) are missing. * @throws {500} If there is a server error during event creation. */ -export async function POST( - req: NextRequest, - { params }: { params: { id: string } } -) { +export async function POST(req: NextRequest, props: { params: Promise<{ id: string }> }) { + const params = await props.params; const session = await getServerSession(authOptions); if (!session?.user?.username) { diff --git a/app/api/calendars/[id]/share/route.ts b/app/api/calendars/[id]/share/route.ts index cc76aa4f..6ebdd06b 100644 --- a/app/api/calendars/[id]/share/route.ts +++ b/app/api/calendars/[id]/share/route.ts @@ -5,10 +5,8 @@ import { prisma } from "@/lib/prisma"; import crypto from "crypto"; // Non testé, généré automatiquement par IA -export async function POST( - req: NextRequest, - { params }: { params: { id: string } } -) { +export async function POST(req: NextRequest, props: { params: Promise<{ id: string }> }) { + const params = await props.params; const session = await getServerSession(authOptions); if (!session?.user?.username) { diff --git a/app/api/courrier/[id]/flag/route.ts b/app/api/courrier/[id]/flag/route.ts index 1b38c675..37f86714 100644 --- a/app/api/courrier/[id]/flag/route.ts +++ b/app/api/courrier/[id]/flag/route.ts @@ -6,7 +6,7 @@ import { invalidateEmailContentCache, invalidateFolderCache } from '@/lib/redis' export async function POST( request: Request, - context: { params: { id: string } } + context: { params: Promise<{ id: string }> } ) { try { const session = await getServerSession(authOptions); diff --git a/app/api/courrier/[id]/mark-read/route.ts b/app/api/courrier/[id]/mark-read/route.ts index a6bb7b1f..c915e873 100644 --- a/app/api/courrier/[id]/mark-read/route.ts +++ b/app/api/courrier/[id]/mark-read/route.ts @@ -31,7 +31,7 @@ const invalidateCache = (userId: string, folder?: string) => { // Mark email as read export async function POST( request: Request, - context: { params: { id: string } } + context: { params: Promise<{ id: string }> } ) { try { const session = await getServerSession(authOptions); diff --git a/app/api/courrier/[id]/route.ts b/app/api/courrier/[id]/route.ts index a9196739..fd1321ff 100644 --- a/app/api/courrier/[id]/route.ts +++ b/app/api/courrier/[id]/route.ts @@ -14,7 +14,7 @@ import { getCachedEmailContent, invalidateEmailContentCache } from '@/lib/redis' export async function GET( request: Request, - context: { params: { id: string } } + context: { params: Promise<{ id: string }> } ) { try { const session = await getServerSession(authOptions); @@ -73,7 +73,7 @@ export async function GET( // Add a route to mark email as read export async function POST( request: Request, - context: { params: { id: string } } + context: { params: Promise<{ id: string }> } ) { try { const session = await getServerSession(authOptions); diff --git a/app/api/events/[id]/route.ts b/app/api/events/[id]/route.ts index 9b922222..7848e0e1 100644 --- a/app/api/events/[id]/route.ts +++ b/app/api/events/[id]/route.ts @@ -3,10 +3,8 @@ import { getServerSession } from "next-auth/next"; import { authOptions } from "@/app/api/auth/[...nextauth]/route"; import { prisma } from "@/lib/prisma"; -export async function DELETE( - req: NextRequest, - { params }: { params: { id: string } } -) { +export async function DELETE(req: NextRequest, props: { params: Promise<{ id: string }> }) { + const params = await props.params; const session = await getServerSession(authOptions); if (!session?.user?.id) { diff --git a/app/api/groups/[groupId]/members/route.ts b/app/api/groups/[groupId]/members/route.ts index 64fcf5fc..fefc8539 100644 --- a/app/api/groups/[groupId]/members/route.ts +++ b/app/api/groups/[groupId]/members/route.ts @@ -2,10 +2,8 @@ import { getServerSession } from "next-auth/next"; import { authOptions } from "@/app/api/auth/[...nextauth]/route"; import { NextResponse } from "next/server"; -export async function GET( - req: Request, - { params }: { params: { groupId: string } } -) { +export async function GET(req: Request, props: { params: Promise<{ groupId: string }> }) { + const params = await props.params; const session = await getServerSession(authOptions); if (!session) { @@ -60,10 +58,8 @@ export async function GET( } } -export async function POST( - req: Request, - { params }: { params: { groupId: string } } -) { +export async function POST(req: Request, props: { params: Promise<{ groupId: string }> }) { + const params = await props.params; const session = await getServerSession(authOptions); if (!session) { diff --git a/app/api/groups/[groupId]/route.ts b/app/api/groups/[groupId]/route.ts index 23101716..2d99661c 100644 --- a/app/api/groups/[groupId]/route.ts +++ b/app/api/groups/[groupId]/route.ts @@ -26,10 +26,8 @@ async function getAdminToken() { return data.access_token; } -export async function GET( - req: Request, - { params }: { params: { groupId: string } } -) { +export async function GET(req: Request, props: { params: Promise<{ groupId: string }> }) { + const params = await props.params; try { const session = await getServerSession(authOptions); if (!session) { @@ -62,10 +60,8 @@ export async function GET( } } -export async function PUT( - req: Request, - { params }: { params: { groupId: string } } -) { +export async function PUT(req: Request, props: { params: Promise<{ groupId: string }> }) { + const params = await props.params; try { const session = await getServerSession(authOptions); if (!session) { @@ -101,10 +97,8 @@ export async function PUT( } } -export async function PATCH( - req: Request, - { params }: { params: { groupId: string } } -) { +export async function PATCH(req: Request, props: { params: Promise<{ groupId: string }> }) { + const params = await props.params; try { const session = await getServerSession(authOptions); if (!session) { @@ -140,10 +134,8 @@ export async function PATCH( } } -export async function DELETE( - req: Request, - { params }: { params: { groupId: string } } -) { +export async function DELETE(req: Request, props: { params: Promise<{ groupId: string }> }) { + const params = await props.params; try { const session = await getServerSession(authOptions); if (!session) { diff --git a/app/api/missions/[missionId]/attachments/[attachmentId]/route.ts b/app/api/missions/[missionId]/attachments/[attachmentId]/route.ts index 3ce0f0b2..a5e8fd2a 100644 --- a/app/api/missions/[missionId]/attachments/[attachmentId]/route.ts +++ b/app/api/missions/[missionId]/attachments/[attachmentId]/route.ts @@ -21,8 +21,9 @@ async function checkAuth(request: Request) { // DELETE endpoint to remove an attachment export async function DELETE( request: Request, - { params }: { params: { missionId: string, attachmentId: string } } + props: { params: Promise<{ missionId: string, attachmentId: string }> } ) { + const params = await props.params; try { const { authorized, userId } = await checkAuth(request); if (!authorized || !userId) { diff --git a/app/api/missions/[missionId]/attachments/download/[attachmentId]/route.ts b/app/api/missions/[missionId]/attachments/download/[attachmentId]/route.ts index 83bd6f4f..2ec6ad96 100644 --- a/app/api/missions/[missionId]/attachments/download/[attachmentId]/route.ts +++ b/app/api/missions/[missionId]/attachments/download/[attachmentId]/route.ts @@ -23,8 +23,9 @@ async function checkAuth(request: Request) { // GET endpoint to download an attachment export async function GET( request: Request, - { params }: { params: { missionId: string, attachmentId: string } } + props: { params: Promise<{ missionId: string, attachmentId: string }> } ) { + const params = await props.params; try { const { authorized, userId } = await checkAuth(request); if (!authorized || !userId) { diff --git a/app/api/missions/[missionId]/attachments/route.ts b/app/api/missions/[missionId]/attachments/route.ts index 7a2ad6f5..0289264b 100644 --- a/app/api/missions/[missionId]/attachments/route.ts +++ b/app/api/missions/[missionId]/attachments/route.ts @@ -18,10 +18,8 @@ async function checkAuth(request: Request) { } // GET endpoint to list all attachments for a mission -export async function GET( - request: Request, - { params }: { params: { missionId: string } } -) { +export async function GET(request: Request, props: { params: Promise<{ missionId: string }> }) { + const params = await props.params; try { const { authorized, userId } = await checkAuth(request); if (!authorized || !userId) { diff --git a/app/api/missions/[missionId]/route.ts b/app/api/missions/[missionId]/route.ts index a39dec8c..f320beb7 100644 --- a/app/api/missions/[missionId]/route.ts +++ b/app/api/missions/[missionId]/route.ts @@ -19,10 +19,8 @@ async function checkAuth(request: Request) { } // GET endpoint to retrieve a mission by ID -export async function GET( - request: Request, - { params }: { params: { missionId: string } } -) { +export async function GET(request: Request, props: { params: Promise<{ missionId: string }> }) { + const params = await props.params; try { const { authorized, userId } = await checkAuth(request); if (!authorized || !userId) { @@ -91,10 +89,8 @@ export async function GET( } // PUT endpoint to update a mission -export async function PUT( - request: Request, - { params }: { params: { missionId: string } } -) { +export async function PUT(request: Request, props: { params: Promise<{ missionId: string }> }) { + const params = await props.params; try { const { authorized, userId } = await checkAuth(request); if (!authorized || !userId) { @@ -246,10 +242,8 @@ export async function PUT( } // DELETE endpoint to remove a mission -export async function DELETE( - request: Request, - { params }: { params: { missionId: string } } -) { +export async function DELETE(request: Request, props: { params: Promise<{ missionId: string }> }) { + const params = await props.params; try { const { authorized, userId } = await checkAuth(request); if (!authorized || !userId) { diff --git a/app/api/notifications/[id]/read/route.ts b/app/api/notifications/[id]/read/route.ts index a97c3e2d..66b7dec0 100644 --- a/app/api/notifications/[id]/read/route.ts +++ b/app/api/notifications/[id]/read/route.ts @@ -6,7 +6,7 @@ import { NotificationService } from '@/lib/services/notifications/notification-s // POST /api/notifications/{id}/read export async function POST( request: Request, - context: { params: { id: string } } + context: { params: Promise<{ id: string }> } ) { try { // Authenticate user diff --git a/app/api/users/[userId]/password/route.ts b/app/api/users/[userId]/password/route.ts index 2fe422eb..e68ea731 100644 --- a/app/api/users/[userId]/password/route.ts +++ b/app/api/users/[userId]/password/route.ts @@ -2,10 +2,8 @@ import { getServerSession } from "next-auth/next"; import { authOptions } from "@/app/api/auth/[...nextauth]/route"; import { NextResponse } from "next/server"; -export async function PUT( - req: Request, - { params }: { params: { userId: string } } -) { +export async function PUT(req: Request, props: { params: Promise<{ userId: string }> }) { + const params = await props.params; const session = await getServerSession(authOptions); if (!session) { diff --git a/app/api/users/[userId]/roles/route.ts b/app/api/users/[userId]/roles/route.ts index f806537f..ea86e55e 100644 --- a/app/api/users/[userId]/roles/route.ts +++ b/app/api/users/[userId]/roles/route.ts @@ -6,10 +6,8 @@ import { getKeycloakAdminClient } from "@/lib/keycloak"; // Fix for Next.js "params should be awaited" error export const dynamic = 'force-dynamic'; -export async function GET( - request: Request, - { params }: { params: { userId?: string } } -) { +export async function GET(request: Request, props: { params: Promise<{ userId?: string }> }) { + const params = await props.params; try { const session = await getServerSession(authOptions); if (!session) { @@ -85,10 +83,8 @@ export async function GET( } } -export async function PUT( - request: Request, - { params }: { params: { userId?: string } } -) { +export async function PUT(request: Request, props: { params: Promise<{ userId?: string }> }) { + const params = await props.params; try { const session = await getServerSession(authOptions); if (!session) { diff --git a/app/api/users/[userId]/route.ts b/app/api/users/[userId]/route.ts index 7758918c..bd342215 100644 --- a/app/api/users/[userId]/route.ts +++ b/app/api/users/[userId]/route.ts @@ -65,7 +65,7 @@ async function deleteLeantimeUser(email: string, requestingUserId: string): Prom // Check if the requesting user has permission to delete this user // This is a placeholder - implement proper permission check based on your requirements - if (!await hasDeletePermission(requestingUserId, leantimeUserId)) { + if (!(await hasDeletePermission(requestingUserId, leantimeUserId))) { return { success: false, error: 'Unauthorized to delete this user' @@ -120,10 +120,8 @@ async function hasDeletePermission(requestingUserId: string, targetUserId: numbe return true; } -export async function DELETE( - req: Request, - { params }: { params: { userId: string } } -) { +export async function DELETE(req: Request, props: { params: Promise<{ userId: string }> }) { + const params = await props.params; const session = await getServerSession(authOptions); const userId = params.userId; // Store userId from params to avoid sync access issues @@ -210,10 +208,8 @@ export async function DELETE( } } -export async function PUT( - req: Request, - { params }: { params: { userId: string } } -) { +export async function PUT(req: Request, props: { params: Promise<{ userId: string }> }) { + const params = await props.params; const session = await getServerSession(authOptions); if (!session) { diff --git a/app/courrier/[id]/route.ts b/app/courrier/[id]/route.ts index bdd0084d..ff9443b2 100644 --- a/app/courrier/[id]/route.ts +++ b/app/courrier/[id]/route.ts @@ -9,10 +9,8 @@ import { simpleParser } from 'mailparser'; const emailContentCache = new Map(); const CACHE_TTL = 30 * 60 * 1000; // 30 minutes in milliseconds -export async function GET( - request: Request, - { params }: { params: { id: string } } -) { +export async function GET(request: Request, props: { params: Promise<{ id: string }> }) { + const params = await props.params; try { console.log(`[DEBUG] GET request for single email ID: ${params.id}`); @@ -162,10 +160,8 @@ export async function GET( } // Handle marking emails as read -export async function POST( - request: Request, - { params }: { params: { id: string } } -) { +export async function POST(request: Request, props: { params: Promise<{ id: string }> }) { + const params = await props.params; try { console.log(`[DEBUG] POST request for email ID: ${params.id}`);