Fix TypeScript errors
Fixes TypeScript errors related to missing properties and incorrect exports.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
|
||||
import React, { createContext, useState, useContext, useEffect } from 'react';
|
||||
import { BudgetContextType, BudgetData, BudgetPeriod, Transaction, CategoryBudget } from './budget/types';
|
||||
import { loadTransactionsFromStorage, saveTransactionsToStorage } from '@/hooks/transactions/storageUtils';
|
||||
@@ -118,6 +119,16 @@ export const BudgetProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// 예산 데이터 재설정 함수 추가
|
||||
const resetBudgetData = () => {
|
||||
setBudgetData({
|
||||
daily: { targetAmount: 0, spentAmount: 0, remainingAmount: 0 },
|
||||
weekly: { targetAmount: 0, spentAmount: 0, remainingAmount: 0 },
|
||||
monthly: { targetAmount: 0, spentAmount: 0, remainingAmount: 0 },
|
||||
});
|
||||
setCategoryBudgets({});
|
||||
};
|
||||
|
||||
return (
|
||||
<BudgetContext.Provider value={{
|
||||
@@ -126,12 +137,13 @@ export const BudgetProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
||||
budgetData,
|
||||
selectedTab,
|
||||
setSelectedTab,
|
||||
addTransaction,
|
||||
updateTransaction,
|
||||
deleteTransaction,
|
||||
handleBudgetGoalUpdate,
|
||||
getCategorySpending,
|
||||
getPaymentMethodStats, // 추가된 메서드
|
||||
addTransaction,
|
||||
deleteTransaction,
|
||||
getPaymentMethodStats,
|
||||
resetBudgetData,
|
||||
}}>
|
||||
{children}
|
||||
</BudgetContext.Provider>
|
||||
@@ -146,3 +158,8 @@ export const useBudget = () => {
|
||||
}
|
||||
return context;
|
||||
};
|
||||
|
||||
// types 내보내기
|
||||
export type { BudgetContextType };
|
||||
export { BudgetPeriod } from './budget/types';
|
||||
export type { Transaction } from './budget/types';
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import React from 'react';
|
||||
import { useBudgetState } from './useBudgetState';
|
||||
import { BudgetContext, BudgetContextType } from './useBudget';
|
||||
import { BudgetPeriod } from './types';
|
||||
import { BudgetPeriod, Transaction } from './types';
|
||||
|
||||
// 컨텍스트 프로바이더 컴포넌트
|
||||
export const BudgetProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||
@@ -19,4 +19,5 @@ export const BudgetProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
||||
export { useBudget } from './useBudget';
|
||||
export type { BudgetContextType } from './useBudget';
|
||||
|
||||
export type { BudgetPeriod } from './types';
|
||||
// types.ts에서 타입들을 export
|
||||
export { BudgetPeriod, Transaction } from './types';
|
||||
|
||||
@@ -27,10 +27,13 @@ export interface BudgetContextType {
|
||||
budgetData: BudgetData;
|
||||
selectedTab: BudgetPeriod;
|
||||
setSelectedTab: (tab: BudgetPeriod) => void;
|
||||
addTransaction: (transaction: Transaction) => void;
|
||||
updateTransaction: (updatedTransaction: Transaction) => void;
|
||||
deleteTransaction: (id: string) => void;
|
||||
handleBudgetGoalUpdate: (type: BudgetPeriod, amount: number, newCategoryBudgets?: Record<string, number>) => void;
|
||||
getCategorySpending: () => CategoryBudget[];
|
||||
getPaymentMethodStats: () => { method: string; amount: number; percentage: number }[];
|
||||
resetBudgetData?: () => void; // 선택적 필드로 유지
|
||||
}
|
||||
|
||||
// Transaction 타입 (기존 TransactionCard에서 가져옴)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
import { useContext, createContext } from 'react';
|
||||
import { BudgetData, BudgetPeriod, Transaction } from './types';
|
||||
|
||||
@@ -17,6 +18,7 @@ export interface BudgetContextType {
|
||||
updateTransaction: (transaction: Transaction) => void;
|
||||
deleteTransaction: (id: string) => void;
|
||||
handleBudgetGoalUpdate: (type: BudgetPeriod, amount: number, newCategoryBudgets?: Record<string, number>) => void;
|
||||
getPaymentMethodStats: () => Array<{ method: string; amount: number; percentage: number }>;
|
||||
resetBudgetData?: () => void; // 선택적 필드로 추가
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import { Transaction } from '@/components/TransactionCard';
|
||||
import { Transaction } from '@/contexts/budget/types';
|
||||
import { toast } from '@/hooks/useToast.wrapper';
|
||||
import { EXPENSE_CATEGORIES } from '@/constants/categoryIcons';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
import { useCallback } from 'react';
|
||||
import { Transaction } from '@/components/TransactionCard';
|
||||
import { Transaction } from '@/contexts/budget/types';
|
||||
import { useBudget } from '@/contexts/BudgetContext';
|
||||
|
||||
export const useTransactionsOperations = (transactions: Transaction[]) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
import { useCallback } from 'react';
|
||||
import { Transaction } from '@/components/TransactionCard';
|
||||
import { Transaction } from '@/contexts/budget/types';
|
||||
import { useBudget } from '@/contexts/BudgetContext';
|
||||
|
||||
export const useTransactionsOperations = (transactions: Transaction[]) => {
|
||||
|
||||
Reference in New Issue
Block a user