Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.7 kB
1
Indexable
Never
// main.jsx

import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import Home from './Home.jsx';
import { BrowserRouter, Routes, Route } from "react-router-dom";
import LoginSignupPage from './Login.jsx';
import NavbarCategory from './Component/NavbarCategory.jsx';
import ProductDetailsPage from './Component/ProductDetails.jsx';
import SearchResultsPage from './Component/SearchResultsPage.jsx';
import Cart from './Cart.jsx';
import './index.css';

const App = () => {
  const [isAuthenticated, setIsAuthenticated] = useState(false); // Initialize isAuthenticated state

  return (
    <React.StrictMode>
      <BrowserRouter>
        <Routes>
          <Route path="/" element={<Home />} />
          <Route path="/:email" element={<Home />} />
          <Route path='/Login' element={<LoginSignupPage setIsAuthenticated={setIsAuthenticated} />} /> {/* Pass setIsAuthenticated as a prop */}
          <Route path='/Login/:email' element={<LoginSignupPage setIsAuthenticated={setIsAuthenticated} />} /> {/* Pass setIsAuthenticated as a prop */}
          <Route path='/ProductDetails/:id/:email' element={<ProductDetailsPage />} />
          <Route path='/NavbarCategory/:categoryName' element={<NavbarCategory />} />
          <Route path='/NavbarCategory/:categoryName/:email' element={<NavbarCategory />} />
          <Route path='/SearchResultsPage/:searchTerm' element={<SearchResultsPage />} />
          <Route path='/SearchResultsPage/:searchTerm/:email' element={<SearchResultsPage />} />
          <Route path='/Cart/:email' element={<Cart />} />
        </Routes>
      </BrowserRouter>
    </React.StrictMode>
  );
};

ReactDOM.createRoot(document.getElementById('root')).render(<App />);
Leave a Comment