Fix import error in BudgetContext

The BudgetContext.tsx file was throwing an error because it was trying to import `BudgetPeriod` from the wrong location. Changed the import path to correctly reference the `BudgetPeriod` type.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-22 07:18:07 +00:00
parent b00e27c1f0
commit 56842becca
3 changed files with 50 additions and 77 deletions

View File

@@ -1,38 +1,17 @@
import { useContext, createContext } from 'react';
import { BudgetData, BudgetPeriod, Transaction } from './types';
import { createContext, useContext } from 'react';
import { BudgetContextType } from './types';
// 컨텍스트 인터페이스 정의
export interface BudgetContextType {
transactions: Transaction[];
selectedTab: BudgetPeriod;
setSelectedTab: (tab: BudgetPeriod) => void;
budgetData: BudgetData;
categoryBudgets: Record<string, number>;
getCategorySpending: () => Array<{
title: string;
current: number;
total: number;
}>;
addTransaction: (transaction: Transaction) => void;
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; // 선택적 필드로 추가
}
// 컨텍스트 생성
// BudgetContext 생성
export const BudgetContext = createContext<BudgetContextType | undefined>(undefined);
/**
* 예산 컨텍스트에 접근하기 위한 커스텀 훅
* BudgetProvider 내부에서만 사용해야 함
*/
export const useBudget = (): BudgetContextType => {
// useBudget 훅
export const useBudget = () => {
const context = useContext(BudgetContext);
if (context === undefined) {
throw new Error('useBudget는 BudgetProvider 내부에서 사용해야 합니다');
throw new Error("useBudget must be used within a BudgetProvider");
}
return context;
};
export type { BudgetContextType };