import React, { useState } from 'react' import { Head, router } from '@inertiajs/react' import { formatIDR } from '@/utils' import CustomerLayout from '@/Layouts/CustomerLayout' import VoucherCard from './VoucherCard' import EmptyHere from './IndexPartials/EmptyHere' import { useModalState } from '@/hooks' import Payment from './IndexPartials/Payment' export default function Index({ carts: items, total, allow_process }) { const [carts, setCarts] = useState(items) const paymentModal = useModalState() const removeCart = (cart) => { setCarts(carts.filter((c) => c.id !== cart.id)) } console.log(carts) const changeQty = (cart, qty) => { setCarts( carts.map((c) => { if (c.id === cart.id) { return { ...c, quantity: qty, } } return c }) ) } const handlePayment = () => { paymentModal.toggle() } const handleTopUp = () => { router.get(route('transactions.deposit.topup')) } return (
Keranjang
{carts.length > 0 ? ( <>
{carts.map((item) => ( ))}
Total Harga
Rp. {formatIDR(total)}
{allow_process ? (
Bayar
) : (
Top Up
)}
{allow_process === false && (
saldo tidak cukup
)}
) : ( )}
) }