Changeset 16237c4 for frontend/src/components
- Timestamp:
- 09/08/22 12:38:24 (2 years ago)
- Branches:
- master
- Children:
- ee05663
- Parents:
- 717ceae
- Location:
- frontend/src/components
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/components/Header.js
r717ceae r16237c4 16 16 import ShoppingBasketIcon from "@mui/icons-material/ShoppingCart"; 17 17 import MenuIcon from "@mui/icons-material/Menu"; 18 import { Link } from "react-router-dom";18 import { Link, NavLink, useNavigate } from "react-router-dom"; 19 19 import logo2 from "../Images/logo2.png"; 20 20 import Badge from "react-bootstrap/Badge"; … … 22 22 import { Store } from "../Store"; 23 23 import { useContext } from "react"; 24 import NavDropdown from "react-bootstrap/NavDropdown"; 24 25 25 26 const toggleMenu = (event) => { 27 event.stopPropagation(); 26 28 let menu = document.querySelector(".mobile-menu-container"); 27 29 menu.classList.remove("hidden"); … … 30 32 31 33 const toggleSubMenu = (event) => { 34 event.stopPropagation(); 32 35 let menu = document.querySelector(".subDropdown"); 33 36 menu.classList.remove("hidden"); … … 68 71 69 72 function Header() { 70 const { state } = useContext(Store); 71 const { cart } = state; 73 const { state, dispatch: ctxDispatch } = useContext(Store); 74 const { cart, userInfo } = state; 75 const navigate = useNavigate(); 76 77 const signoutHandler = () => { 78 ctxDispatch({ type: "USER_SIGNOUT" }); 79 localStorage.removeItem("userInfo"); 80 localStorage.removeItem("shippingAddress"); 81 localStorage.removeItem("paymentMethod"); 82 }; 83 72 84 return ( 73 85 <div className="header"> … … 78 90 onClick={toggleMenu} 79 91 /> 80 <img className="header__icon" src={logo2} alt="logo"></img> 92 <img 93 className="header__icon" 94 src={logo2} 95 alt="logo" 96 onClick={() => { 97 navigate("/"); 98 }} 99 ></img> 81 100 </div> 82 101 <div className="mobile-menu-container hidden"> … … 85 104 </div> 86 105 <ul className="mobile-menu"> 87 <li>Почетна</li> 106 <Link 107 to="/" 108 style={{ textDecoration: "none", color: "black" }} 109 onClick={closeMenu} 110 > 111 <li>Почетна</li> 112 </Link> 88 113 <li onClick={toggleSubMenu} className="subMenu"> 89 114 Производи <ArrowDropDownIcon /> … … 492 517 <div className="header__right"> 493 518 <div className="header__buttons"> 494 <span> 495 <AccountCircleIcon className="header__login" fontSize="large" /> 496 <p>Најави се</p> 497 </span> 519 {userInfo ? ( 520 <NavDropdown 521 title={ 522 <span> 523 <AccountCircleIcon 524 className="header__login" 525 fontSize="large" 526 /> 527 <p>{userInfo.name}</p> 528 </span> 529 } 530 id="basic-nav-dropdown" 531 > 532 <NavDropdown.Item 533 onClick={() => { 534 navigate("/profile"); 535 }} 536 > 537 Профил 538 </NavDropdown.Item> 539 540 <NavDropdown.Item 541 onClick={() => { 542 navigate("/orderhistory"); 543 }} 544 > 545 Нарачки 546 </NavDropdown.Item> 547 548 <NavDropdown.Divider /> 549 <Link 550 className="drowdown-item" 551 to="#signout" 552 onClick={signoutHandler} 553 > 554 Одјави се 555 </Link> 556 </NavDropdown> 557 ) : ( 558 <Link 559 to={"/signin"} 560 className="link" 561 onClick={() => { 562 navigate("/orderhistory"); 563 }} 564 > 565 <span> 566 <AccountCircleIcon className="header__login" fontSize="large" /> 567 <p>Најави се</p> 568 </span> 569 </Link> 570 )} 571 498 572 <Link to="/cart" className="badgee"> 499 573 <span>
Note:
See TracChangeset
for help on using the changeset viewer.