Fix budget synchronization issue
Ensure budget data is also synchronized when syncing with cloud after local data deletion.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
@@ -42,12 +42,17 @@ export const downloadBudgets = async (userId: string): Promise<void> => {
|
||||
* 예산 데이터 조회
|
||||
*/
|
||||
async function fetchBudgetData(userId: string) {
|
||||
// 현재 월/년도 가져오기
|
||||
const now = new Date();
|
||||
const currentMonth = now.getMonth() + 1; // 0-11 -> 1-12
|
||||
const currentYear = now.getFullYear();
|
||||
|
||||
const { data, error } = await supabase
|
||||
.from('budgets')
|
||||
.select('*')
|
||||
.eq('user_id', userId)
|
||||
.order('created_at', { ascending: false })
|
||||
.limit(1); // 가장 최근 데이터
|
||||
.eq('month', currentMonth)
|
||||
.eq('year', currentYear);
|
||||
|
||||
if (error) {
|
||||
console.error('예산 데이터 조회 실패:', error);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
import { isSyncEnabled, setSyncEnabled, getLastSyncTime, setLastSyncTime, initSyncSettings } from './sync/syncSettings';
|
||||
import { uploadTransactions, downloadTransactions, deleteTransactionFromServer } from './sync/transactionSync';
|
||||
import { uploadBudgets, downloadBudgets } from './sync/budget';
|
||||
|
||||
Reference in New Issue
Block a user