Investigate transaction deletion issue

Further investigate the issue where deleting transactions causes the application to freeze.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-18 05:17:41 +00:00
parent 0ed4073bfd
commit 152586cd1b
4 changed files with 100 additions and 113 deletions

View File

@@ -7,6 +7,7 @@ import { useTransactions } from '@/hooks/transactions';
import TransactionsHeader from '@/components/transactions/TransactionsHeader';
import TransactionsContent from '@/components/transactions/TransactionsContent';
import { Transaction } from '@/components/TransactionCard';
import { toast } from '@/hooks/useToast.wrapper';
const Transactions = () => {
const {
@@ -43,40 +44,38 @@ const Transactions = () => {
}
try {
console.log('Transactions 페이지에서 트랜잭션 삭제:', id);
// 삭제 중임을 표시
setIsProcessing(true);
setDeletingId(id);
// 간소화된 삭제 작업 실행
console.log('트랜잭션 삭제 시작 (ID):', id);
// deleteTransaction 함수 호출 (Promise<boolean> 반환 예상)
const success = await deleteTransaction(id);
// 상태 초기화
setTimeout(() => {
setIsProcessing(false);
setDeletingId(null);
}, 300);
// 성공 여부와 관계없이 데이터 새로고침
setTimeout(() => {
refreshTransactions();
}, 500);
console.log('삭제 작업 결과:', success);
return success;
} catch (error) {
console.error('트랜잭션 삭제 처리 중 오류:', error);
// 오류 발생 시 상태 초기화
setIsProcessing(false);
setDeletingId(null);
// 오류 후에도 데이터 새로고침 (일관성 유지)
setTimeout(() => {
refreshTransactions();
}, 500);
// 오류 발생 시 토스트 표시
toast({
title: "삭제 실패",
description: "지출 삭제 중 오류가 발생했습니다.",
variant: "destructive"
});
return false;
} finally {
// 상태 초기화 (약간의 지연 후)
setTimeout(() => {
setIsProcessing(false);
setDeletingId(null);
// 데이터 새로고침 (삭제 후 UI 업데이트)
refreshTransactions();
}, 500);
}
};