Fix: Resolve issue with transaction display
Addresses a bug where transactions were not displayed on the transaction history page and expense amounts were showing as zero.
This commit is contained in:
@@ -3,6 +3,7 @@ import { useCallback, useRef } from 'react';
|
||||
import { Transaction } from '@/components/TransactionCard';
|
||||
import { useAuth } from '@/contexts/auth/AuthProvider';
|
||||
import { useDeleteTransactionCore } from './deleteOperation/deleteTransactionCore';
|
||||
import { toast } from '@/hooks/useToast.wrapper';
|
||||
|
||||
/**
|
||||
* 트랜잭션 삭제 기능
|
||||
@@ -17,5 +18,42 @@ export const useDeleteTransaction = (
|
||||
const { user } = useAuth();
|
||||
|
||||
// 핵심 삭제 로직 사용
|
||||
return useDeleteTransactionCore(transactions, setTransactions, user, pendingDeletionRef);
|
||||
const deleteTransactionHandler = useDeleteTransactionCore(transactions, setTransactions, user, pendingDeletionRef);
|
||||
|
||||
// 디버깅 추가
|
||||
const deleteTransaction = useCallback((id: string) => {
|
||||
console.log('트랜잭션 삭제 시작:', id);
|
||||
|
||||
try {
|
||||
// 이미 삭제 중인지 확인
|
||||
if (pendingDeletionRef.current.has(id)) {
|
||||
console.log('이미 삭제 중인 트랜잭션:', id);
|
||||
return;
|
||||
}
|
||||
|
||||
// 트랜잭션이 존재하는지 확인
|
||||
const transactionExists = transactions.some(t => t.id === id);
|
||||
if (!transactionExists) {
|
||||
console.error('존재하지 않는 트랜잭션 ID:', id);
|
||||
toast({
|
||||
title: "삭제 실패",
|
||||
description: "존재하지 않는 트랜잭션입니다.",
|
||||
variant: "destructive"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 삭제 실행
|
||||
return deleteTransactionHandler(id);
|
||||
} catch (error) {
|
||||
console.error('트랜잭션 삭제 오류:', error);
|
||||
toast({
|
||||
title: "삭제 실패",
|
||||
description: "트랜잭션 삭제 중 오류가 발생했습니다.",
|
||||
variant: "destructive"
|
||||
});
|
||||
}
|
||||
}, [transactions, deleteTransactionHandler]);
|
||||
|
||||
return deleteTransaction;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user