import { formatIDR } from '@/utils' import { router, usePage } from '@inertiajs/react' import { HiMinusCircle, HiPlusCircle, HiTrash } from 'react-icons/hi2' export default function VoucherCard({ item, onRemove, onChangeQty }) { const { props: { auth: { user }, }, } = usePage() const { location_profile, quantity } = item const handleDelete = () => { onRemove(item) fetch( route('api.cart.store', { profile: location_profile, param: 'delete', }), { method: 'POST', credentials: 'include', headers: { 'Content-Type': 'application/json', user: user.id, }, } ) } const handleAdd = () => { const qty = +quantity + 1 onChangeQty(item, qty) fetch( route('api.cart.store', { profile: location_profile, param: 'add', }), { method: 'POST', credentials: 'include', headers: { 'Content-Type': 'application/json', user: user.id, }, } ) } const handleSub = () => { const qty = +quantity - 1 if (qty <= 0) { return } onChangeQty(item, qty) fetch( route('api.cart.store', { profile: location_profile, param: 'sub', }), { method: 'POST', credentials: 'include', headers: { 'Content-Type': 'application/json', user: user.id, }, } ) } return (