diff options
Diffstat (limited to 'src/main.jsx')
-rw-r--r-- | src/main.jsx | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/main.jsx b/src/main.jsx index c4a8c39..3de432c 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import ReactDOM from 'react-dom'; +import ReactDOM from 'react-dom/client'; // Import from 'react-dom/client' import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; import './index.css'; import App from './App'; @@ -7,15 +7,32 @@ import Login from './pages/Login'; import Register from './pages/Register'; import Dashboard from './pages/Dashboard'; import ManageAds from './pages/ManageAds'; +import PrivateRoute from './utils/PrivateRoute'; -ReactDOM.render( +const rootElement = document.getElementById('root'); +const root = ReactDOM.createRoot(rootElement); // Create a root + +root.render( <Router> <Routes> <Route path="/" element={<Login />} /> <Route path="/register" element={<Register />} /> - <Route path="/dashboard" element={<Dashboard />} /> - <Route path="/manage-ads" element={<ManageAds />} /> + <Route + path="/dashboard" + element={ + <PrivateRoute> + <Dashboard /> + </PrivateRoute> + } + /> + <Route + path="/manage-ads" + element={ + <PrivateRoute> + <ManageAds /> + </PrivateRoute> + } + /> </Routes> - </Router>, - document.getElementById('root') + </Router> ); |