feat: enhance transaction deletion process with optimistic updates, improved error handling, and restore previous data on failure
This commit is contained in:
@@ -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<{
|
||||
|
||||
Reference in New Issue
Block a user