diff --git a/client/src/App.js b/client/src/App.js
index 53867b4..2aa5c29 100644
--- a/client/src/App.js
+++ b/client/src/App.js
@@ -2,9 +2,9 @@ import React, { useState, useEffect } from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import './App.css';
import './Animations.css';
-import { Navbar, Footer } from './Components/index.js';
+import { Navbar, Footer } from './components/index.js';
// import { ProfilePage, Product } from './Components/index.js';
-import { Product } from './Components/index.js';
+import { Product } from './components/index.js';
import RomancePage from './Pages/RomancePage.jsx';
import ActionPage from './Pages/ActionPage.jsx';
import ThrillerPage from './Pages/ThrillerPage.jsx';
@@ -26,9 +26,9 @@ import FAQ from "./Pages/Faq.jsx";
import AboutUs from "./Pages/AboutUs.jsx";
import { OrderList } from "./Pages/Orders.jsx";
import Contributors from "./Pages/Contributors.jsx";
-import Preloader from "./Components/Preloader.jsx";
+// import Preloader from "./Components/Preloader.jsx";
import { Toast } from "./Toast/Toast.js";
-import GoToTop from "./Components/GoToTop.jsx";
+import GoToTop from "./components/GoToTop.jsx";
import License from "./Pages/Licensing.jsx";
import CustomerProfile from "./Pages/CustomerProfile.jsx";
import GiftCards from "./Pages/GiftCards.jsx";
@@ -93,7 +93,7 @@ function App() {
{/* Pass darkMode prop here */}
- {/* Ensure Preloader is correctly styled */}
+ {/**/} {/* Ensure Preloader is correctly styled */}
{/* Added GoToTop component */}
diff --git a/client/src/Pages/AboutUs.jsx b/client/src/Pages/AboutUs.jsx
index a12abd8..31c3708 100644
--- a/client/src/Pages/AboutUs.jsx
+++ b/client/src/Pages/AboutUs.jsx
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
-import Preloader from '../Components/Preloader';
+import Preloader from '../components/Preloader';
import { Link } from 'react-router-dom';
const AboutUs = () => {
diff --git a/client/src/Pages/CancelReturns.jsx b/client/src/Pages/CancelReturns.jsx
index d367953..a075682 100644
--- a/client/src/Pages/CancelReturns.jsx
+++ b/client/src/Pages/CancelReturns.jsx
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
-import Preloader from '../Components/Preloader';
+import Preloader from '../components/Preloader';
const PrivacyPolicy = () => {
useEffect(() => {
diff --git a/client/src/Pages/Careers.jsx b/client/src/Pages/Careers.jsx
index 7385a37..c0d7833 100644
--- a/client/src/Pages/Careers.jsx
+++ b/client/src/Pages/Careers.jsx
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
-import Preloader from '../Components/Preloader';
+import Preloader from '../components/Preloader';
const Careers = () => {
useEffect(() => {
diff --git a/client/src/Pages/Cart.jsx b/client/src/Pages/Cart.jsx
index 479ae3f..1facc6d 100644
--- a/client/src/Pages/Cart.jsx
+++ b/client/src/Pages/Cart.jsx
@@ -6,7 +6,7 @@ import {
removeItemFromCart,
} from "../api/api.js";
import "./Cart.css";
-import Preloader from "../Components/Preloader";
+import Preloader from "../components/Preloader";
import { useToast } from "../Context/ToastContext";
import { useNavigate } from "react-router-dom";
import { useAuth } from "../Context/AuthContext";
diff --git a/client/src/Pages/Contact.jsx b/client/src/Pages/Contact.jsx
index 9f59265..32962a9 100644
--- a/client/src/Pages/Contact.jsx
+++ b/client/src/Pages/Contact.jsx
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from "react";
-import Preloader from "../Components/Preloader";
+import Preloader from "../components/Preloader";
import { FaLinkedin, FaGithub, FaEnvelope, FaPhoneAlt } from "react-icons/fa";
// import "./Contact.css";
function Contact() {
diff --git a/client/src/Pages/Contributors.jsx b/client/src/Pages/Contributors.jsx
index 170d323..a944a93 100644
--- a/client/src/Pages/Contributors.jsx
+++ b/client/src/Pages/Contributors.jsx
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import './Contributors.css';
-import Preloader from '../Components/Preloader';
+import Preloader from '../components/Preloader';
function Contributors() {
const [contributors, setContributors] = useState([]);
diff --git a/client/src/Pages/CustomerProfile.jsx b/client/src/Pages/CustomerProfile.jsx
index 141a7e5..77d59d8 100644
--- a/client/src/Pages/CustomerProfile.jsx
+++ b/client/src/Pages/CustomerProfile.jsx
@@ -1,10 +1,10 @@
import React, { useState } from "react";
-import Sidebar from "../Components/CustomerProfile/Sidebar";
-import Profile from "../Components/CustomerProfile/Profile";
-import Orders from "../Components/CustomerProfile/Orders";
-import Pancard from "../Components/CustomerProfile/Pancard";
-import DeliveryLocation from "../Components/CustomerProfile/DeliveryLocation";
-import Giftcard from "../Components/CustomerProfile/Giftcard";
+import Sidebar from "../components/CustomerProfile/Sidebar";
+import Profile from "../components/CustomerProfile/Profile";
+import Orders from "../components/CustomerProfile/Orders";
+import Pancard from "../components/CustomerProfile/Pancard";
+import DeliveryLocation from "../components/CustomerProfile/DeliveryLocation";
+import Giftcard from "../components/CustomerProfile/Giftcard";
const CustomerProfile = () => {
const [activeSection, setActiveSection] = useState("profile");
diff --git a/client/src/Pages/Faq.jsx b/client/src/Pages/Faq.jsx
index eb0619c..a3f1c88 100644
--- a/client/src/Pages/Faq.jsx
+++ b/client/src/Pages/Faq.jsx
@@ -1,5 +1,5 @@
import React, { useState,useEffect } from 'react';
-import Preloader from '../Components/Preloader';
+import Preloader from '../components/Preloader';
const FAQ = () => {
const faqs = [
diff --git a/client/src/Pages/GiftCards.jsx b/client/src/Pages/GiftCards.jsx
index e750773..e0602c3 100644
--- a/client/src/Pages/GiftCards.jsx
+++ b/client/src/Pages/GiftCards.jsx
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
-import Preloader from '../Components/Preloader';
+import Preloader from '../components/Preloader';
const GiftCards = () => {
useEffect(() => {
diff --git a/client/src/Pages/Home.jsx b/client/src/Pages/Home.jsx
index 1292147..ad82165 100644
--- a/client/src/Pages/Home.jsx
+++ b/client/src/Pages/Home.jsx
@@ -3,9 +3,9 @@ import { Link, useNavigate } from 'react-router-dom';
import B1Child from '../assets/image/B1Child.jpeg';
import AuthorImage from '../assets/image/author1.jpeg';
import Spinner from './Spinner';
-import SearchBar from '../Components/SearchBar';
+import SearchBar from '../components/SearchBar';
import { useTheme, useMediaQuery } from '@mui/material';
-import Preloader from '../Components/Preloader';
+import Preloader from '../components/Preloader';
import Newarrivals, { books as newbooks } from './Newarrivals';
import Review from './Review';
import crawdadsImage from '../assets/image/WhereTheCrawdadsSings.jpg';
@@ -144,148 +144,167 @@ const Home = () => {
- Book Categories
-
-
-
-
-
Romance
-
Explore our collection of romantic novels.
-
-
-
-
-
-
Action
-
Dive into thrilling action-packed stories.
-
-
-
-
-
-
Thriller
-
Get your adrenaline pumping with our thrillers.
-
-
-
-
-
-
Fiction
-
Discover imaginative and captivating fiction.
-
-
-
-
-
-
Tech
-
Stay updated with the latest in technology.
-
-
-
-
-
-
Philosophy
-
Dive deep into philosophical thoughts and ideas.
-
-
-
-
-
-
Manga
-
Explore our extensive collection of Manga.
-
-
-
-
-
-
-
-
-
- {/* New Arrivals Section */}
-
-
-
{
- const book = newbooks.find(b => b.title === bookTitle);
- if (book) {
- setHighlightedBookId(book.id); // Highlight the found book
- navigate(`/book/${bookTitle}`);
- }
- }}
- highlightedBookId={highlightedBookId}
- bookRefs={bookRefs}
- filteredBooks={filteredBooks} // Pass filteredBooks to display
- />
- {bookNotFound && No books found matching your search.
}
-
-
-
- {/* Top Trending Books Section */}
-
+
Book Categories
+
+ {/* Top row of four cards */}
+
+ {/* Romance Card */}
+
+
+

+
Romance
+
Explore our collection of romantic novels.
+
+
+
+ {/* Action Card */}
+
+
+

+
Action
+
Dive into thrilling action-packed stories.
+
+
+
+ {/* Thriller Card */}
+
+
+

+
Thriller
+
Get your adrenaline pumping with our thrillers.
+
+
+
+ {/* Fiction Card */}
+
+
+

+
Fiction
+
Discover imaginative and captivating fiction.
+
+
+
+
+ {/* Bottom row of three centered cards */}
+
+ {/* Tech Card */}
+
+
+

+
Tech
+
Stay updated with the latest in technology.
+
+
+
+ {/* Philosophy Card */}
+
+
+

+
Philosophy
+
Dive deep into philosophical thoughts and ideas.
+
+
+
+ {/* Manga Card */}
+
+
+

+
Manga
+
Explore our extensive collection of Manga.
+
+
+
+
+
+{/* New Arrivals Section */}
+
+ Newly Arrived
+
+
{
+ const book = newbooks.find(b => b.title === bookTitle);
+ if (book) {
+ setHighlightedBookId(book.id); // Highlight the found book
+ navigate(`/book/${bookTitle}`);
+ }
+ }}
+ highlightedBookId={highlightedBookId}
+ bookRefs={bookRefs}
+ filteredBooks={filteredBooks} // Pass filteredBooks to display
+ />
+ {bookNotFound && No books found matching your search.
}
+
+
+
+
+
+{/* Top Trending Books Section */}
+
+ Top Trending Books
+
+
+
+ {/* Book Cards */}
+
+
+
+

+
The Midnight Library
+
A philosophical tale about choices, regrets, and the infinite possibilities of life.
+
+
+
+
+
+

+
Dune
+
A science fiction epic set on the desert planet of Arrakis, exploring themes of politics, religion, and ecology.
+
+
+
+
+
+

+
Project Hail Mary
+
A gripping tale of survival in space as an astronaut embarks on a mission to save humanity.
+
+
+
+
+
+

+
Where the Crawdads Sing
+
A coming-of-age tale blended with a murder mystery in the marshes of North Carolina.
+
+
+
+
+
+

+
The Vanishing Half
+
A multigenerational saga about twin sisters whose lives diverge when one decides to live as a white woman.
+
+
+
+
+
+

+
Klara and the Sun
+
A story told from the perspective of an artificial friend, exploring themes of love and what it means to be human.
+
+
+
+
+
+

+
Malibu Rising
+
A summer story of four siblings throwing a party that changes everything, set in Malibu's vibrant beach culture.
+
+
+
+
+
-
- Top Trending Books
-
-
-
-
-

-
Where the Crawdads Sing
-
A coming-of-age story intertwined with a murder mystery set in the marshes of North Carolina.
-
-
-
-
-
-

-
The Midnight Library
-
A philosophical tale about choices, regrets, and the infinite possibilities of life.
-
-
-
-
-
-

-
The Vanishing Half
-
A multigenerational saga about twin sisters whose lives diverge when one decides to live as a white woman.
-
-
-
-
-
-

-
Dune
-
A science fiction epic set on the desert planet of Arrakis, exploring themes of politics, religion, and ecology.
-
-
-
-
-
-

-
Klara and the Sun
-
A story told from the perspective of an artificial friend, exploring themes of love and what it means to be human.
-
-
-
-
-
-

-
Project Hail Mary
-
A gripping tale of survival in space as an astronaut embarks on a mission to save humanity.
-
-
-
-
-
-

-
Malibu Rising
-
A summer story of four siblings throwing a party that changes everything, set in Malibu's vibrant beach culture.
-
-
-
-
-
{/* Featured Author Section */}
Featured Author
@@ -312,6 +331,4 @@ const Home = () => {
);
};
-export default Home;
-
-
+export default Home;
\ No newline at end of file
diff --git a/client/src/Pages/Licensing.jsx b/client/src/Pages/Licensing.jsx
index 5a87390..b1bce31 100644
--- a/client/src/Pages/Licensing.jsx
+++ b/client/src/Pages/Licensing.jsx
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
-import Preloader from '../Components/Preloader';
+import Preloader from '../components/Preloader';
const License = () => {
useEffect(() => {
diff --git a/client/src/Pages/LoginPage.jsx b/client/src/Pages/LoginPage.jsx
index 6d51530..407afeb 100644
--- a/client/src/Pages/LoginPage.jsx
+++ b/client/src/Pages/LoginPage.jsx
@@ -12,8 +12,8 @@ import toast, { Toaster } from "react-hot-toast";
import { Link, useNavigate } from "react-router-dom";
import { useAuth } from "../Context/AuthContext";
import { useToast } from "../Context/ToastContext";
-import Preloader from "../Components/Preloader";
-import GoogleLogin from "../Components/GoogleLogin";
+import Preloader from "../components/Preloader";
+import GoogleLogin from "../components/GoogleLogin";
import { loginValidation } from "../validations/validation";
const LoginPage = () => {
diff --git a/client/src/Pages/Newarrivals.js b/client/src/Pages/Newarrivals.js
index 3d497ac..e976af3 100644
--- a/client/src/Pages/Newarrivals.js
+++ b/client/src/Pages/Newarrivals.js
@@ -1,132 +1,74 @@
-
import { Link } from 'react-router-dom';
-// import BannerCard from '../Pages/BannerCard.js';
-
-import React, { useState, useEffect, useRef } from 'react';
-import BannerCard from '../Pages/BannerCard.js';
-
-// import { set } from 'mongoose';
-
+import React from 'react';
export const books = [
{
- _id:"1",
+ _id: "1",
bookTitle: "Fourth Wing",
authorName: "Rebecca Yarros",
imageURL: "https://images-na.ssl-images-amazon.com/images/S/compressed.photo.goodreads.com/books/1701980900i/61431922.jpg",
category: "Romantasy",
},
{
- _id:"2",
+ _id: "2",
bookTitle: "The Maid",
authorName: "Nita Prose",
imageURL: "https://images-na.ssl-images-amazon.com/images/S/compressed.photo.goodreads.com/books/1643228739i/55196813.jpg",
category: "Fiction",
},
{
- _id:"3",
+ _id: "3",
bookTitle: "Check & Mate",
authorName: "Ali Hazelwood",
imageURL: "https://images-na.ssl-images-amazon.com/images/S/compressed.photo.goodreads.com/books/1678378842i/60683957.jpg",
category: "YOUNG ADULT FANTASY & SCIENCE FICTION",
},
{
- _id:"4",
+ _id: "4",
bookTitle: "Holly",
authorName: "Stephen King",
imageURL: "https://images-na.ssl-images-amazon.com/images/S/compressed.photo.goodreads.com/books/1674418461i/65916344.jpg",
category: "Horror",
},
{
- _id:"5",
- bookTitle: "Tomorrow and Tomorrow",
- authorName: "Gabrielle Zevin ",
- imageURL: "https://images-na.ssl-images-amazon.com/images/S/compressed.photo.goodreads.com/books/1636978687i/58784475.jpg",
- category: "Fiction",
- },
- {
- _id:"6",
- bookTitle: "Hidden Pictures",
- authorName: "Jason Rekulak",
- imageURL: "https://images-na.ssl-images-amazon.com/images/S/compressed.photo.goodreads.com/books/1635260162i/58724923.jpg",
- category: "Horror",
- },
-
- {
- _id:"7",
- bookTitle: "Holly",
- authorName: "Stephen King",
- imageURL: "https://images-na.ssl-images-amazon.com/images/S/compressed.photo.goodreads.com/books/1674418461i/65916344.jpg",
- category: "Horror",
- },
-
+ _id: "5",
+ bookTitle: "Tomorrow and Tomorrow",
+ authorName: "Gabrielle Zevin",
+ imageURL: "https://images-na.ssl-images-amazon.com/images/S/compressed.photo.goodreads.com/books/1636978687i/58784475.jpg",
+ category: "Fiction",
+ },
+ {
+ _id: "6",
+ bookTitle: "Hidden Pictures",
+ authorName: "Jason Rekulak",
+ imageURL: "https://images-na.ssl-images-amazon.com/images/S/compressed.photo.goodreads.com/books/1635260162i/58724923.jpg",
+ category: "Horror",
+ },
+ {
+ _id: "7",
+ bookTitle: "Holly",
+ authorName: "Stephen King",
+ imageURL: "https://images-na.ssl-images-amazon.com/images/S/compressed.photo.goodreads.com/books/1674418461i/65916344.jpg",
+ category: "Horror",
+ },
];
function Newarrivals({ onBookClick, highlightedBookId }) {
- // const bookRefs = useRef({});
-
-
- // const fetchRandomBooks = async () => {
- // setIsLoading(true);
- // try {
- // const randomStartIndex = Math.floor(Math.random() * 100);
- // const response = await fetch(`https://www.googleapis.com/books/v1/volumes?q=subject:fiction&maxResults=7&startIndex=${randomStartIndex}`);
-
- // if (!response.ok) {
- // throw new Error('HTTP Error! Status: ' + response.status);
- // }
-
- // const data = await response.json();
- // console.log(data);
-
-
- // if (data.items) {
-
- // const formattedBooks = data.items.map(item => ({
- // id: item.id,
- // bookTitle: item.volumeInfo.title,
- // authorName: item.volumeInfo.authors ? item.volumeInfo.authors[0] : 'Unknown Author',
- // imageURL: item.volumeInfo.imageLinks ? item.volumeInfo.imageLinks.thumbnail : 'https://via.placeholder.com/128x193.png',
- // category: item.volumeInfo.categories ? item.volumeInfo.categories[0] : 'Fiction'
- // }));
- // setBooks(formattedBooks);
- // }
- // else {
- // setError('No books found');
- // }
- // }
- // catch (error) {
- // console.error('Error fetching books: ', error);
- // setError('Falied to fetch books');
- // }
- // finally {
- // setIsLoading(false);
- // }
- // };
-
- // if (isLoading) {
- // return Loading...
;
- // }
- // if (error) {
- // return Error: {error}
;
- // }
-
- return (
-
- {books.map((book, index) => (
-
-
-

-
-
{book.bookTitle}
-
{book.authorName}
-
{book.category}
-
-
-
- ))}
-
-
+ return (
+
+ {books.map((book, index) => (
+
+
+

+
+
{book.bookTitle}
+
{book.authorName}
+
{book.category}
+
+
+
+ ))}
+
);
}
diff --git a/client/src/Pages/Orders.jsx b/client/src/Pages/Orders.jsx
index 5fc5866..5e86a0c 100644
--- a/client/src/Pages/Orders.jsx
+++ b/client/src/Pages/Orders.jsx
@@ -24,7 +24,7 @@ import {
import SearchIcon from "@mui/icons-material/Search";
import SortIcon from "@mui/icons-material/Sort";
import RefreshIcon from "@mui/icons-material/Refresh";
-import Preloader from "../Components/Preloader";
+import Preloader from "../components/Preloader";
import { useAuth } from "../Context/AuthContext";
import { useToast } from "../Context/ToastContext";
import { useNavigate } from "react-router-dom";
diff --git a/client/src/Pages/PrivacyPolicy.jsx b/client/src/Pages/PrivacyPolicy.jsx
index fa545b8..9f191a6 100644
--- a/client/src/Pages/PrivacyPolicy.jsx
+++ b/client/src/Pages/PrivacyPolicy.jsx
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react';
// import styled from 'styled-components';
-import Preloader from '../Components/Preloader';
+import Preloader from '../components/Preloader';
const PrivacyPolicy = () => {
useEffect(() => {
diff --git a/client/src/Pages/Shop.jsx b/client/src/Pages/Shop.jsx
index 1c6a7bf..6c977a0 100644
--- a/client/src/Pages/Shop.jsx
+++ b/client/src/Pages/Shop.jsx
@@ -1,6 +1,6 @@
import React from 'react'
import Productitem from './ProductItem'
-import Preloader from '../Components/Preloader'
+import Preloader from '../components/Preloader'
const Shop = () => {
return (
diff --git a/client/src/Pages/SignUpPage.jsx b/client/src/Pages/SignUpPage.jsx
index 4773740..ac7b1fe 100644
--- a/client/src/Pages/SignUpPage.jsx
+++ b/client/src/Pages/SignUpPage.jsx
@@ -10,8 +10,8 @@ import loginAnimation from "../Lottie-animation/loginAnimation.json";
import axios from "axios";
import toast, { Toaster } from "react-hot-toast";
import { Link, useNavigate } from "react-router-dom";
-import Preloader from "../Components/Preloader";
-import GoogleLogin from "../Components/GoogleLogin";
+import Preloader from "../components/Preloader";
+import GoogleLogin from "../components/GoogleLogin";
import { registerValidation } from "../validations/validation";
const SignUpPage = () => {
diff --git a/client/src/Pages/Terms.jsx b/client/src/Pages/Terms.jsx
index 64b72ad..9375328 100644
--- a/client/src/Pages/Terms.jsx
+++ b/client/src/Pages/Terms.jsx
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react';
// import styled from 'styled-components';
-import Preloader from '../Components/Preloader';
+import Preloader from '../components/Preloader';
const TermsAndConditions = () => {
useEffect(() => {
diff --git a/client/src/Pages/Wishlist.jsx b/client/src/Pages/Wishlist.jsx
index 7f46c29..1f57bf5 100644
--- a/client/src/Pages/Wishlist.jsx
+++ b/client/src/Pages/Wishlist.jsx
@@ -6,7 +6,7 @@ import {
FaTable,
} from "react-icons/fa";
import "./Wishlist.css"; // Import CSS file for wishlist component styling
-import Preloader from "../Components/Preloader";
+import Preloader from "../components/Preloader";
import { useAuth } from "../Context/AuthContext";
import { useToast } from "../Context/ToastContext";
import { useNavigate } from "react-router-dom";
diff --git a/client/src/components/NavBar/NavBar.jsx b/client/src/components/NavBar/NavBar.jsx
index b1fcc4d..6600e2e 100644
--- a/client/src/components/NavBar/NavBar.jsx
+++ b/client/src/components/NavBar/NavBar.jsx
@@ -1,4 +1,4 @@
-import React, { useState } from "react";
+import React, { useState, useMemo } from "react";
import {
AppBar,
Toolbar,
@@ -7,14 +7,17 @@ import {
useMediaQuery,
useTheme,
styled,
+ Tooltip,
} from "@mui/material";
-import MenuIcon from "@mui/icons-material/Menu";
-import AccountCircleIcon from "@mui/icons-material/AccountCircle";
-import StoreIcon from "@mui/icons-material/Store";
-import FavoriteIcon from "@mui/icons-material/Favorite";
-import ShoppingCartIcon from "@mui/icons-material/ShoppingCart";
-import ShoppingBagIcon from "@mui/icons-material/ShoppingBag";
-import HomeIcon from "@mui/icons-material/Home";
+import {
+ Menu as MenuIcon,
+ AccountCircle as AccountCircleIcon,
+ Store as StoreIcon,
+ Favorite as FavoriteIcon,
+ ShoppingCart as ShoppingCartIcon,
+ ShoppingBag as ShoppingBagIcon,
+ Home as HomeIcon,
+} from "@mui/icons-material";
import { Link, useNavigate, useLocation } from "react-router-dom";
import { useAuth } from "../../Context/AuthContext";
import { useToast } from "../../Context/ToastContext";
@@ -22,14 +25,10 @@ import sunIcon from "../../assets/sun.png"; // Adjust the path as necessary
import moonIcon from "../../assets/moon.png"; // Adjust the path as necessary
import logo from "../../assets/Logo.png"; // Adjust the path as necessary
import SearchBar from "../SearchBar";
-
-import { Tooltip } from '@mui/material';
-import { pink } from '@mui/material/colors';
-import ScrollProgressBar from './ScrollProgressBar';
-
+import ScrollProgressBar from "./ScrollProgressBar";
const StyledAppBar = styled(AppBar)(({ darkMode }) => ({
- backgroundColor: darkMode ? "black" : "#002147", // Change color based on darkMode
+ backgroundColor: darkMode ? "black" : "#002147",
}));
const Logo = styled("img")({
@@ -38,15 +37,13 @@ const Logo = styled("img")({
marginRight: "auto",
});
-const StyledButton = styled(Button)(({ isActive }) => ({
-
+const NavButton = styled(Button)(({ isActive }) => ({
fontSize: "1rem",
- color: isActive ? "#FFD700" : "#FFF", // Highlight active page color
- textDecoration: isActive ? "underline" : "none", // Add underline for active page
+ color: isActive ? "#FFD700" : "#FFF",
+ textDecoration: isActive ? "underline" : "none",
"&:hover": {
color: "#FFD700",
textDecoration: "underline",
-
},
}));
@@ -57,270 +54,122 @@ const MenuContainer = styled("div")({
marginLeft: "auto",
});
-const MobileMenu = styled("div")(({ open }) => ({
- display: "flex",
+const MobileMenuContainer = styled("div")(({ open }) => ({
+ display: open ? "flex" : "none",
flexDirection: "column",
- gap: "10px", // Added 'px' for proper gap
position: "fixed",
- top: "0", // Align to the top of the screen
- right: "0",
- backgroundColor: "#002147",
+ top: 0,
+ right: 0,
width: "100%",
- height: "100vh", // Full height
- padding: "20px", // Padding for better spacing
+ height: "100vh",
+ backgroundColor: "#002147",
+ padding: "20px",
boxShadow: "0px 4px 8px rgba(0, 0, 0, 0.2)",
zIndex: 1000,
- overflowY: "auto", // Enable scrolling if needed
- transform: open ? "translateX(0)" : "translateX(100%)", // Slide from right
- transition: "transform 0.4s ease-in-out", // Smooth transition effect
+ overflowY: "auto",
}));
-const MobileMenuButton = styled(IconButton)({
- fill: "#fff",
-});
+const DarkModeToggle = ({ darkMode, toggleDarkMode }) => (
+
+
+
+
+
+);
function Navbar({ darkMode, toggleDarkMode }) {
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down("lg"));
const [openMenu, setOpenMenu] = useState(false);
const { userLoggedIn, setUserLoggedIn } = useAuth();
- let navigate = useNavigate();
+ const navigate = useNavigate();
const { showToast } = useToast();
const location = useLocation();
- const handleMenuClick = () => {
- setOpenMenu(!openMenu);
- };
+ const isActive = (path) => location.pathname === path;
- const handleLogout = () => {
- try {
- const token = sessionStorage.getItem("token");
- if (token) {
- sessionStorage.removeItem("token");
- }
- } catch (error) {
- console.error("Error removing token from sessionStorage:", error);
- }
+ const handleMenuClick = () => setOpenMenu((prev) => !prev);
+ const handleLogout = () => {
+ sessionStorage.removeItem("token");
setUserLoggedIn(false);
localStorage.removeItem("token");
navigate("/", { replace: true });
showToast("success", "", "Logged out successfully");
};
- const handleSearch = (query) => {
- console.log("Search query:", query);
- // Implement search logic here
- };
-
- const isActive = (path) => location.pathname === path;
+ const navLinks = useMemo(
+ () => [
+ { label: "Home", to: "/", icon: },
+ { label: "Shop", to: "/shop", icon: },
+ { label: "Wishlist", to: "/wishlist", icon: },
+ { label: "Cart", to: "/cart", icon: },
+ ...(userLoggedIn
+ ? [
+ { label: "Profile", to: "/profile", icon: },
+ { label: "Orders", to: "/orders", icon: },
+ { label: "Logout", to: "#", onClick: handleLogout, icon: },
+ ]
+ : [{ label: "Login", to: "/login", icon: }]),
+ ],
+ [userLoggedIn]
+ );
return (
-
-
+
-
{isMobile ? (
<>
-
-
-
-
+
+
-
-
-
+
-
-
-
-
-
-
-
- Close
-
- }
- fullWidth
- style={{ marginBottom: "15px" }} // Add margin for spacing
- >
- Home
-
- {userLoggedIn && (
- } fullWidth>
- Profile
-
- )}
- }
- fullWidth
- style={{ marginBottom: "15px" }} // Add margin for spacing
- >
- Shop
-
- }
- fullWidth
- style={{ marginBottom: "15px" }} // Add margin for spacing
- >
- Wishlist
-
- }
- fullWidth
- style={{ marginBottom: "15px" }} // Add margin for spacing
- >
- Cart
-
-
- {userLoggedIn ? (
-
+
+ {navLinks.map((link) => (
+ }
+ to={link.to}
+ onClick={link.onClick || handleMenuClick}
+ startIcon={link.icon}
+ isActive={isActive(link.to)}
fullWidth
- style={{ marginBottom: "15px" }} // Add margin for spacing
>
- Orders
-
- ) : null}
-
- }
- fullWidth
- style={{ marginBottom: "15px" }} // Add margin for spacing
- >
- {userLoggedIn ? "Logout" : "Login"}
-
-
+ {link.label}
+
+ ))}
+
>
) : (
- }
- >
- Home
-
-
-
- }
- >
- }>
- Home
-
- {userLoggedIn && (
- }>
- Profile
-
- )}
- }>
- Shop
-
- }
- >
- Wishlist
-
- }
- >
- Cart
-
- {userLoggedIn ? (
- (
+ }
- >
- Orders
-
- ) : null}
-
- }
- >
- {userLoggedIn ? "Logout" : "Login"}
-
-
-
-
-
-
+ {link.label}
+
+ ))}
+
- )}
-
-
- );
+ )}
+
+
+ );
}
export default Navbar;
diff --git a/client/src/components/SearchBar.js b/client/src/components/SearchBar.jsx
similarity index 100%
rename from client/src/components/SearchBar.js
rename to client/src/components/SearchBar.jsx
diff --git a/client/src/index.js b/client/src/index.js
index 09e5b98..05fcf68 100644
--- a/client/src/index.js
+++ b/client/src/index.js
@@ -1,10 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
-import App from './App';
+import App from './App.js';
import { AuthContextProvider } from './Context/AuthContext.js';
import { ToastContextProvider } from './Context/ToastContext.js';
-import reportWebVitals from './reportWebVitals';
+import reportWebVitals from './reportWebVitals.js';