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 React, { useState, useEffect } from 'react';
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
|
|||||||
@@ -42,12 +42,17 @@ export const downloadBudgets = async (userId: string): Promise<void> => {
|
|||||||
* 예산 데이터 조회
|
* 예산 데이터 조회
|
||||||
*/
|
*/
|
||||||
async function fetchBudgetData(userId: string) {
|
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
|
const { data, error } = await supabase
|
||||||
.from('budgets')
|
.from('budgets')
|
||||||
.select('*')
|
.select('*')
|
||||||
.eq('user_id', userId)
|
.eq('user_id', userId)
|
||||||
.order('created_at', { ascending: false })
|
.eq('month', currentMonth)
|
||||||
.limit(1); // 가장 최근 데이터
|
.eq('year', currentYear);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('예산 데이터 조회 실패:', error);
|
console.error('예산 데이터 조회 실패:', error);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import { isSyncEnabled, setSyncEnabled, getLastSyncTime, setLastSyncTime, initSyncSettings } from './sync/syncSettings';
|
import { isSyncEnabled, setSyncEnabled, getLastSyncTime, setLastSyncTime, initSyncSettings } from './sync/syncSettings';
|
||||||
import { uploadTransactions, downloadTransactions, deleteTransactionFromServer } from './sync/transactionSync';
|
import { uploadTransactions, downloadTransactions, deleteTransactionFromServer } from './sync/transactionSync';
|
||||||
import { uploadBudgets, downloadBudgets } from './sync/budget';
|
import { uploadBudgets, downloadBudgets } from './sync/budget';
|
||||||
|
|||||||
Reference in New Issue
Block a user