summaryrefslogtreecommitdiff
path: root/src/lib/auth/components/Menu.jsx
blob: 9a73609d789f757b8f62709d10d784a3f16c5f31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import Link from '@/core/components/elements/Link/Link'
import { useRouter } from 'next/router'

const Menu = () => {
  const router = useRouter()

  const routeStartWith = (route) => router.pathname.startsWith(route)

  return (
    <div className='grid grid-cols-1 bg-white border border-gray_r-6 rounded py-2 px-4'>
      <div className='mt-4 mb-1 font-medium'>Menu</div>
      <LinkItem href='/my/transactions' active={routeStartWith('/my/transaction')}>
        Daftar Transaksi
      </LinkItem>
      <LinkItem href='/my/invoices' active={routeStartWith('/my/invoice')}>
        Invoice & Faktur Pajak
      </LinkItem>
      <LinkItem href='/my/wishlist' active={routeStartWith('/my/wishlist')}>
        Wishlist
      </LinkItem>

      <div className='mt-4 mb-1 font-medium'>Pusat Bantuan</div>
      <LinkItem href='/'>Layanan Pelanggan</LinkItem>

      <div className='mt-4 mb-1 font-medium'>Pengaturan Akun</div>
      <LinkItem href='/my/address' active={routeStartWith('/my/address')}>
        Daftar Alamat
      </LinkItem>
      <button type='button' className='text-gray_r-12/80 p-2 text-left'>
        Keluar Akun
      </button>
    </div>
  )
}

const LinkItem = ({ children, ...props }) => (
  <Link
    {...props}
    className={`!text-gray_r-12/80 !font-normal p-2 rounded ${
      props.active == true ? 'bg-gray_r-3' : ''
    }`}
  >
    {children}
  </Link>
)

export default Menu