Refactor transaction sync module
Refactors the transaction sync module for better organization.
This commit is contained in:
35
src/utils/sync/transaction/deleteTransaction.ts
Normal file
35
src/utils/sync/transaction/deleteTransaction.ts
Normal 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"
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user