refactor: standardize code formatting and improve consistency across various components and API routes for enhanced readability and maintainability

This commit is contained in:
Julien Froidefond
2025-12-10 14:28:05 +01:00
parent 299a66e6ff
commit f8919b19b3
19 changed files with 152 additions and 161 deletions

View File

@@ -23,7 +23,7 @@ export async function GET(request: NextRequest) {
console.error("Error fetching accounts:", error);
return NextResponse.json(
{ error: "Failed to fetch accounts" },
{ status: 500 }
{ status: 500 },
);
}
}
@@ -51,7 +51,7 @@ export async function POST(request: Request) {
console.error("Error creating account:", error);
return NextResponse.json(
{ error: "Failed to create account" },
{ status: 500 }
{ status: 500 },
);
}
}
@@ -79,7 +79,7 @@ export async function PUT(request: Request) {
console.error("Error updating account:", error);
return NextResponse.json(
{ error: "Failed to update account" },
{ status: 500 }
{ status: 500 },
);
}
}
@@ -99,7 +99,7 @@ export async function DELETE(request: Request) {
if (accountIds.length === 0) {
return NextResponse.json(
{ error: "At least one account ID is required" },
{ status: 400 }
{ status: 400 },
);
}
await accountService.deleteMany(accountIds);
@@ -116,14 +116,14 @@ export async function DELETE(request: Request) {
headers: {
"Cache-Control": "no-store",
},
}
},
);
}
if (!id) {
return NextResponse.json(
{ error: "Account ID is required" },
{ status: 400 }
{ status: 400 },
);
}
@@ -141,13 +141,13 @@ export async function DELETE(request: Request) {
headers: {
"Cache-Control": "no-store",
},
}
},
);
} catch (error) {
console.error("Error deleting account:", error);
return NextResponse.json(
{ error: "Failed to delete account" },
{ status: 500 }
{ status: 500 },
);
}
}

View File

@@ -23,7 +23,7 @@ export async function GET(request: NextRequest) {
console.error("Error fetching category stats:", error);
return NextResponse.json(
{ error: "Failed to fetch category stats" },
{ status: 500 }
{ status: 500 },
);
}
}
@@ -50,7 +50,7 @@ export async function POST(request: Request) {
console.error("Error creating category:", error);
return NextResponse.json(
{ error: "Failed to create category" },
{ status: 500 }
{ status: 500 },
);
}
}
@@ -78,7 +78,7 @@ export async function PUT(request: Request) {
console.error("Error updating category:", error);
return NextResponse.json(
{ error: "Failed to update category" },
{ status: 500 }
{ status: 500 },
);
}
}
@@ -94,7 +94,7 @@ export async function DELETE(request: Request) {
if (!id) {
return NextResponse.json(
{ error: "Category ID is required" },
{ status: 400 }
{ status: 400 },
);
}
@@ -112,13 +112,13 @@ export async function DELETE(request: Request) {
headers: {
"Cache-Control": "no-store",
},
}
},
);
} catch (error) {
console.error("Error deleting category:", error);
return NextResponse.json(
{ error: "Failed to delete category" },
{ status: 500 }
{ status: 500 },
);
}
}

View File

@@ -17,4 +17,3 @@ export async function GET() {
);
}
}

View File

@@ -23,7 +23,7 @@ export async function POST(request: Request) {
console.error("Error creating folder:", error);
return NextResponse.json(
{ error: "Failed to create folder" },
{ status: 500 }
{ status: 500 },
);
}
}
@@ -48,7 +48,7 @@ export async function PUT(request: Request) {
console.error("Error updating folder:", error);
return NextResponse.json(
{ error: "Failed to update folder" },
{ status: 500 }
{ status: 500 },
);
}
}
@@ -64,7 +64,7 @@ export async function DELETE(request: Request) {
if (!id) {
return NextResponse.json(
{ error: "Folder ID is required" },
{ status: 400 }
{ status: 400 },
);
}
@@ -79,7 +79,7 @@ export async function DELETE(request: Request) {
headers: {
"Cache-Control": "no-store",
},
}
},
);
} catch (error) {
if (error instanceof FolderNotFoundError) {
@@ -88,7 +88,7 @@ export async function DELETE(request: Request) {
console.error("Error deleting folder:", error);
return NextResponse.json(
{ error: "Failed to delete folder" },
{ status: 500 }
{ status: 500 },
);
}
}

View File

@@ -31,7 +31,7 @@ export async function POST() {
headers: {
"Cache-Control": "no-store",
},
}
},
);
} catch (error) {
console.error("Error clearing categories:", error);

View File

@@ -64,7 +64,7 @@ export async function GET(request: NextRequest) {
console.error("Error fetching transactions:", error);
return NextResponse.json(
{ error: "Failed to fetch transactions" },
{ status: 500 }
{ status: 500 },
);
}
}
@@ -90,7 +90,7 @@ export async function POST(request: Request) {
console.error("Error creating transactions:", error);
return NextResponse.json(
{ error: "Failed to create transactions" },
{ status: 500 }
{ status: 500 },
);
}
}
@@ -103,7 +103,7 @@ export async function PUT(request: Request) {
const transaction: Transaction = await request.json();
const updated = await transactionService.update(
transaction.id,
transaction
transaction,
);
// Revalider le cache des pages
@@ -120,7 +120,7 @@ export async function PUT(request: Request) {
console.error("Error updating transaction:", error);
return NextResponse.json(
{ error: "Failed to update transaction" },
{ status: 500 }
{ status: 500 },
);
}
}
@@ -136,7 +136,7 @@ export async function DELETE(request: Request) {
if (!id) {
return NextResponse.json(
{ error: "Transaction ID is required" },
{ status: 400 }
{ status: 400 },
);
}
@@ -153,7 +153,7 @@ export async function DELETE(request: Request) {
headers: {
"Cache-Control": "no-store",
},
}
},
);
} catch (error) {
console.error("Error deleting transaction:", error);