From 1136683b572c263089a1c18f2c8afa641cbc41a2 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 16:32:07 +0000 Subject: [PATCH] Ensure useBudget is within BudgetProvider The useBudget hook was throwing an error when used outside of a BudgetProvider. This commit ensures that the useBudget hook is always used within a BudgetProvider to prevent this error. --- src/App.tsx | 49 +++++++++++++++++++------------------ src/pages/Index.tsx | 59 +++++++++++++++++++-------------------------- 2 files changed, 51 insertions(+), 57 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 7138416..81b93cd 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -19,6 +19,7 @@ import ForgotPassword from './pages/ForgotPassword'; import Analytics from './pages/Analytics'; import PaymentMethods from './pages/PaymentMethods'; import Settings from './pages/Settings'; +import { BudgetProvider } from './contexts/BudgetContext'; // 전역 오류 핸들러 const handleError = (error: any) => { @@ -74,30 +75,32 @@ function App() { return ( - -
- -
- - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - + + +
+ +
+ + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + +
+
- -
- + + ); diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index feb2220..f96ca5f 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -7,10 +7,10 @@ import BudgetProgressCard from '@/components/BudgetProgressCard'; import BudgetCategoriesSection from '@/components/BudgetCategoriesSection'; import RecentTransactionsSection from '@/components/RecentTransactionsSection'; import { formatCurrency, calculatePercentage } from '@/utils/formatters'; -import { BudgetProvider, useBudget } from '@/contexts/BudgetContext'; +import { useBudget } from '@/contexts/BudgetContext'; // 메인 컴포넌트 -const IndexContent = () => { +const Index = () => { const { transactions, budgetData, @@ -22,43 +22,34 @@ const IndexContent = () => { } = useBudget(); return ( -
-
+
+
+
- {/* 목표 진행 상황 */} -

예산과 지출

- + {/* 목표 진행 상황 */} +

예산과 지출

+ - {/* 지출 카테고리 */} - + {/* 지출 카테고리 */} + - {/* 최근 지출 */} - + {/* 최근 지출 */} + +
+ +
); }; -// Provider를 감싼 컨테이너 컴포넌트 -const Index = () => { - return ( - -
- - - -
-
- ); -}; - export default Index;