import React, { useContext } from "react"; import { Link, useLocation } from "react-router-dom"; import bank1 from "../../assets/images/bank-1.png"; import bank2 from "../../assets/images/bank-2.png"; import bank3 from "../../assets/images/bank-3.png"; import bank4 from "../../assets/images/bank-4.png"; import profileImg from "../../assets/images/profile.jpg"; import useToggle from "../../hooks/useToggle"; import DarkModeContext from "../Contexts/DarkModeContext"; import Icons from "../Helpers/Icons"; import ModalCom from "../Helpers/ModalCom"; import WalletHeader from "../MyWallet/WalletHeader"; import { useSelector } from "react-redux"; import Flag from "../../assets/images/united-states.svg"; import siteLogo from "../../assets/images/wrenchboard-logo-text.png"; // import { updateWalletDetails } from "../../store/walletDetails"; import TimeDifference from "../Helpers/TimeDifference"; const DEFAULT_PROFILE_IMAGE = require("../../assets/images/profile.jpg"); export default function Header({ logoutModalHandler, sidebarHandler }) { const {userDetails: { account_type }} = useSelector((state) => state?.userDetails); const [balanceDropdown, setbalanceValue] = useToggle(false); const [notificationDropdown, setNotificationValue] = useToggle(false); const [userProfileDropdown, setProfileDropdown] = useToggle(false); const [moneyPopup, setPopup] = useToggle(false); const darkMode = useContext(DarkModeContext); const { userDetails } = useSelector((state) => state?.userDetails); const { notifications } = useSelector((state) => state?.notifications); // NOTIFICATION STORE const { walletDetails } = useSelector((state) => state?.walletDetails); // WALLET STORE const image = localStorage.getItem("session_token") ? userDetails.account_type === "FAMILY" ? `${userDetails.session_image_server}${localStorage.getItem( "session_token" )}/family/${sessionStorage.getItem("family_uid")}` : `${userDetails.session_image_server}${localStorage.getItem( "session_token" )}/profile/${userDetails.uid}` : ""; // 9308RDR122 const handlerBalance = () => { setbalanceValue.toggle(); if (notificationDropdown) { setNotificationValue.toggle(); } if (userProfileDropdown) { setProfileDropdown.toggle(); } }; const handlerNotification = () => { setNotificationValue.toggle(); if (balanceDropdown) { setbalanceValue.toggle(); } if (userProfileDropdown) { setProfileDropdown.toggle(); } }; const handlerProfile = () => { setProfileDropdown.toggle(); if (balanceDropdown) { setbalanceValue.toggle(); } if (notificationDropdown) { setNotificationValue.toggle(); } }; const clickAwayhandler = () => { if (balanceDropdown) { setbalanceValue.toggle(); } if (notificationDropdown) { setNotificationValue.toggle(); } if (userProfileDropdown) { setProfileDropdown.toggle(); } }; const addMoneyHandler = () => { setPopup.toggle(); setbalanceValue.set(false); }; // getting the location of head let { pathname } = useLocation(); const handleWalletBtn = () => { if (pathname === "/my-wallet") { setbalanceValue.set(false); } else return balanceDropdown; }; // User Profile let { firstname, lastname, email, profile_pic_url } = userDetails; let userEmail = email?.split("@")[0]; const userProfileImage = image || DEFAULT_PROFILE_IMAGE; return ( <>
{/* Home */}
{/* user info */}
{/* dark mode */} {/* */} {/* balance */} {/* My Page Button */} {/* {userDetails.account_type === "FULL" ? : null} */} {/*
*/} {/* notification */}
handlerNotification()} className="lg:w-[48px] lg:h-[48px] w-[38px] h-[38px] bg-white flex justify-center items-center rounded-full overflow-hidden relative" > {notifications?.loading ? "●" : notifications?.data?.length}

Recent Notifications

    {notifications?.data?.length && notifications?.data?.map((item, idx) => { if (idx < 5) { return (
  • icon

    {item?.title} {/* successfully done */}

  • ); } })}
See all Notification {/* */}
10
{/* profile */}
handlerProfile()} className="hidden lg:flex items-center space-x-3.5" > {/* profile-image */}
profile

{firstname}

{userDetails && userDetails?.account_type !== "FAMILY" && (

@{userEmail}

)}
handlerProfile()} className="lg:w-[62px] lg:h-[62px] w-[50px] h-[50px] rounded-full overflow-hidden block" > profile
Logo

{`${firstname} ${lastname}`}

    {userDetails && userDetails?.account_type !== "FAMILY" && (
  • My Profile

  • )}
  • My Wallet

  • {userDetails && userDetails?.account_type !== "FAMILY" && (
  • My Page

  • )} {userDetails && userDetails?.account_type !== "FAMILY" && ( <>
  • My Statements

  • )}

    {userDetails && userDetails?.account_type !== "FAMILY" && ( <>
  • Language

    English

    U.S.A Flag
    {/* langauge list items*/}
    • U.S.A Flag

      English

    {/* end Language list items*/}
  • Account Settings

  • )}
  • {process.env.REACT_APP_LOGOUT_TEXT}


{balanceDropdown || notificationDropdown || userProfileDropdown ? (
) : ( "" )} {moneyPopup && (

Connect to a wallet

  • MetaMask

  • Coinbase Wallet

  • Bitski

  • WalletConnect

View Wallet
)} ); } const PageButton = () => { return (

My Page

{/* */}
); }; const HomeButton = () => { return (

Home

); };