Refactor transaction sync module

Refactors the transaction sync module for better organization.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-16 10:05:06 +00:00
parent e3e29d6ebe
commit 74e7ea19fd
7 changed files with 264 additions and 231 deletions

View File

@@ -0,0 +1,35 @@
import { supabase } from '@/lib/supabase';
import { isSyncEnabled } from '../syncSettings';
import { toast } from '@/hooks/useToast.wrapper';
/**
* 특정 트랜잭션 ID 삭제 처리
*/
export const deleteTransactionFromServer = async (userId: string, transactionId: string): Promise<void> => {
if (!isSyncEnabled()) return;
try {
console.log(`트랜잭션 삭제 요청: ${transactionId}`);
const { error } = await supabase
.from('transactions')
.delete()
.eq('transaction_id', transactionId)
.eq('user_id', userId);
if (error) {
console.error('트랜잭션 삭제 실패:', error);
throw error;
}
console.log(`트랜잭션 ${transactionId} 삭제 완료`);
} catch (error) {
console.error('트랜잭션 삭제 중 오류:', error);
// 에러 발생 시 토스트 알림
toast({
title: "삭제 동기화 실패",
description: "서버에서 트랜잭션을 삭제하는데 문제가 발생했습니다.",
variant: "destructive"
});
}
};