import React, { useEffect, useState } from 'react' import toast, { Toaster } from 'react-hot-toast' import { router, usePage } from '@inertiajs/react' 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 [bounce, setBouce] = useState(false) const handleOnClick = (r) => { router.get(route(r, { direct: 1 })) } const isActive = (r) => { if (route().current(r)) { return 'text-primary-900 font-bold' } return 'text-gray-600 font-light' } const clearAnimate = () => { setBouce(false) } useEffect(() => { let se if (flash.message !== null && flash.message.type !== null) { toast.success((t) => { return (
toast.dismiss(t.id)}> {flash.message.message}
) }) if (+flash.message.cart === 1) { setBouce(true) se = setTimeout(clearAnimate, 3000) } } return () => clearTimeout(se) }, [flash]) return (
{children}
handleOnClick('home.index')} >
Beranda
handleOnClick('cart.index')} >
{cart_count}
Keranjang
handleOnClick('customer.poin.exchange')} >
Poin
handleOnClick('transactions.index')} >
Transaksi
handleOnClick( user !== null ? 'customer.profile.index' : 'customer.login' ) } >
Menu
) }