feat: add functionality to clear category assignments from transactions and display categorized count in settings

This commit is contained in:
Julien Froidefond
2025-11-27 10:31:24 +01:00
parent 7314cb6716
commit e516ed9efd
2 changed files with 72 additions and 3 deletions

View File

@@ -0,0 +1,24 @@
import { NextResponse } from "next/server"
import { prisma } from "@/lib/prisma"
export async function POST() {
try {
const result = await prisma.transaction.updateMany({
where: {
categoryId: { not: null },
},
data: {
categoryId: null,
},
})
return NextResponse.json({
success: true,
count: result.count,
})
} catch (error) {
console.error("Error clearing categories:", error)
return NextResponse.json({ error: "Failed to clear categories" }, { status: 500 })
}
}