import style from '../styles/item.module.css'
import Image from 'next/image'
import React from 'react'
import { Skeleton, SkeletonProps, Tooltip } from '@chakra-ui/react'
import { InfoIcon } from 'lucide-react'
import { PROMO_CATEGORY } from '~/constants/promotion'
import formatCurrency from '~/libs/formatCurrency'
import { CartItem as CartItemProps } from '~/types/cart'
import CartItemPromo from './ItemPromo'
import CartItemAction from './ItemAction'
import CartItemSelect from './ItemSelect'
type Props = {
item: CartItemProps
editable?: boolean
}
const CartItem = ({ item, editable = true }: Props) => {
const image = item?.image || item?.parent?.image
return (
{item.cart_type === 'promotion' && (
{item.promotion_type?.value && (
Paket {PROMO_CATEGORY[item.promotion_type?.value].alias}
)}
Selamat! Pembelian anda lebih hemat {' '}
Rp{formatCurrency((item.package_price || 0) * item.quantity - item.subtotal)}
)}
{editable &&
}
{image &&
}
{!image &&
No Image
}
{item.name}
{item.cart_type === 'promotion' && (
Rp {formatCurrency((item.package_price || 0))}
Rp {formatCurrency(item.price.price)}
)}
{item.cart_type === 'product' && (
<>
Rp {formatCurrency(item.price.price)}
{item.code}
>
)}
{item.weight} Kg
{editable &&
}
{!editable &&
{item.quantity}
}
{item.products?.map((product) => )}
{item.free_products?.map((product) => )}
)
}
CartItem.Skeleton = function CartItemSkeleton(props: SkeletonProps & { count: number }) {
return Array.from({ length: props.count }).map((_, index) => (
))
}
export default CartItem