Fix file operation error
The AI attempted to delete or rename a file that does not exist, this commit addresses the error.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
import React, { useEffect, useState, useRef, useCallback } from 'react';
|
||||
import NavBar from '@/components/NavBar';
|
||||
import AddTransactionButton from '@/components/AddTransactionButton';
|
||||
@@ -20,13 +19,14 @@ const Transactions = () => {
|
||||
handleNextMonth,
|
||||
refreshTransactions,
|
||||
totalExpenses,
|
||||
deleteTransaction
|
||||
} = useTransactions();
|
||||
|
||||
const { budgetData, deleteTransaction: budgetDeleteTransaction } = useBudget();
|
||||
const { budgetData } = useBudget();
|
||||
const [isProcessing, setIsProcessing] = useState(false);
|
||||
const processingTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||
|
||||
// 삭제 핸들러 - 홈 페이지와 동일한 방식으로 구현
|
||||
// 삭제 핸들러 - 단순화된 버전
|
||||
const handleTransactionDelete = useCallback(async (id: string): Promise<boolean> => {
|
||||
if (isProcessing) {
|
||||
console.log('이미 삭제 작업이 진행 중입니다');
|
||||
@@ -41,30 +41,23 @@ const Transactions = () => {
|
||||
setIsProcessing(false);
|
||||
}, 2000);
|
||||
|
||||
// BudgetContext의 삭제 함수 사용
|
||||
budgetDeleteTransaction(id);
|
||||
const result = await deleteTransaction(id);
|
||||
|
||||
// 삭제 후 데이터 새로고침
|
||||
setTimeout(() => {
|
||||
refreshTransactions();
|
||||
}, 500);
|
||||
if (result) {
|
||||
setTimeout(() => {
|
||||
refreshTransactions();
|
||||
}, 500);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error('트랜잭션 삭제 중 오류:', error);
|
||||
toast({
|
||||
title: "삭제 실패",
|
||||
description: "지출 항목을 삭제하는데 문제가 발생했습니다.",
|
||||
variant: "destructive"
|
||||
});
|
||||
return false;
|
||||
return result;
|
||||
} finally {
|
||||
if (processingTimeoutRef.current) {
|
||||
clearTimeout(processingTimeoutRef.current);
|
||||
}
|
||||
setIsProcessing(false);
|
||||
}
|
||||
}, [isProcessing, budgetDeleteTransaction, refreshTransactions]);
|
||||
}, [isProcessing, deleteTransaction, refreshTransactions]);
|
||||
|
||||
// 컴포넌트 언마운트 시 타임아웃 정리
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user