fix: types of nj15

This commit is contained in:
Julien Froidefond
2025-03-02 14:40:15 +01:00
parent a4b521fe2e
commit e60b48d549
27 changed files with 133 additions and 100 deletions

View File

@@ -1,13 +1,15 @@
import type { NextRequest} from "next/server";
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { BookService } from "@/lib/services/book.service";
import { ERROR_CODES } from "@/constants/errorCodes";
import { getErrorMessage } from "@/utils/errors";
import { AppError } from "@/utils/errors";
export async function PATCH(request: NextRequest, { params }: { params: { bookId: string } }) {
export async function PATCH(request: NextRequest) {
try {
const { page, completed } = await request.json();
const params = request.nextUrl.searchParams;
const bookId: string = params.get("bookId") || "";
if (typeof page !== "number") {
return NextResponse.json(
@@ -22,7 +24,7 @@ export async function PATCH(request: NextRequest, { params }: { params: { bookId
);
}
await BookService.updateReadProgress(params.bookId, page, completed);
await BookService.updateReadProgress(bookId, page, completed);
return NextResponse.json({ message: "📖 Progression mise à jour avec succès" });
} catch (error) {
console.error("Erreur lors de la mise à jour de la progression:", error);
@@ -51,9 +53,12 @@ export async function PATCH(request: NextRequest, { params }: { params: { bookId
}
}
export async function DELETE(request: NextRequest, { params }: { params: { bookId: string } }) {
export async function DELETE(request: NextRequest) {
try {
await BookService.deleteReadProgress(params.bookId);
const params = request.nextUrl.searchParams;
const bookId: string = params.get("bookId") || "";
await BookService.deleteReadProgress(bookId);
return NextResponse.json({ message: "🗑️ Progression supprimée avec succès" });
} catch (error) {
console.error("Erreur lors de la suppression de la progression:", error);