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 (
{location_profile.location.name}
{location_profile.display_note}
Rp {formatIDR(location_profile.validate_price)}
{+location_profile.discount !== 0 && (
{location_profile.discount}%
{formatIDR( location_profile.validate_display_price )}
)}
{location_profile.quota}
{location_profile.display_expired}
{quantity}
) }