You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
4.0 KiB
React

import React, { useEffect } from 'react'
1 year ago
import { ToastContainer, toast } from 'react-toastify'
import { router, usePage } from '@inertiajs/react'
1 year ago
import { HiOutlineHome } from 'react-icons/hi'
import {
HiArrowPathRoundedSquare,
HiBars3,
HiOutlineGift,
HiOutlineShoppingCart,
} from 'react-icons/hi2'
export default function CustomerLayout({ children }) {
const {
props: {
auth: { user },
cart_count,
flash,
},
} = usePage()
const handleOnClick = (r) => {
router.get(route(r))
}
const isActive = (r) => {
if (route().current(r)) {
return 'text-blue-700 font-bold'
}
return 'text-gray-600 font-light'
}
useEffect(() => {
if (flash.message !== null) {
toast(flash.message.message, { type: flash.message.type })
}
}, [flash])
return (
1 year ago
<div className="min-h-screen flex flex-col sm:justify-center items-center">
<div className="flex flex-col w-full bg-white shadow pb-20 min-h-[calc(90dvh)] max-w-md">
1 year ago
<div>{children}</div>
</div>
<div className="fixed px-2 bottom-0 flex flex-row gap-0 justify-between w-full bg-gray-50 max-w-md">
1 year ago
<div
className={`pb-1 pt-2 hover:bg-blue-200 flex flex-col items-center w-full ${isActive(
'home.index'
)}`}
1 year ago
onClick={() => handleOnClick('home.index')}
>
<HiOutlineHome className="h-6 w-6" />
<div className="text-xs">Beranda</div>
1 year ago
</div>
<div
className={`pb-1 pt-2 hover:bg-blue-200 flex flex-col items-center w-full ${isActive(
'cart.index'
)}`}
onClick={() => handleOnClick('cart.index')}
>
<div className="flex flex-row">
<HiOutlineShoppingCart className="h-6 w-6" />
<div>
<div className="bg-blue-300 text-blue-600 rounded-lg px-1 text-xs -ml-2">
{cart_count}
</div>
1 year ago
</div>
</div>
<div className="text-xs">Keranjang</div>
1 year ago
</div>
<div
className={`pb-1 pt-2 hover:bg-blue-200 flex flex-col items-center w-full ${isActive(
'customer.coin.exchange'
)}`}
onClick={() => handleOnClick('customer.coin.exchange')}
>
<div className="flex flex-row">
<HiOutlineGift className="h-6 w-6" />
</div>
<div className="text-xs">Coin</div>
</div>
<div
className={`pb-1 pt-2 hover:bg-blue-200 flex flex-col items-center w-full ${isActive(
'transactions.*'
)}`}
onClick={() => handleOnClick('transactions.index')}
>
<HiArrowPathRoundedSquare className="h-6 w-6" />
<div className="text-xs">Transaksi</div>
</div>
<div
className={`py-2 hover:bg-blue-200 flex flex-col items-center w-full ${isActive(
'customer.profile.*'
)}`}
onClick={() =>
handleOnClick(
user !== null
? 'customer.profile.index'
: 'customer.login'
)
}
>
<HiBars3 className="h-6 w-6" />
<div className="text-xs">Menu</div>
1 year ago
</div>
</div>
1 year ago
<ToastContainer />
</div>
)
}