From 94a96e371f554c7d87e2a6edbc6bdb7fe9228fd6 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 16 Oct 2024 13:19:45 +0700
Subject: <iman> add CR tambahin info jumlah barang ready stock yang bisa di
 pick up

---
 .../product-detail/components/PriceAction.tsx      | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

(limited to 'src-migrate/modules/product-detail/components/PriceAction.tsx')

diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx
index 3544fa26..5171308c 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -2,11 +2,12 @@ import style from '../styles/price-action.module.css';
 
 import Image from 'next/image';
 import Link from 'next/link';
-import { useEffect } from 'react';
+import { useEffect, useState } from 'react';
 import formatCurrency from '~/libs/formatCurrency';
 import { IProductDetail } from '~/types/product';
 import { useProductDetail } from '../stores/useProductDetail';
 import AddToCart from './AddToCart';
+import odooApi from '~/libs/odooApi';
 
 type Props = {
   product: IProductDetail;
@@ -25,7 +26,7 @@ const PriceAction = ({ product }: Props) => {
     selectedVariant,
     sla,
   } = useProductDetail();
-
+  const [qtyPickUp, setQtyPickUp] = useState(0);
   useEffect(() => {
     setActive(selectedVariant);
     if (product.variants.length > 2 && product.variants[0].price.price === 0) {
@@ -39,6 +40,18 @@ const PriceAction = ({ product }: Props) => {
     }
   }, [product, setActive, selectedVariant]);
 
+  useEffect(() => {
+    const fetchData = async () => {
+      const qty_available = await odooApi(
+        'GET',
+        `/api/v1/product_variant/${selectedVariant.id}/qty_available`
+      );
+
+      setQtyPickUp(qty_available?.qty);
+    };
+    fetchData();
+  }, [selectedVariant]);
+
   let voucherPastiHemat = 0;
 
   if (
@@ -143,6 +156,11 @@ const PriceAction = ({ product }: Props) => {
           )}
         </div>
       </div>
+      {qtyPickUp > 0 && (
+        <div className='text-[10px] mt-1 text-red-500 italic'>
+          * {qtyPickUp} barang bisa di pickup
+        </div>
+      )}
       <div className='h-4' />
 
       <div className={`${style['action-wrapper']}`}>
-- 
cgit v1.2.3


From c64472c479ec282af9b606a76358922b25752be0 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 25 Oct 2024 15:03:53 +0700
Subject: <iman> update revisi CR

---
 .../product-detail/components/PriceAction.tsx        | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

(limited to 'src-migrate/modules/product-detail/components/PriceAction.tsx')

diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx
index 5171308c..a87f8ae0 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -8,6 +8,7 @@ import { IProductDetail } from '~/types/product';
 import { useProductDetail } from '../stores/useProductDetail';
 import AddToCart from './AddToCart';
 import odooApi from '~/libs/odooApi';
+import { Button, Skeleton } from '@chakra-ui/react';
 
 type Props = {
   product: IProductDetail;
@@ -52,6 +53,10 @@ const PriceAction = ({ product }: Props) => {
     fetchData();
   }, [selectedVariant]);
 
+  useEffect(() => {
+    setQuantityInput('1');
+  }, [selectedVariant]);
+
   let voucherPastiHemat = 0;
 
   if (
@@ -137,10 +142,17 @@ const PriceAction = ({ product }: Props) => {
         </div>
 
         <div>
-          <span className={sla?.qty < 10 ? 'text-red-600 font-medium' : ''}>
-            {' '}
+          <Skeleton
+            isLoaded={sla}
+            h='21px'
+            // w={16}
+            className={sla?.qty < 10 ? 'text-red-600 font-medium' : ''}
+          >
             Stock : {sla?.qty}{' '}
-          </span>
+          </Skeleton>
+          {/* <span className={sla?.qty < 10 ? 'text-red-600 font-medium' : ''}>
+            {' '}
+          </span> */}
         </div>
         <div>
           {product?.is_in_bu && (
@@ -157,7 +169,7 @@ const PriceAction = ({ product }: Props) => {
         </div>
       </div>
       {qtyPickUp > 0 && (
-        <div className='text-[10px] mt-1 text-red-500 italic'>
+        <div className='text-[12px] mt-1 text-red-500 italic'>
           * {qtyPickUp} barang bisa di pickup
         </div>
       )}
-- 
cgit v1.2.3

