import { LuSunDim } from "react-icons/lu";
import { IoMdSunny } from "react-icons/io";

import { GeneralLayoutContext } from "../../context/GeneralLayoutContext"

import UserAvatar from '../../assets/user_avatar.jpg'
import HandBurger from "./HandBurger"
import { Link } from "react-router-dom"
import RouteLinks from "../../RouteLinks"
import MainBtn from "../MainBtn";
import { TbLogout2 } from "react-icons/tb";
import Icons from "../Icons";

export default function DashboardHeader() {

    // let {pathname} = useLocation()

    const {theme, handleTheme, setLogoutModal, activeMenu, handleActiveMenu, showAsideDrawer, setShowAsideDrawer} = GeneralLayoutContext()

  return (
    <>
        {/* HEADER SECTION*/}
        <header className='text-brown dark:text-white'>
            <div className='w-full flex h-20 justify-between lg:justify-end items-center'>
                <div className="lg:hidden cursor-pointer" onClick={()=>setShowAsideDrawer('aside')}>
                    <HandBurger showAside={showAsideDrawer} />
                </div>

                {/* USER AVATAR */}
                <div className="flex gap-4 justify-end">

                    {/* GO TO WALLET */}
                    <Link to={RouteLinks.walletPage} className="relative px-2 flex justify-center items-center gap-2 cursor-pointer">
                        <i className="fa-solid fa-wallet text-xl"></i>
                    </Link>

                    {/* RIGHT DRAWER BUTTON */}
                     <div onClick={()=>setShowAsideDrawer('right-aside')} className='large:hidden  w-10 h-10 border border-slate-300 text-slate-500 dark:text-white-body rounded-md px-2 flex justify-center items-center gap-2 cursor-pointer' title='Switch Color Mode'>
                        <Icons name='right-panel' className="text-sm md:text-xl font-bold" />
                    </div>

                     {/* MESSAGE */}
                     {/* <button onClick={()=>handleDrawer(drawerName.chat)} className="relative px-2 flex justify-center items-center gap-2 cursor-pointer">
                        <i className="fa-regular fa-envelope text-xl"></i>
                        <div className="absolute w-4 h-4 right-0 top-4 text-[8px] flex justify-center items-center rounded-full bg-emerald-500 animate-pulse">1</div>
                    </button> */}

                    {/* THEME SELECTION */}
                    <div onClick={handleTheme} className='w-10 h-10 border border-slate-300 text-slate-500 dark:text-white-body rounded-md px-2 flex justify-center items-center gap-2 cursor-pointer' title='Switch Color Mode'>
                        {theme === 'dark' ?
                        <IoMdSunny className="text-sm md:text-xl font-bold" />
                        :
                        <LuSunDim className="text-sm md:text-xl font-bold" />
                        }
                    </div>

                    <div onClick={()=>handleActiveMenu('avatar')} className='relative cursor-pointer w-10 h-10 rounded shadow-round_black dark:shadow-round_white'>
                        <img src={UserAvatar} alt='user avatar' className='w-full h-full p-1 rounded-full' />
                        {activeMenu === 'avatar' &&
                            <div className="pop-modal z-[777] absolute p-4 w-52 sm:w-96 bg-white dark:bg-black-box right-0 top-16 rounded shadow-round_black dark:shadow-round_white">
                                <div className="w-full h-full flex flex-col gap-4">
                                    <div className="flex flex-col text-black dark:text-white text-base sm:text-lg">
                                        <h1 className="font-semibold">Username</h1>
                                        <p className="-mt-2">username@gmail.com</p>
                                    </div>
                                    <div className="rounded w-full flex justify-center items-center gap-2">
                                        <MainBtn
                                            text='Logout' 
                                            className="w-full text-center text-black-body hover:text-red-500 dark:text-white-body font-bold text-lg flex justify-center gap-2 items-center" 
                                            onClick={()=>setLogoutModal(true)}
                                        >
                                            <TbLogout2 className="text-base" />
                                        </MainBtn>
                                    </div>
                                </div>
                            </div>
                        }
                    </div>
                </div>
                </div>
        </header>
    </>
  )
}
