summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-migrate/modules/product-detail/components/AddToCart.tsx5
-rw-r--r--src-migrate/modules/product-detail/components/AddToQuotation.tsx7
-rw-r--r--src-migrate/modules/product-detail/components/PriceAction.tsx27
3 files changed, 20 insertions, 19 deletions
diff --git a/src-migrate/modules/product-detail/components/AddToCart.tsx b/src-migrate/modules/product-detail/components/AddToCart.tsx
index 18f90012..a8523f55 100644
--- a/src-migrate/modules/product-detail/components/AddToCart.tsx
+++ b/src-migrate/modules/product-detail/components/AddToCart.tsx
@@ -51,7 +51,7 @@ const AddToCart = ({
const { isMobile, isDesktop } = useDevice();
- const { askAdminUrl } = useProductDetail();
+ const { askAdminUrl, selectedVariant } = useProductDetail();
const [product, setProducts] = useState(products);
const [status, setStatus] = useState<Status>('idle');
@@ -72,8 +72,7 @@ const AddToCart = ({
weight: '',
isFlashSale: false,
});
- const hasPrice =
- !!product?.lowest_price && Number(product.lowest_price.price) > 0;
+ const hasPrice = Number(selectedVariant?.price?.price_discount || 0) > 0;
useEffect(() => {
const fetchData = async () => {
diff --git a/src-migrate/modules/product-detail/components/AddToQuotation.tsx b/src-migrate/modules/product-detail/components/AddToQuotation.tsx
index e26e271f..747e8718 100644
--- a/src-migrate/modules/product-detail/components/AddToQuotation.tsx
+++ b/src-migrate/modules/product-detail/components/AddToQuotation.tsx
@@ -44,7 +44,7 @@ const AddToQuotation = ({
isClosable: true,
});
- const { askAdminUrl } = useProductDetail();
+ const { askAdminUrl, selectedVariant } = useProductDetail();
const { isMobile, isDesktop } = useDevice();
const [product, setProducts] = useState(products);
@@ -64,8 +64,8 @@ const AddToQuotation = ({
`fq=-manufacture_id_i:${product.manufacture?.id || 0}`,
].join('&');
const [addCartAlert, setAddCartAlert] = useState(false);
- const hasPrice =
- !!product?.lowest_price && Number(product.lowest_price.price) > 0;
+
+ const hasPrice = Number(selectedVariant?.price?.price_discount || 0) > 0;
const handleButton = async () => {
if (typeof auth !== 'object') {
@@ -138,6 +138,7 @@ const AddToQuotation = ({
className="w-full border border-gray-300 p-2 gap-2 flex items-center justify-center text-gray-600 hover:text-red-600 hover:border-red-600 transition-all font-normal text-sm"
_hover={{ textDecoration: 'none' }}
onClick={handleButton}
+ isDisabled={!hasPrice}
>
<ImageNext src="/images/doc_red.svg" width={20} height={20} alt="penawaran" />
Penawaran
diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx
index ea65b3d1..37ee5055 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -80,7 +80,8 @@ const PriceAction = ({ product, onCompare }: Props) => {
const validJsonString = stringVoucher.replace(/'/g, '"');
voucherPastiHemat = JSON.parse(validJsonString);
}
- const hasPrice = Number(product?.lowest_price?.price) > 0;
+ const hasPrice = Number(selectedVariant?.price?.price_discount || 0) > 0;
+ const price = selectedVariant?.price;
return (
<div
@@ -90,59 +91,59 @@ const PriceAction = ({ product, onCompare }: Props) => {
}`}
id='price-section'
>
- {!!activePrice && activePrice.price > 0 && (
+ {!!price && price.price > 0 && (
<>
<DesktopView>
<div className='flex items-end gap-x-2'>
- {activePrice.discount_percentage > 0 && (
+ {price.discount_percentage > 0 && (
<>
<div className={style['disc-badge']}>
- {Math.floor(activePrice.discount_percentage)}%
+ {Math.floor(price.discount_percentage)}%
</div>
<div className={style['disc-price']}>
- Rp {formatCurrency(activePrice.price || 0)}
+ Rp {formatCurrency(price.price || 0)}
</div>
</>
)}
<div className={style['main-price']}>
- Rp {formatCurrency(activePrice.price_discount || 0)}
+ Rp {formatCurrency(price.price_discount || 0)}
</div>
</div>
<div className='h-1' />
<div className={style['secondary-text']}>
Termasuk PPN: Rp{' '}
- {formatCurrency(Math.round(activePrice.price_discount * PPN))}
+ {formatCurrency(Math.round(price.price_discount * PPN))}
</div>
</DesktopView>
<MobileView>
<div className='flex items-end gap-x-2'>
- {activePrice.discount_percentage > 0 ? (
+ {price.discount_percentage > 0 ? (
<>
<div className={style['disc-badge']}>
- {Math.floor(activePrice.discount_percentage)}%
+ {Math.floor(price.discount_percentage)}%
</div>
{/* harga setelah diskon (main-price) di kiri */}
<div className={style['main-price']}>
- Rp {formatCurrency(activePrice.price_discount || 0)}
+ Rp {formatCurrency(price.price_discount || 0)}
</div>
{/* harga coret di kanan */}
<div className={style['disc-price']}>
- Rp {formatCurrency(activePrice.price || 0)}
+ Rp {formatCurrency(price.price || 0)}
</div>
</>
) : (
// kalau tidak ada diskon, tampilkan harga normal saja
<div className={style['main-price']}>
- Rp {formatCurrency(activePrice.price || 0)}
+ Rp {formatCurrency(price.price || 0)}
</div>
)}
</div>
<div className='text-md text-gray-500 shadow-0'>
Termasuk PPN: Rp{' '}
- {formatCurrency(Math.round(activePrice.price_discount * PPN))}
+ {formatCurrency(Math.round(price.price_discount * PPN))}
</div>
</MobileView>
</>