From d700bbb3f841b509d0f664cdf089e656cac4413a Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 28 Mar 2023 16:52:10 +0700 Subject: fix product mobile price --- .../product/components/Product/ProductMobile.jsx | 34 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/product/components/Product/ProductMobile.jsx b/src/lib/product/components/Product/ProductMobile.jsx index f6ed3d40..0df22026 100644 --- a/src/lib/product/components/Product/ProductMobile.jsx +++ b/src/lib/product/components/Product/ProductMobile.jsx @@ -13,16 +13,18 @@ import MobileView from '@/core/components/views/MobileView' import { toast } from 'react-hot-toast' import useVariantPrice from '@/lib/variant/hooks/useVariantPrice' import PriceSkeleton from '@/core/components/elements/Skeleton/PriceSkeleton' +import useProductPrice from '../../hooks/useProductPrice' const ProductMobile = ({ product, wishlist, toggleWishlist }) => { const router = useRouter() + const { productPrice } = useProductPrice({ id: product.id }) const [quantity, setQuantity] = useState('1') const [selectedVariant, setSelectedVariant] = useState(null) const [informationTab, setInformationTab] = useState(informationTabOptions[0].value) const [activeVariant, setActiveVariant] = useState({ - id: product.id, + id: null, code: product.code, name: product.name, price: product.lowestPrice, @@ -117,7 +119,35 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {

{activeVariant?.name}

- + {activeVariant.id && } + {product.variants?.length > 1 && !activeVariant.id && productPrice.isLoading && ( + + )} + {product.variants?.length > 1 && !activeVariant.id && productPrice.isFetched && ( + <> +
Harga mulai dari:
+ {productPrice?.data?.discount > 0 && ( +
+
+ {currencyFormat(productPrice?.data?.priceExclude)} +
+
{productPrice?.data?.discount}%
+
+ )} +

+ {productPrice?.data?.priceExcludeAfterDiscount > 0 ? ( + currencyFormat(productPrice?.data?.priceExcludeAfterDiscount) + ) : ( + + Hubungi kami untuk dapatkan harga terbaik,  + + klik disini + + + )} +

+ + )} -- cgit v1.2.3