summaryrefslogtreecommitdiff
path: root/src-migrate/modules/product-detail/components/PriceAction.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src-migrate/modules/product-detail/components/PriceAction.tsx')
-rw-r--r--src-migrate/modules/product-detail/components/PriceAction.tsx50
1 files changed, 16 insertions, 34 deletions
diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx
index d73ab5f6..ea65b3d1 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -1,5 +1,4 @@
import style from '../styles/price-action.module.css';
-
import Image from 'next/image';
import Link from 'next/link';
import { useEffect, useState } from 'react';
@@ -15,14 +14,17 @@ import { Button, Skeleton } from '@chakra-ui/react';
import DesktopView from '@/core/components/views/DesktopView';
import MobileView from '@/core/components/views/MobileView';
+// 1. Tambahkan onCompare (Optional) di sini
type Props = {
product: IProductDetail;
+ onCompare?: () => void;
};
const PPN: number = process.env.NEXT_PUBLIC_PPN
? parseFloat(process.env.NEXT_PUBLIC_PPN)
: 0;
-const PriceAction = ({ product }: Props) => {
+
+const PriceAction = ({ product, onCompare }: Props) => {
const {
activePrice,
setActive,
@@ -146,19 +148,6 @@ const PriceAction = ({ product }: Props) => {
</>
)}
- {/* {!!activePrice && activePrice.price === 0 && (
- <span>
- Hubungi kami untuk dapatkan harga terbaik,{' '}
- <Link
- href={askAdminUrl}
- target='_blank'
- className={style['contact-us']}
- >
- klik disini
- </Link>
- </span>
- )} */}
-
<DesktopView>
<div className='h-4' />
<div className='flex gap-x-5 items-center'>
@@ -227,9 +216,6 @@ const PriceAction = ({ product }: Props) => {
)}
</div>
</div>
- {/* <span className='text-[12px] text-red-500 italic'>
- * {qtyPickUp} barang bisa di pickup
- </span> */}
</DesktopView>
{/* ===== MOBILE: grid kiri-kanan, kanan hanya qty ===== */}
@@ -263,12 +249,6 @@ const PriceAction = ({ product }: Props) => {
</Link>
)}
</div>
-
- {/* {qtyPickUp > 0 && (
- <div className='text-[12px] mt-1 text-red-500 italic'>
- * {qtyPickUp} barang bisa di pickup
- </div>
- )} */}
</div>
{/* Kanan: hanya qty, rata kanan */}
@@ -295,9 +275,9 @@ const PriceAction = ({ product }: Props) => {
value={quantityInput}
onChange={(e) => setQuantityInput(e.target.value)}
className='h-11 md:h-12 w-16 md:w-20 text-center text-lg md:text-xl outline-none border-x
- [appearance:textfield]
- [&::-webkit-outer-spin-button]:appearance-none
- [&::-webkit-inner-spin-button]:appearance-none'
+ [appearance:textfield]
+ [&::-webkit-outer-spin-button]:appearance-none
+ [&::-webkit-inner-spin-button]:appearance-none'
disabled={!hasPrice}
/>
@@ -322,24 +302,26 @@ const PriceAction = ({ product }: Props) => {
<div className={`${style['action-wrapper']}`}>
<AddToCart
products={product}
- variantId={activeVariantId}
+ variantId={selectedVariant?.id ?? null}
quantity={Number(quantityInput)}
/>
{!isApproval && (
<AddToCart
source='buy'
products={product}
- variantId={activeVariantId}
+ variantId={selectedVariant?.id ?? null}
quantity={Number(quantityInput)}
/>
)}
</div>
<div className='mt-4'>
+ {/* 2. TERUSKAN onCompare KE SINI */}
<AddToQuotation
source='buy'
products={product}
- variantId={activeVariantId}
+ variantId={selectedVariant?.id ?? null}
quantity={Number(quantityInput)}
+ onCompare={onCompare}
/>
</div>
</DesktopView>
@@ -349,14 +331,14 @@ const PriceAction = ({ product }: Props) => {
<AddToQuotation
source='buy'
products={product}
- variantId={activeVariantId}
+ variantId={selectedVariant?.id ?? null}
quantity={Number(quantityInput)}
/>
</div>
<div className='col-span-5'>
<AddToCart
products={product}
- variantId={activeVariantId}
+ variantId={selectedVariant?.id ?? null}
quantity={Number(quantityInput)}
/>
</div>
@@ -365,7 +347,7 @@ const PriceAction = ({ product }: Props) => {
<AddToCart
source='buy'
products={product}
- variantId={activeVariantId}
+ variantId={selectedVariant?.id ?? null}
quantity={Number(quantityInput)}
/>
)}
@@ -376,4 +358,4 @@ const PriceAction = ({ product }: Props) => {
);
};
-export default PriceAction;
+export default PriceAction; \ No newline at end of file