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.tsx34
1 files changed, 23 insertions, 11 deletions
diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx
index ffc9ba40..d73ab5f6 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -37,6 +37,7 @@ const PriceAction = ({ product }: Props) => {
} = useProductDetail();
const [qtyPickUp, setQtyPickUp] = useState(0);
const { isDesktop, isMobile } = useDevice();
+
useEffect(() => {
setActive(selectedVariant);
if (product.variants.length > 2 && product.variants[0].price.price === 0) {
@@ -77,6 +78,7 @@ const PriceAction = ({ product }: Props) => {
const validJsonString = stringVoucher.replace(/'/g, '"');
voucherPastiHemat = JSON.parse(validJsonString);
}
+ const hasPrice = Number(product?.lowest_price?.price) > 0;
return (
<div
@@ -144,7 +146,7 @@ const PriceAction = ({ product }: Props) => {
</>
)}
- {!!activePrice && activePrice.price === 0 && (
+ {/* {!!activePrice && activePrice.price === 0 && (
<span>
Hubungi kami untuk dapatkan harga terbaik,{' '}
<Link
@@ -155,7 +157,7 @@ const PriceAction = ({ product }: Props) => {
klik disini
</Link>
</span>
- )}
+ )} */}
<DesktopView>
<div className='h-4' />
@@ -164,27 +166,32 @@ const PriceAction = ({ product }: Props) => {
<div className='relative flex items-center'>
<button
type='button'
- className='absolute left-0 px-2 py-1 h-full text-gray-500'
+ className='absolute left-0 px-2 py-1 h-full text-gray-500 disabled:opacity-40'
onClick={() =>
setQuantityInput(String(Math.max(1, Number(quantityInput) - 1)))
}
+ disabled={!hasPrice}
>
-
</button>
+
<input
type='number'
id='quantity'
min={1}
value={quantityInput}
onChange={(e) => setQuantityInput(e.target.value)}
- className={style['quantity-input']}
+ className={`${style['quantity-input']} disabled:bg-gray-100 disabled:text-gray-400`}
+ disabled={!hasPrice}
/>
+
<button
type='button'
- className='absolute right-0 px-2 py-1 h-full text-gray-500'
+ className='absolute right-0 px-2 py-1 h-full text-gray-500 disabled:opacity-40'
onClick={() =>
setQuantityInput(String(Number(quantityInput) + 1))
}
+ disabled={!hasPrice}
>
+
</button>
@@ -195,9 +202,11 @@ const PriceAction = ({ product }: Props) => {
<Skeleton
isLoaded={sla}
h='21px'
- className={sla?.qty < 10 ? 'text-red-600 font-medium' : ''}
+ className={
+ !hasPrice || sla?.qty < 10 ? 'text-red-600 font-medium' : ''
+ }
>
- Stock : {sla?.qty}{' '}
+ Stock : {hasPrice ? sla?.qty : 'Habis'}
</Skeleton>
</div>
@@ -218,9 +227,9 @@ const PriceAction = ({ product }: Props) => {
)}
</div>
</div>
- <span className='text-[12px] text-red-500 italic'>
+ {/* <span className='text-[12px] text-red-500 italic'>
* {qtyPickUp} barang bisa di pickup
- </span>
+ </span> */}
</DesktopView>
{/* ===== MOBILE: grid kiri-kanan, kanan hanya qty ===== */}
@@ -255,11 +264,11 @@ const PriceAction = ({ product }: Props) => {
)}
</div>
- {qtyPickUp > 0 && (
+ {/* {qtyPickUp > 0 && (
<div className='text-[12px] mt-1 text-red-500 italic'>
* {qtyPickUp} barang bisa di pickup
</div>
- )}
+ )} */}
</div>
{/* Kanan: hanya qty, rata kanan */}
@@ -274,6 +283,7 @@ const PriceAction = ({ product }: Props) => {
)
}
aria-label='Kurangi'
+ disabled={!hasPrice}
>
<span className='text-2xl leading-none'>–</span>
</button>
@@ -288,6 +298,7 @@ const PriceAction = ({ product }: Props) => {
[appearance:textfield]
[&::-webkit-outer-spin-button]:appearance-none
[&::-webkit-inner-spin-button]:appearance-none'
+ disabled={!hasPrice}
/>
<button
@@ -297,6 +308,7 @@ const PriceAction = ({ product }: Props) => {
setQuantityInput(String(Number(quantityInput) + 1))
}
aria-label='Tambah'
+ disabled={!hasPrice}
>
<span className='text-2xl leading-none'>+</span>
</button>