Fix: Wrap components with AuthProvider
The `useAuth` hook was being called outside of the `AuthProvider`, leading to an error. This commit ensures that all components using `useAuth` are wrapped within the `AuthProvider`.
This commit is contained in:
43
src/App.tsx
43
src/App.tsx
@@ -2,6 +2,7 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { Routes, Route } from 'react-router-dom';
|
import { Routes, Route } from 'react-router-dom';
|
||||||
import { BudgetProvider } from './contexts/budget/BudgetContext';
|
import { BudgetProvider } from './contexts/budget/BudgetContext';
|
||||||
|
import { AuthProvider } from './contexts/auth/AuthProvider';
|
||||||
import { Toaster } from './components/ui/toaster';
|
import { Toaster } from './components/ui/toaster';
|
||||||
import Index from './pages/Index';
|
import Index from './pages/Index';
|
||||||
import Login from './pages/Login';
|
import Login from './pages/Login';
|
||||||
@@ -23,26 +24,28 @@ function App() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BudgetProvider>
|
<AuthProvider>
|
||||||
<div className="App">
|
<BudgetProvider>
|
||||||
<Routes>
|
<div className="App">
|
||||||
<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="/settings" element={<Settings />} />
|
||||||
<Route path="/analytics" element={<Analytics />} />
|
<Route path="/transactions" element={<Transactions />} />
|
||||||
<Route path="/profile" element={<ProfileManagement />} />
|
<Route path="/analytics" element={<Analytics />} />
|
||||||
<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="/help-support" element={<HelpSupport />} />
|
||||||
<Route path="/notifications" element={<NotificationSettings />} />
|
<Route path="/security-privacy" element={<SecurityPrivacySettings />} />
|
||||||
<Route path="/forgot-password" element={<ForgotPassword />} />
|
<Route path="/notifications" element={<NotificationSettings />} />
|
||||||
<Route path="*" element={<NotFound />} />
|
<Route path="/forgot-password" element={<ForgotPassword />} />
|
||||||
</Routes>
|
<Route path="*" element={<NotFound />} />
|
||||||
<Toaster />
|
</Routes>
|
||||||
</div>
|
<Toaster />
|
||||||
</BudgetProvider>
|
</div>
|
||||||
|
</BudgetProvider>
|
||||||
|
</AuthProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user