feat : add signin ,signout, forgot password features

This commit is contained in:
ghazall-ag
2025-10-29 22:43:48 +03:30
parent 46a1fae510
commit 5079a5bc56
63 changed files with 2920 additions and 125 deletions

View File

@@ -1,16 +1,18 @@
import React from 'react';
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
import { AuthProvider, useAuth } from './context/AuthContext';
import { useAuthStore } from './store/authStore';
import Sidebar from './components/Sidebar';
import Navbar from './components/Navbar';
import Login from './pages/Login';
import Dashboard from './pages/Dashboard';
import Transactions from './pages/Transactions';
import Settings from './pages/Settings';
import ForgotPassword from './pages/ForgotPassword';
// Protected Route Component
const ProtectedRoute = ({ children }) => {
const { isAuthenticated, loading } = useAuth();
const isLoggedIn = useAuthStore((s) => s.isLoggedIn);
const loading = useAuthStore((s) => s.loading);
if (loading) {
return (
@@ -20,7 +22,7 @@ const ProtectedRoute = ({ children }) => {
);
}
return isAuthenticated ? children : <Navigate to="/login" />;
return isLoggedIn ? children : <Navigate to="/login" />;
};
// Main Layout Component
@@ -58,6 +60,7 @@ const AppRoutes = () => {
return (
<Routes>
<Route path="/login" element={<Login />} />
<Route path="/forgot-password" element={<ForgotPassword />} />
<Route
path="/"
element={
@@ -96,13 +99,11 @@ const AppRoutes = () => {
// Main App Component
const App = () => {
return (
<AuthProvider>
<Router>
<div className="App">
<AppRoutes />
</div>
</Router>
</AuthProvider>
<Router>
<div className="App">
<AppRoutes />
</div>
</Router>
);
};