import React, { useState } from 'react' import { usePage, router } from '@inertiajs/react' import BottomSheet from '@/Customer/Components/BottomSheet' const Payment = ({ state }) => { const { props: { payments }, } = usePage() const [processing, setProcessing] = useState(false) const isEnable = (enable) => { if (enable) { return 'font-semibold h-11 border bg-blue-700 text-white px-5 py-2 rounded-full hover:text-black hover:bg-white' } return 'font-semibold h-11 border bg-gray-400 text-white px-5 py-2 rounded-full' } const pay = (payment) => { if (processing) { return } router.post( route('cart.purchase'), { payed_with: payment, }, { onBefore: () => setProcessing(true), onFinish: () => setProcessing(false), } ) } return ( state.toggle()}>
Opsi Pembayaran
{payments.map((payment) => (
pay(payment.name)} > {payment.display_name}
))}
) } export default Payment