import Image from '@/core/components/elements/Image/Image'
import Link from '@/core/components/elements/Link/Link'
import currencyFormat from '@/core/utils/currencyFormat'
import { createSlug } from '@/core/utils/slug'
import useProductPrice from '../hooks/useProductPrice'
import { LazyLoadComponent } from 'react-lazy-load-image-component'
import PriceSkeleton from '@/core/components/elements/Skeleton/PriceSkeleton'
const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
if (variant == 'vertical') {
return (
{product.variantTotal > 1 && (
{product.variantTotal} Varian
)}
{product?.manufacture?.name ? (
{product.manufacture.name}
) : (
-
)}
{product?.name}
{product?.stockTotal > 0 && (
Ready Stock
{product?.stockTotal > 5 ? '> 5' : '< 5'}
)}
)
}
if (variant == 'horizontal') {
return (
{product.variantTotal > 1 && (
{product.variantTotal} Varian
)}
{product?.manufacture?.name ? (
{product.manufacture.name}
) : (
-
)}
{product?.name}
{product?.stockTotal > 0 && (
Ready Stock
{product?.stockTotal > 5 ? '> 5' : '< 5'}
)}
)
}
}
const ProductCardPrice = ({ variant, id }) => {
const { productPrice } = useProductPrice({ id })
if (productPrice.isLoading) return
if (variant == 'vertical') {
return (
productPrice.isFetched && (
<>
{productPrice?.data?.discount > 0 && (
{currencyFormat(
productPrice?.data?.priceStartFrom || productPrice?.data?.priceExclude
)}
{productPrice?.data?.discount}%
)}
{productPrice?.data?.priceExcludeAfterDiscount > 0 ? (
currencyFormat(
productPrice?.data?.priceDiscStartFrom ||
productPrice?.data?.priceExcludeAfterDiscount
)
) : (
Call for price
)}
>
)
)
}
if (variant == 'horizontal') {
return (
productPrice.isFetched && (
<>
{productPrice?.data?.discount > 0 && (
{productPrice?.data?.discount}%
{currencyFormat(
productPrice?.data?.priceStartFrom || productPrice?.data?.priceExclude
)}
)}
{productPrice?.data?.priceExcludeAfterDiscount > 0 ? (
currencyFormat(
productPrice?.data?.priceDiscStartFrom ||
productPrice?.data?.priceExcludeAfterDiscount
)
) : (
Call for price
)}
>
)
)
}
}
export default ProductCard