Fix TypeScript errors

Fixes TypeScript errors related to missing properties and incorrect exports.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-22 07:12:06 +00:00
parent aa8381a823
commit 81afd624a4
7 changed files with 31 additions and 8 deletions

View File

@@ -1,3 +1,4 @@
import React, { createContext, useState, useContext, useEffect } from 'react'; import React, { createContext, useState, useContext, useEffect } from 'react';
import { BudgetContextType, BudgetData, BudgetPeriod, Transaction, CategoryBudget } from './budget/types'; import { BudgetContextType, BudgetData, BudgetPeriod, Transaction, CategoryBudget } from './budget/types';
import { loadTransactionsFromStorage, saveTransactionsToStorage } from '@/hooks/transactions/storageUtils'; import { loadTransactionsFromStorage, saveTransactionsToStorage } from '@/hooks/transactions/storageUtils';
@@ -119,6 +120,16 @@ export const BudgetProvider: React.FC<{ children: React.ReactNode }> = ({ childr
return result; 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 ( return (
<BudgetContext.Provider value={{ <BudgetContext.Provider value={{
transactions, transactions,
@@ -126,12 +137,13 @@ export const BudgetProvider: React.FC<{ children: React.ReactNode }> = ({ childr
budgetData, budgetData,
selectedTab, selectedTab,
setSelectedTab, setSelectedTab,
addTransaction,
updateTransaction, updateTransaction,
deleteTransaction,
handleBudgetGoalUpdate, handleBudgetGoalUpdate,
getCategorySpending, getCategorySpending,
getPaymentMethodStats, // 추가된 메서드 getPaymentMethodStats,
addTransaction, resetBudgetData,
deleteTransaction,
}}> }}>
{children} {children}
</BudgetContext.Provider> </BudgetContext.Provider>
@@ -146,3 +158,8 @@ export const useBudget = () => {
} }
return context; return context;
}; };
// types 내보내기
export type { BudgetContextType };
export { BudgetPeriod } from './budget/types';
export type { Transaction } from './budget/types';

View File

@@ -2,7 +2,7 @@
import React from 'react'; import React from 'react';
import { useBudgetState } from './useBudgetState'; import { useBudgetState } from './useBudgetState';
import { BudgetContext, BudgetContextType } from './useBudget'; import { BudgetContext, BudgetContextType } from './useBudget';
import { BudgetPeriod } from './types'; import { BudgetPeriod, Transaction } from './types';
// 컨텍스트 프로바이더 컴포넌트 // 컨텍스트 프로바이더 컴포넌트
export const BudgetProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => { 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 { useBudget } from './useBudget';
export type { BudgetContextType } from './useBudget'; export type { BudgetContextType } from './useBudget';
export type { BudgetPeriod } from './types'; // types.ts에서 타입들을 export
export { BudgetPeriod, Transaction } from './types';

View File

@@ -27,10 +27,13 @@ export interface BudgetContextType {
budgetData: BudgetData; budgetData: BudgetData;
selectedTab: BudgetPeriod; selectedTab: BudgetPeriod;
setSelectedTab: (tab: BudgetPeriod) => void; setSelectedTab: (tab: BudgetPeriod) => void;
addTransaction: (transaction: Transaction) => void;
updateTransaction: (updatedTransaction: Transaction) => void; updateTransaction: (updatedTransaction: Transaction) => void;
deleteTransaction: (id: string) => void;
handleBudgetGoalUpdate: (type: BudgetPeriod, amount: number, newCategoryBudgets?: Record<string, number>) => void; handleBudgetGoalUpdate: (type: BudgetPeriod, amount: number, newCategoryBudgets?: Record<string, number>) => void;
getCategorySpending: () => CategoryBudget[]; getCategorySpending: () => CategoryBudget[];
getPaymentMethodStats: () => { method: string; amount: number; percentage: number }[]; getPaymentMethodStats: () => { method: string; amount: number; percentage: number }[];
resetBudgetData?: () => void; // 선택적 필드로 유지
} }
// Transaction 타입 (기존 TransactionCard에서 가져옴) // Transaction 타입 (기존 TransactionCard에서 가져옴)

View File

@@ -1,3 +1,4 @@
import { useContext, createContext } from 'react'; import { useContext, createContext } from 'react';
import { BudgetData, BudgetPeriod, Transaction } from './types'; import { BudgetData, BudgetPeriod, Transaction } from './types';
@@ -17,6 +18,7 @@ export interface BudgetContextType {
updateTransaction: (transaction: Transaction) => void; updateTransaction: (transaction: Transaction) => void;
deleteTransaction: (id: string) => void; deleteTransaction: (id: string) => void;
handleBudgetGoalUpdate: (type: BudgetPeriod, amount: number, newCategoryBudgets?: Record<string, number>) => void; handleBudgetGoalUpdate: (type: BudgetPeriod, amount: number, newCategoryBudgets?: Record<string, number>) => void;
getPaymentMethodStats: () => Array<{ method: string; amount: number; percentage: number }>;
resetBudgetData?: () => void; // 선택적 필드로 추가 resetBudgetData?: () => void; // 선택적 필드로 추가
} }

View File

@@ -1,5 +1,5 @@
import { Transaction } from '@/components/TransactionCard'; import { Transaction } from '@/contexts/budget/types';
import { toast } from '@/hooks/useToast.wrapper'; import { toast } from '@/hooks/useToast.wrapper';
import { EXPENSE_CATEGORIES } from '@/constants/categoryIcons'; import { EXPENSE_CATEGORIES } from '@/constants/categoryIcons';

View File

@@ -1,6 +1,6 @@
import { useCallback } from 'react'; import { useCallback } from 'react';
import { Transaction } from '@/components/TransactionCard'; import { Transaction } from '@/contexts/budget/types';
import { useBudget } from '@/contexts/BudgetContext'; import { useBudget } from '@/contexts/BudgetContext';
export const useTransactionsOperations = (transactions: Transaction[]) => { export const useTransactionsOperations = (transactions: Transaction[]) => {

View File

@@ -1,6 +1,6 @@
import { useCallback } from 'react'; import { useCallback } from 'react';
import { Transaction } from '@/components/TransactionCard'; import { Transaction } from '@/contexts/budget/types';
import { useBudget } from '@/contexts/BudgetContext'; import { useBudget } from '@/contexts/BudgetContext';
export const useTransactionsOperations = (transactions: Transaction[]) => { export const useTransactionsOperations = (transactions: Transaction[]) => {