diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-11-16 10:08:14 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-11-16 10:08:14 +0700 |
| commit | 9a15f2eea3f182ce8b9cf749f3dcd7b7f42efbaf (patch) | |
| tree | 4ad2b18c126a19728827f877aeb8be4085c3baf0 /src/lib/auth | |
| parent | 607ddd5050b5ee900606984b60e74d094fbe89f9 (diff) | |
<iman> CR website
Diffstat (limited to 'src/lib/auth')
| -rw-r--r-- | src/lib/auth/components/Menu.jsx | 99 |
1 files changed, 76 insertions, 23 deletions
diff --git a/src/lib/auth/components/Menu.jsx b/src/lib/auth/components/Menu.jsx index f475db1f..9cd10ab4 100644 --- a/src/lib/auth/components/Menu.jsx +++ b/src/lib/auth/components/Menu.jsx @@ -1,76 +1,129 @@ -import Link from '@/core/components/elements/Link/Link' -import { useRouter } from 'next/router' -import ImageNext from 'next/image' -import whatsappUrl from '@/core/utils/whatsappUrl' - +import Link from '@/core/components/elements/Link/Link'; +import { useRouter } from 'next/router'; +import ImageNext from 'next/image'; +import whatsappUrl from '@/core/utils/whatsappUrl'; +import { deleteAuth } from '@/core/utils/auth'; const Menu = () => { - const router = useRouter() + const router = useRouter(); + + const routeStartWith = (route) => router.pathname.startsWith(route); - const routeStartWith = (route) => router.pathname.startsWith(route) + const logout = async () => { + deleteAuth().then(() => { + router.push('/login'); + }); + }; return ( <div className='grid grid-cols-1 bg-white border border-gray_r-6 rounded py-2 px-4 sticky top-48'> <div className='mt-4 mb-1 font-medium'>Menu</div> <LinkItem href='/my/quotations' active={routeStartWith('/my/quotations')}> <div className='flex gap-x-3 items-center'> - <ImageNext src='/images/icon/icon_daftar_quotation.svg' width={18} height={20} /> + <ImageNext + src='/images/icon/icon_daftar_quotation.svg' + width={18} + height={20} + /> <p>Daftar Quotation</p> </div> </LinkItem> - <LinkItem href='/my/transactions' active={routeStartWith('/my/transactions')}> + <LinkItem + href='/my/transactions' + active={routeStartWith('/my/transactions')} + > <div className='flex gap-x-3 items-center'> - <ImageNext src='/images/icon/icon_daftar_transaksi.svg' width={18} height={20} /> + <ImageNext + src='/images/icon/icon_daftar_transaksi.svg' + width={18} + height={20} + /> <p>Daftar Transaksi</p> </div> </LinkItem> <LinkItem href='/my/shipments' active={routeStartWith('/my/shipments')}> <div className='flex gap-x-3 items-center'> - <ImageNext src='/images/icon/icon_pengiriman.svg' width={18} height={20} /> + <ImageNext + src='/images/icon/icon_pengiriman.svg' + width={18} + height={20} + /> <p>Daftar Pengiriman</p> </div> </LinkItem> <LinkItem href='/my/invoices' active={routeStartWith('/my/invoices')}> <div className='flex gap-x-3 items-center'> - <ImageNext src='/images/icon/icon_invoice.svg' width={18} height={20} /> + <ImageNext + src='/images/icon/icon_invoice.svg' + width={18} + height={20} + /> <p>Invoice & Faktur Pajak</p> </div> </LinkItem> <LinkItem href='/my/wishlist' active={routeStartWith('/my/wishlist')}> <div className='flex gap-x-3 items-center'> - <ImageNext src='/images/icon/icon_wishlist.svg' width={18} height={20} /> + <ImageNext + src='/images/icon/icon_wishlist.svg' + width={18} + height={20} + /> <p>Wishlist</p> </div> </LinkItem> <div className='mt-4 mb-1 font-medium'>Pusat Bantuan</div> - <LinkItem href={whatsappUrl('', '', '')} rel='noopener noreferrer' target='_blank'> + <LinkItem + href={whatsappUrl('', '', '')} + rel='noopener noreferrer' + target='_blank' + > <div className='flex gap-x-3 items-center'> - <ImageNext src='/images/icon/icon_layanan_pelanggan.svg' width={18} height={20} /> + <ImageNext + src='/images/icon/icon_layanan_pelanggan.svg' + width={18} + height={20} + /> <p>Layanan Pelanggan</p> </div> </LinkItem> <div className='mt-4 mb-1 font-medium'>Pengaturan Akun</div> <LinkItem href='/my/address' active={routeStartWith('/my/address')}> <div className='flex gap-x-3 items-center'> - <ImageNext src='/images/icon/icon_daftar_alamat.svg' width={18} height={20} /> + <ImageNext + src='/images/icon/icon_daftar_alamat.svg' + width={18} + height={20} + /> <p>Daftar Alamat</p> </div> </LinkItem> <LinkItem href='/my/profile' active={routeStartWith('/my/profile')}> <div className='flex gap-x-3 items-center'> - <ImageNext src='/images/icon/icon_profile.svg' width={18} height={20} /> + <ImageNext + src='/images/icon/icon_profile.svg' + width={18} + height={20} + /> <p>Profil Saya</p> </div> </LinkItem> - <button type='button' className='text-gray_r-12/80 p-2 text-left'> + <button + type='button' + onClick={logout} + className='text-gray_r-12/80 p-2 text-left' + > <div className='flex gap-x-3 items-center'> - <ImageNext src='/images/icon/icon_logout.svg' width={18} height={20} /> + <ImageNext + src='/images/icon/icon_logout.svg' + width={18} + height={20} + /> <p>Keluar Akun</p> </div> </button> </div> - ) -} + ); +}; const LinkItem = ({ children, ...props }) => ( <Link @@ -81,6 +134,6 @@ const LinkItem = ({ children, ...props }) => ( > {children} </Link> -) +); -export default Menu +export default Menu; |
