text: import React from "react";
  import Cart from "./pages/Cart";
  import Home from "./pages/Home";
  import Login from "./pages/Login";
  import ProductList from "./pages/ProductList";
  import Product from "./pages/Product";
  import Register from "./pages/Register";
  import {
      BrowserRouter as Router,
      Routes,
      Route,
      Navigate,
  } from "react-router-dom";
  import {useSelector} from "react-redux";
  
  const App = () => {
      const user = useSelector((state) => state.user.currentUser);
      return (
          <Router>
              <Routes>
                  <Route exact path="/" element={<Home />} />
                  <Route path="/products" element={<ProductList />} />
                  <Route path="/products/:categroy" element={<ProductList />} />
                  <Route path="/products/:id" element={<ProductList />} />
                  <Route path="/product/:id" element={<Product />} />
                  <Route path="/cart" element={<Cart />} />
                  <Route
                      path="/login"
                      element={user ? <Navigate to="/" /> : <Login />}
                  />
                  <Route
                      path="/register"
                      element={user ? <Navigate to="/" /> : <Register />}
                  />
              </Routes>
          </Router>
      );
  };
  
  export default App;
  