From 62efd1afc02422545579c529cd954d0c157889ee Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Sat, 18 Mar 2023 10:17:16 +0700
Subject: navbar user dropdown, add to cart

---
 .../components/elements/Navbar/NavbarDesktop.jsx   | 47 +++++++++++++++-------
 1 file changed, 33 insertions(+), 14 deletions(-)

(limited to 'src/core/components/elements/Navbar/NavbarDesktop.jsx')

diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx
index fa620eb2..3ee9dc1e 100644
--- a/src/core/components/elements/Navbar/NavbarDesktop.jsx
+++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx
@@ -11,11 +11,14 @@ import dynamic from 'next/dynamic'
 import IndoteknikLogo from '@/images/logo.png'
 import Category from '@/lib/category/components/Category'
 import { useState } from 'react'
+import useAuth from '@/core/hooks/useAuth'
+import NavbarUserDropdown from './NavbarUserDropdown'
 
 const Search = dynamic(() => import('./Search'))
 
 const NavbarDesktop = () => {
   const [isOpenCategory, setIsOpenCategory] = useState(false)
+  const auth = useAuth()
 
   return (
     <DesktopView>
@@ -82,7 +85,7 @@ const NavbarDesktop = () => {
           >
             <div>Kategori Produk</div>
             <ChevronDownIcon className={`ml-auto w-6 ${isOpenCategory ? 'rotate-180' : ''}`} />
-            
+
             <div className={`category-mega-box-wrapper ${isOpenCategory ? 'show' : ''}`}>
               <Category />
             </div>
@@ -113,19 +116,35 @@ const NavbarDesktop = () => {
               Blog Indoteknik
             </Link>
           </div>
-          <div className='w-3/12 flex gap-x-1'>
-            <Link
-              href='/login'
-              className='flex-1 flex justify-center items-center bg-red_r-11 !text-gray_r-1 rounded-none'
-            >
-              Masuk
-            </Link>
-            <Link
-              href='/register'
-              className='flex-1 flex justify-center items-center bg-red_r-11 !text-gray_r-1 rounded-none rounded-tr-xl'
-            >
-              Daftar
-            </Link>
+
+          <div className='w-3/12 flex gap-x-1 relative'>
+            {!auth && (
+              <>
+                <Link
+                  href='/login'
+                  className='flex-1 flex justify-center items-center bg-red_r-11 !text-gray_r-1 rounded-none'
+                >
+                  Masuk
+                </Link>
+                <Link
+                  href='/register'
+                  className='flex-1 flex justify-center items-center bg-red_r-11 !text-gray_r-1 rounded-none rounded-tr-xl'
+                >
+                  Daftar
+                </Link>
+              </>
+            )}
+            {auth && (
+              <>
+                <Link href='/' className='navbar-user-dropdown-button'>
+                  <span>Halo, {auth?.name}</span>
+                  <div className='ml-auto'>
+                    <ChevronDownIcon className='w-6' />
+                  </div>
+                </Link>
+                <NavbarUserDropdown />
+              </>
+            )}
           </div>
         </div>
       </div>
-- 
cgit v1.2.3

