11import React , { useEffect , useState } from 'react' ;
22import { BrowserRouter as Router , Routes , Route , Navigate } from 'react-router-dom' ;
33import { AnimatePresence } from 'framer-motion' ;
4+ import { Toaster } from 'react-hot-toast' ;
45import Sidebar from './components/layout/Sidebar' ;
56import Dashboard from './components/dashboard/Dashboard' ;
6-
7-
87import BotIntegrationPage from './components/integration/BotIntegrationPage' ;
98import ContributorsPage from './components/contributors/ContributorsPage' ;
109import PullRequestsPage from './components/pages/PullRequestsPage' ;
1110import SettingsPage from './components/pages/SettingsPage' ;
1211import AnalyticsPage from './components/pages/AnalyticsPage' ;
1312import SupportPage from './components/pages/SupportPage' ;
1413import LandingPage from './components/landing/LandingPage' ;
14+ import LoginPage from './components/pages/LoginPage' ;
15+ import ProfilePage from './components/pages/ProfilePage' ;
1516
1617function App ( ) {
1718 const [ isSidebarOpen , setIsSidebarOpen ] = useState ( true ) ;
1819 const [ activePage , setActivePage ] = useState ( 'landing' ) ; // Default to landing page
1920 const [ repoData , setRepoData ] = useState < any > ( null ) ; // Store fetched repo stats
21+ const [ isAuthenticated , setIsAuthenticated ] = useState ( false ) ;
22+
23+ // Check for existing authentication on app load
24+ useEffect ( ( ) => {
25+ const savedAuth = localStorage . getItem ( 'isAuthenticated' ) ;
26+ if ( savedAuth === 'true' ) {
27+ setIsAuthenticated ( true ) ;
28+ }
29+ } , [ ] ) ;
30+
31+ const handleLogin = ( ) => {
32+ setIsAuthenticated ( true ) ;
33+ localStorage . setItem ( 'isAuthenticated' , 'true' ) ;
34+ } ;
35+
36+ const handleLogout = ( ) => {
37+ setIsAuthenticated ( false ) ;
38+ localStorage . removeItem ( 'isAuthenticated' ) ;
39+ setActivePage ( 'landing' ) ;
40+ setRepoData ( null ) ;
41+ } ;
2042
2143 const renderPage = ( ) => {
2244 switch ( activePage ) {
@@ -36,15 +58,17 @@ function App() {
3658 return < SupportPage /> ;
3759 case 'settings' :
3860 return < SettingsPage /> ;
61+ case 'profile' :
62+ return < ProfilePage /> ;
3963 default :
4064 return < Dashboard repoData = { repoData } /> ;
41-
4265 }
4366 } ;
4467
4568 return (
4669 < Router >
4770 < div className = "min-h-screen bg-gray-950 text-white" >
71+ < Toaster position = "top-right" />
4872 < Routes >
4973 < Route
5074 path = "/login"
@@ -89,4 +113,3 @@ function App() {
89113}
90114
91115export default App ;
92-
0 commit comments