Fix TypeScript errors
Fixes TypeScript errors related to type assignments and declaration conflicts. Specifically, addresses the type mismatch in `TransactionEditDialog.tsx` and declaration conflicts in `deleteTransactionStorage.ts`.
This commit is contained in:
@@ -78,43 +78,48 @@ const TransactionEditDialog: React.FC<TransactionEditDialogProps> = ({
|
||||
});
|
||||
};
|
||||
|
||||
const handleDelete = () => {
|
||||
try {
|
||||
// 다이얼로그 닫기를 먼저 수행 (UI 블로킹 방지)
|
||||
onOpenChange(false);
|
||||
|
||||
// 잠시 지연 후 삭제 작업 수행 (안정성 향상)
|
||||
setTimeout(() => {
|
||||
try {
|
||||
// 트랜잭션 ID 임시 저장 (안전성 확보)
|
||||
const transactionId = transaction.id;
|
||||
|
||||
// 부모 컴포넌트의 onDelete 콜백이 있다면 호출
|
||||
if (onDelete) {
|
||||
onDelete(transactionId);
|
||||
const handleDelete = (): Promise<boolean> => {
|
||||
return new Promise<boolean>((resolve) => {
|
||||
try {
|
||||
// 다이얼로그 닫기를 먼저 수행 (UI 블로킹 방지)
|
||||
onOpenChange(false);
|
||||
|
||||
// 잠시 지연 후 삭제 작업 수행 (안정성 향상)
|
||||
setTimeout(() => {
|
||||
try {
|
||||
// 트랜잭션 ID 임시 저장 (안전성 확보)
|
||||
const transactionId = transaction.id;
|
||||
|
||||
// 부모 컴포넌트의 onDelete 콜백이 있다면 호출
|
||||
if (onDelete) {
|
||||
onDelete(transactionId);
|
||||
}
|
||||
|
||||
// 컨텍스트를 통해 트랜잭션 삭제
|
||||
deleteTransaction(transactionId);
|
||||
|
||||
console.log('트랜잭션 삭제 완료:', transactionId);
|
||||
resolve(true);
|
||||
} catch (innerError) {
|
||||
console.error('트랜잭션 삭제 중 내부 오류:', innerError);
|
||||
toast({
|
||||
title: "삭제 실패",
|
||||
description: "지출 항목을 삭제하는데 문제가 발생했습니다.",
|
||||
variant: "destructive"
|
||||
});
|
||||
resolve(false);
|
||||
}
|
||||
|
||||
// 컨텍스트를 통해 트랜잭션 삭제
|
||||
deleteTransaction(transactionId);
|
||||
|
||||
console.log('트랜잭션 삭제 완료:', transactionId);
|
||||
} catch (innerError) {
|
||||
console.error('트랜잭션 삭제 중 내부 오류:', innerError);
|
||||
toast({
|
||||
title: "삭제 실패",
|
||||
description: "지출 항목을 삭제하는데 문제가 발생했습니다.",
|
||||
variant: "destructive"
|
||||
});
|
||||
}
|
||||
}, 100);
|
||||
} catch (outerError) {
|
||||
console.error('트랜잭션 삭제 처리 중 오류:', outerError);
|
||||
toast({
|
||||
title: "시스템 오류",
|
||||
description: "처리 중 문제가 발생했습니다. 다시 시도해주세요.",
|
||||
variant: "destructive"
|
||||
});
|
||||
}
|
||||
}, 100);
|
||||
} catch (outerError) {
|
||||
console.error('트랜잭션 삭제 처리 중 오류:', outerError);
|
||||
toast({
|
||||
title: "시스템 오류",
|
||||
description: "처리 중 문제가 발생했습니다. 다시 시도해주세요.",
|
||||
variant: "destructive"
|
||||
});
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { MutableRefObject } from 'react';
|
||||
import { Transaction } from '@/components/TransactionCard';
|
||||
import { saveTransactionsToStorage } from '../../storageUtils';
|
||||
import { deleteTransactionFromSupabase } from '../../supabaseUtils';
|
||||
import { deleteTransactionFromSupabase as deleteFromSupabase } from '../../supabaseUtils';
|
||||
import { toast } from '@/hooks/useToast.wrapper';
|
||||
import { normalizeDate } from '@/utils/sync/transaction/dateUtils';
|
||||
|
||||
@@ -33,7 +33,7 @@ export const handleDeleteStorage = (
|
||||
setTimeout(() => {
|
||||
try {
|
||||
// 동기화 작업 실행
|
||||
deleteTransactionFromSupabase(user, id)
|
||||
deleteFromSupabase(user, id)
|
||||
.catch(error => {
|
||||
console.error('Supabase 삭제 오류:', error);
|
||||
})
|
||||
@@ -105,11 +105,4 @@ export const handleDeleteStorage = (
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Supabase에서 트랜잭션 삭제
|
||||
*/
|
||||
export const deleteTransactionFromSupabase = async (user: any, transactionId: string): Promise<void> => {
|
||||
// supabaseUtils에서 구현된 함수 사용
|
||||
// 이 함수는 네트워크 요청을 처리합니다
|
||||
return;
|
||||
};
|
||||
// 내부 함수 선언 제거 (supabaseUtils.ts에서 가져오기 때문에 중복 선언할 필요 없음)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import { useCallback, useRef, useEffect } from 'react';
|
||||
import { Transaction } from '@/components/TransactionCard';
|
||||
import { useAuth } from '@/contexts/auth/AuthProvider';
|
||||
|
||||
Reference in New Issue
Block a user