import Image from 'next/image' import React from 'react' import formatCurrency from '~/common/libs/formatCurrency' import { CartItem as CartItemProps } from '~/common/types/cart' import ProductPromo from './ProductPromo' import { Skeleton, SkeletonProps } from '@chakra-ui/react' import style from '../styles/CartItem.module.css' import CartItemAction from '../components/CartItemAction' import CartItemSelect from '../components/CartItemSelect' type Props = { item: CartItemProps } const CartItem = ({ item }: Props) => { const image = item?.image || item?.parent?.image return (
{image && {item.name}} {!image &&
No Image
}
{item.name}
{item.cart_type === 'promotion' && (
Rp {formatCurrency((item.package_price || 0))} Hemat Rp {formatCurrency((item.package_price || 0) - item.subtotal)} Rp {formatCurrency(item.subtotal)}
)} {item.cart_type === 'product' && ( <>
Rp {formatCurrency(item.price.price)}
{item.code}
)}
Berat barang: {item.weight} Kg
{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