import React, { useMemo } from "react"; import axios from "axios"; import { useSelector } from "react-redux"; import { AppBar, Toolbar, IconButton, Badge, Button } from "@material-ui/core"; import ShoppingCartIcon from "@material-ui/icons/ShoppingCart"; import ArrowBackIcon from "@material-ui/icons/ArrowBack"; import { useNavigate, useLocation } from "react-router-dom"; const apiUrl = process.env.REACT_APP_API_URL; const selectPosterSelections = (state) => state.posterSelections; const NavBar = () => { const navigate = useNavigate(); const location = useLocation(); const posterSelections = useSelector(selectPosterSelections); const selectedPosters = useMemo(() => { return Object.values(posterSelections).flat(); }, [posterSelections]); const totalSelected = selectedPosters.length; const handleBack = () => { navigate(-1); }; const handleCart = () => { navigate("/Cart"); }; const handleResetprofile = async () => { try { await axios.delete(`${apiUrl}/api/delete-csv`, { withCredentials: true }); navigate("/"); } catch (error) { console.error("Error deleting CSV file:", error); } }; const isPosterSelectorPage = location.pathname !== "/PosterSelector"; return ( {isPosterSelectorPage ? ( ) : ( {/* Disabled IconButton */} )}
); }; export default NavBar;