| import React from 'react'; | |
| import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom'; | |
| import Auth from './components/Auth'; | |
| import { ReactFlowProvider } from 'reactflow'; | |
| import MindMapEditor from './components/MindMapEditor'; | |
| import LandingPage from './components/LandingPage'; | |
| interface PrivateRouteProps { | |
| children: React.ReactNode; | |
| redirectTo?: string; | |
| } | |
| const PrivateRoute: React.FC<PrivateRouteProps> = ({ | |
| children, | |
| redirectTo = "/" | |
| }) => { | |
| const token = localStorage.getItem('token'); | |
| return token ? <>{children}</> : <Navigate to={redirectTo} />; | |
| }; | |
| const App: React.FC = () => { | |
| return ( | |
| <Router> | |
| <Routes> | |
| <Route path="/" element={<LandingPage />} /> | |
| <Route path="/login" element={<Auth isLogin={true} />} /> | |
| <Route path="/signup" element={<Auth isLogin={false} />} /> | |
| <Route | |
| path="/editor" | |
| element={ | |
| <PrivateRoute> | |
| <ReactFlowProvider> | |
| <MindMapEditor /> | |
| </ReactFlowProvider> | |
| </PrivateRoute> | |
| } | |
| /> | |
| </Routes> | |
| </Router> | |
| ); | |
| }; | |
| export default App; |