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:
79
src/App.tsx
79
src/App.tsx
@@ -1,52 +1,47 @@
|
|||||||
|
import React, { useEffect } from 'react';
|
||||||
import React from 'react';
|
import { Routes, Route } from 'react-router-dom';
|
||||||
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
|
import { BudgetProvider } from './contexts/budget/BudgetContext';
|
||||||
|
import { Toaster } from './components/ui/toaster';
|
||||||
import Index from './pages/Index';
|
import Index from './pages/Index';
|
||||||
import Settings from './pages/Settings';
|
|
||||||
import Login from './pages/Login';
|
import Login from './pages/Login';
|
||||||
import Register from './pages/Register';
|
import Register from './pages/Register';
|
||||||
import ForgotPassword from './pages/ForgotPassword';
|
import Settings from './pages/Settings';
|
||||||
import NotFound from './pages/NotFound';
|
|
||||||
import SecurityPrivacySettings from './pages/SecurityPrivacySettings';
|
|
||||||
import ProfileManagement from './pages/ProfileManagement';
|
|
||||||
import PaymentMethods from './pages/PaymentMethods';
|
|
||||||
import NotificationSettings from './pages/NotificationSettings';
|
|
||||||
import HelpSupport from './pages/HelpSupport';
|
|
||||||
import Analytics from './pages/Analytics';
|
|
||||||
import Transactions from './pages/Transactions';
|
import Transactions from './pages/Transactions';
|
||||||
import { AuthProvider } from './contexts/auth';
|
import Analytics from './pages/Analytics';
|
||||||
import { BudgetProvider } from './contexts/BudgetContext';
|
import ProfileManagement from './pages/ProfileManagement';
|
||||||
import { Toaster } from '@/components/ui/toaster';
|
import NotFound from './pages/NotFound';
|
||||||
import { Toaster as SonnerToaster} from '@/components/ui/sonner';
|
import PaymentMethods from './pages/PaymentMethods';
|
||||||
import SafeAreaContainer from './components/SafeAreaContainer';
|
import HelpSupport from './pages/HelpSupport';
|
||||||
|
import SecurityPrivacySettings from './pages/SecurityPrivacySettings';
|
||||||
|
import NotificationSettings from './pages/NotificationSettings';
|
||||||
|
import ForgotPassword from './pages/ForgotPassword';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
useEffect(() => {
|
||||||
|
document.title = "적자 탈출 가계부";
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthProvider>
|
<BudgetProvider>
|
||||||
<BudgetProvider>
|
<div className="App">
|
||||||
<Router>
|
<Routes>
|
||||||
<SafeAreaContainer className="min-h-screen bg-neuro-background">
|
<Route path="/" element={<Index />} />
|
||||||
<Routes>
|
<Route path="/login" element={<Login />} />
|
||||||
<Route path="/" element={<Index />} />
|
<Route path="/register" element={<Register />} />
|
||||||
<Route path="/login" element={<Login />} />
|
<Route path="/settings" element={<Settings />} />
|
||||||
<Route path="/register" element={<Register />} />
|
<Route path="/transactions" element={<Transactions />} />
|
||||||
<Route path="/forgot-password" element={<ForgotPassword />} />
|
<Route path="/analytics" element={<Analytics />} />
|
||||||
<Route path="/settings" element={<Settings />} />
|
<Route path="/profile" element={<ProfileManagement />} />
|
||||||
<Route path="/security-privacy" element={<SecurityPrivacySettings />} />
|
<Route path="/payment-methods" element={<PaymentMethods />} />
|
||||||
<Route path="/profile" element={<ProfileManagement />} />
|
<Route path="/help-support" element={<HelpSupport />} />
|
||||||
<Route path="/payment-methods" element={<PaymentMethods />} />
|
<Route path="/security-privacy" element={<SecurityPrivacySettings />} />
|
||||||
<Route path="/notifications" element={<NotificationSettings />} />
|
<Route path="/notifications" element={<NotificationSettings />} />
|
||||||
<Route path="/help-support" element={<HelpSupport />} />
|
<Route path="/forgot-password" element={<ForgotPassword />} />
|
||||||
<Route path="/analytics" element={<Analytics />} />
|
<Route path="*" element={<NotFound />} />
|
||||||
<Route path="/transactions" element={<Transactions />} />
|
</Routes>
|
||||||
<Route path="*" element={<NotFound />} />
|
<Toaster />
|
||||||
</Routes>
|
</div>
|
||||||
</SafeAreaContainer>
|
</BudgetProvider>
|
||||||
<Toaster />
|
|
||||||
<SonnerToaster />
|
|
||||||
</Router>
|
|
||||||
</BudgetProvider>
|
|
||||||
</AuthProvider>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
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, Transaction, CategoryBudget } from './budget/types';
|
||||||
import { loadTransactionsFromStorage, saveTransactionsToStorage } from '@/hooks/transactions/storageUtils';
|
import { loadTransactionsFromStorage, saveTransactionsToStorage } from '@/hooks/transactions/storageUtils';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
@@ -16,7 +15,7 @@ export const BudgetProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
|||||||
weekly: { targetAmount: 0, spentAmount: 0, remainingAmount: 0 },
|
weekly: { targetAmount: 0, spentAmount: 0, remainingAmount: 0 },
|
||||||
monthly: { targetAmount: 0, spentAmount: 0, remainingAmount: 0 },
|
monthly: { targetAmount: 0, spentAmount: 0, remainingAmount: 0 },
|
||||||
});
|
});
|
||||||
const [selectedTab, setSelectedTab] = useState<BudgetPeriod>('monthly');
|
const [selectedTab, setSelectedTab] = useState<'daily' | 'weekly' | 'monthly'>('monthly');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const storedTransactions = loadTransactionsFromStorage();
|
const storedTransactions = loadTransactionsFromStorage();
|
||||||
@@ -51,7 +50,7 @@ export const BudgetProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 예산 목표 업데이트
|
// 예산 목표 업데이트
|
||||||
const handleBudgetGoalUpdate = (type: BudgetPeriod, amount: number, newCategoryBudgets?: Record<string, number>) => {
|
const handleBudgetGoalUpdate = (type: 'daily' | 'weekly' | 'monthly', amount: number, newCategoryBudgets?: Record<string, number>) => {
|
||||||
setBudgetData(prev => ({
|
setBudgetData(prev => ({
|
||||||
...prev,
|
...prev,
|
||||||
[type]: {
|
[type]: {
|
||||||
@@ -159,7 +158,7 @@ export const useBudget = () => {
|
|||||||
return context;
|
return context;
|
||||||
};
|
};
|
||||||
|
|
||||||
// types 내보내기
|
// 타입 내보내기를 수정
|
||||||
export type { BudgetContextType };
|
export type { BudgetContextType };
|
||||||
export { BudgetPeriod } from './budget/types';
|
|
||||||
export type { Transaction } from './budget/types';
|
export type { Transaction } from './budget/types';
|
||||||
|
export { type BudgetPeriod } from './budget/types';
|
||||||
|
|||||||
@@ -1,38 +1,17 @@
|
|||||||
|
|
||||||
import { useContext, createContext } from 'react';
|
import { createContext, useContext } from 'react';
|
||||||
import { BudgetData, BudgetPeriod, Transaction } from './types';
|
import { BudgetContextType } from './types';
|
||||||
|
|
||||||
// 컨텍스트 인터페이스 정의
|
// BudgetContext 생성
|
||||||
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; // 선택적 필드로 추가
|
|
||||||
}
|
|
||||||
|
|
||||||
// 컨텍스트 생성
|
|
||||||
export const BudgetContext = createContext<BudgetContextType | undefined>(undefined);
|
export const BudgetContext = createContext<BudgetContextType | undefined>(undefined);
|
||||||
|
|
||||||
/**
|
// useBudget 훅
|
||||||
* 예산 컨텍스트에 접근하기 위한 커스텀 훅
|
export const useBudget = () => {
|
||||||
* BudgetProvider 내부에서만 사용해야 함
|
|
||||||
*/
|
|
||||||
export const useBudget = (): BudgetContextType => {
|
|
||||||
const context = useContext(BudgetContext);
|
const context = useContext(BudgetContext);
|
||||||
if (context === undefined) {
|
if (context === undefined) {
|
||||||
throw new Error('useBudget는 BudgetProvider 내부에서 사용해야 합니다');
|
throw new Error("useBudget must be used within a BudgetProvider");
|
||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type { BudgetContextType };
|
||||||
|
|||||||
Reference in New Issue
Block a user