feat: enhance transaction deletion process with optimistic updates, improved error handling, and restore previous data on failure

This commit is contained in:
Julien Froidefond
2025-12-08 08:52:47 +01:00
parent 4224c8aa83
commit 28baf9aa9e
4 changed files with 48 additions and 6 deletions

View File

@@ -119,9 +119,16 @@ export const transactionService = {
},
async delete(id: string): Promise<void> {
await prisma.transaction.delete({
where: { id },
});
try {
await prisma.transaction.delete({
where: { id },
});
} catch (error: any) {
if (error.code === "P2025") {
throw new Error(`Transaction with id ${id} not found`);
}
throw error;
}
},
async deduplicate(): Promise<{