From 948914e88fa6849ec3be1cd88113dc7febeda577 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Thu, 22 Aug 2024 14:16:57 +0700
Subject: update template detail product

---
 .../product-detail/components/PriceAction.tsx      | 45 +++++++++++++---------
 1 file changed, 26 insertions(+), 19 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 81271f6e..405eb12b 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -22,23 +22,22 @@ const PriceAction = ({ product }: Props) => {
     askAdminUrl,
     isApproval,
     setIsApproval,
+    selectedVariant,
+    sla,
   } = useProductDetail();
 
   useEffect(() => {
-    setActive(product.variants[0])
-    if(product.variants.length > 2 && product.variants[0].price.price === 0){
-      const variants = product.variants
+    setActive(selectedVariant);
+    if (product.variants.length > 2 && product.variants[0].price.price === 0) {
+      const variants = product.variants;
       for (let i = 0; i < variants.length; i++) {
-        if(variants[i].price.price > 0){
-          setActive(variants[i])
+        if (variants[i].price.price > 0) {
+          setActive(variants[i]);
           break;
         }
       }
     }
-   
-  }, [product, setActive]);
-
-
+  }, [product, setActive, selectedVariant]);
 
   return (
     <div
@@ -83,19 +82,27 @@ const PriceAction = ({ product }: Props) => {
         </span>
       )}
 
+      <div className='h-4' />
+      <div className='flex gap-x-5 items-center'>
+        <div>
+          <label htmlFor='quantity' className='hidden'>
+            Quantity
+          </label>
+          <input
+            type='number'
+            id='quantity'
+            value={quantityInput}
+            onChange={(e) => setQuantityInput(e.target.value)}
+            className={style['quantity-input']}
+          />
+        </div>
+        <div>
+          <span className={sla?.qty < 10 ? 'text-red-600 font-medium' : ''} > Stock : {sla?.qty} </span>
+        </div>
+      </div>
       <div className='h-4' />
 
       <div className={style['action-wrapper']}>
-        <label htmlFor='quantity' className='hidden'>
-          Quantity
-        </label>
-        <input
-          type='number'
-          id='quantity'
-          value={quantityInput}
-          onChange={(e) => setQuantityInput(e.target.value)}
-          className={style['quantity-input']}
-        />
         <AddToCart
           variantId={activeVariantId}
           quantity={Number(quantityInput)}
-- 
cgit v1.2.3


From f8133c76306d9f70e01ac510c74dcfabe7f79b37 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Mon, 26 Aug 2024 10:47:28 +0700
Subject: new product template

---
 .../product-detail/components/PriceAction.tsx      | 33 ++++++++++++++++------
 1 file changed, 25 insertions(+), 8 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 405eb12b..b46afac9 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -39,6 +39,18 @@ const PriceAction = ({ product }: Props) => {
     }
   }, [product, setActive, selectedVariant]);
 
+  let voucherPastiHemat = 0;
+
+  if (
+    product?.voucher_pasti_hemat
+      ? product?.voucher_pasti_hemat.length
+      : voucherPastiHemat > 0
+  ) {
+    const stringVoucher = product?.voucher_pasti_hemat[0];
+    const validJsonString = stringVoucher.replace(/'/g, '"');
+    voucherPastiHemat = JSON.parse(validJsonString);
+  }
+
   return (
     <div
       className='block md:sticky top-[150px] bg-white py-0 md:py-6 z-10'
@@ -88,16 +100,21 @@ const PriceAction = ({ product }: Props) => {
           <label htmlFor='quantity' className='hidden'>
             Quantity
           </label>
-          <input
-            type='number'
-            id='quantity'
-            value={quantityInput}
-            onChange={(e) => setQuantityInput(e.target.value)}
-            className={style['quantity-input']}
-          />
+          <div className='flex items-center space-x-2'>
+            <input
+              type='number'
+              id='quantity'
+              value={quantityInput}
+              onChange={(e) => setQuantityInput(e.target.value)}
+              className={style['quantity-input']}
+            />
+          </div>
         </div>
         <div>
-          <span className={sla?.qty < 10 ? 'text-red-600 font-medium' : ''} > Stock : {sla?.qty} </span>
+          <span className={sla?.qty < 10 ? 'text-red-600 font-medium' : ''}>
+            {' '}
+            Stock : {sla?.qty}{' '}
+          </span>
         </div>
       </div>
       <div className='h-4' />
-- 
cgit v1.2.3


From 1475593324319d1faf377f2d00a22a4b3caa3faa Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Thu, 12 Sep 2024 15:08:21 +0700
Subject: price action

---
 .../modules/product-detail/components/PriceAction.tsx  | 18 ++++++++++++++++--
 1 file changed, 16 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 6042d578..a39877e9 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -7,6 +7,7 @@ import { useProductDetail } from '../stores/useProductDetail';
 import AddToCart from './AddToCart';
 import Link from 'next/link';
 import { getAuth } from '~/libs/auth';
+import Image from 'next/image';
 
 type Props = {
   product: IProductDetail;
@@ -53,7 +54,7 @@ const PriceAction = ({ product }: Props) => {
 
   return (
     <div
-      className='block md:sticky top-[150px] bg-white py-0 md:py-6 z-10'
+      className='block md:sticky md:top-[150px] md:py-6 fixed bottom-0 left-0 right-0 bg-white p-4 z-10'
       id='price-section'
     >
       {!!activePrice && activePrice.price > 0 && (
@@ -116,10 +117,23 @@ const PriceAction = ({ product }: Props) => {
             Stock : {sla?.qty}{' '}
           </span>
         </div>
+        <div>
+          {product?.is_in_bu && (
+            <Link href='/panduan-pick-up-service' className='group'>
+              <Image
+                src='/images/PICKUP-NOW.png'
+                className='group-hover:scale-105 transition-transform duration-200'
+                alt='pickup now'
+                width={100}
+                height={12}
+              />
+            </Link>
+          )}
+        </div>
       </div>
       <div className='h-4' />
 
-      <div className={style['action-wrapper']}>
+      <div className={`${style['action-wrapper']}`}>
         <AddToCart
           products={product}
           variantId={activeVariantId}
-- 
cgit v1.2.3


From 9a3d52dc189f7a309951c60fd923c49e9fb9085a Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Thu, 26 Sep 2024 15:45:03 +0700
Subject: dertail product

---
 .../product-detail/components/PriceAction.tsx      | 48 ++++++++++++++--------
 1 file changed, 30 insertions(+), 18 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 a39877e9..3544fa26 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -1,13 +1,12 @@
 import style from '../styles/price-action.module.css';
 
-import React, { useEffect } from 'react';
+import Image from 'next/image';
+import Link from 'next/link';
+import { useEffect } from 'react';
 import formatCurrency from '~/libs/formatCurrency';
 import { IProductDetail } from '~/types/product';
 import { useProductDetail } from '../stores/useProductDetail';
 import AddToCart from './AddToCart';
-import Link from 'next/link';
-import { getAuth } from '~/libs/auth';
-import Image from 'next/image';
 
 type Props = {
   product: IProductDetail;
@@ -54,7 +53,7 @@ const PriceAction = ({ product }: Props) => {
 
   return (
     <div
-      className='block md:sticky md:top-[150px] md:py-6 fixed bottom-0 left-0 right-0 bg-white p-4 z-10'
+      className='block md:sticky md:top-[150px] md:py-6 fixed bottom-0 left-0 right-0 bg-white p-2 z-10'
       id='price-section'
     >
       {!!activePrice && activePrice.price > 0 && (
@@ -97,20 +96,33 @@ const PriceAction = ({ product }: Props) => {
 
       <div className='h-4' />
       <div className='flex gap-x-5 items-center'>
-        <div>
-          <label htmlFor='quantity' className='hidden'>
-            Quantity
-          </label>
-          <div className='flex items-center space-x-2'>
-            <input
-              type='number'
-              id='quantity'
-              value={quantityInput}
-              onChange={(e) => setQuantityInput(e.target.value)}
-              className={style['quantity-input']}
-            />
-          </div>
+        <div className='relative flex items-center'>
+          <button
+            type='button'
+            className='absolute left-0 px-2 py-1 h-full text-gray-500'
+            onClick={() =>
+              setQuantityInput(String(Math.max(1, Number(quantityInput) - 1)))
+            }
+          >
+            -
+          </button>
+          <input
+            type='number'
+            id='quantity'
+            min={1}
+            value={quantityInput}
+            onChange={(e) => setQuantityInput(e.target.value)}
+            className={style['quantity-input']}
+          />
+          <button
+            type='button'
+            className='absolute right-0 px-2 py-1 h-full text-gray-500'
+            onClick={() => setQuantityInput(String(Number(quantityInput) + 1))}
+          >
+            +
+          </button>
         </div>
+
         <div>
           <span className={sla?.qty < 10 ? 'text-red-600 font-medium' : ''}>
             {' '}
-- 
cgit v1.2.3


From d4f59658ab714325f7ff679997c22b306e766d5c Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 11 Oct 2024 15:46:55 +0700
Subject: <iman> add penawaran instan

---
 src-migrate/modules/product-detail/components/PriceAction.tsx | 9 +++++++++
 1 file changed, 9 insertions(+)

(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 9021264e..a69e896c 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -5,6 +5,7 @@ import formatCurrency from '~/libs/formatCurrency';
 import { IProductDetail } from '~/types/product';
 import { useProductDetail } from '../stores/useProductDetail';
 import AddToCart from './AddToCart';
+import AddToQuotation from './AddToQuotation';
 import Link from 'next/link';
 import { getAuth } from '~/libs/auth';
 
@@ -110,6 +111,14 @@ const PriceAction = ({ product }: Props) => {
           />
         )}
       </div>
+      <div className='mt-4'>
+        <AddToQuotation
+          source='buy'
+          products={product}
+          variantId={activeVariantId}
+          quantity={Number(quantityInput)}
+        />
+      </div>
     </div>
   );
 };
-- 
cgit v1.2.3


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 17d4827393616734a37ff7b43b0f697283271164 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 24 Oct 2024 10:12:11 +0700
Subject: <iman> avoid error code

---
 src-migrate/modules/product-detail/components/PriceAction.tsx | 1 -
 1 file changed, 1 deletion(-)

(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 a3126cdd..a9b17f92 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -8,7 +8,6 @@ import { IProductDetail } from '~/types/product';
 import { useProductDetail } from '../stores/useProductDetail';
 import AddToCart from './AddToCart';
 import AddToQuotation from './AddToQuotation';
-import Link from 'next/link';
 import { getAuth } from '~/libs/auth';
 
 type Props = {
-- 
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


From f7a32dbccbdefd478ed6bd6190bd4fa395eda720 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 6 Nov 2024 15:42:41 +0700
Subject: <iman> update mobile view

---
 src-migrate/modules/product-detail/components/PriceAction.tsx | 8 ++++++--
 1 file changed, 6 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..dc384dda 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -7,6 +7,7 @@ import formatCurrency from '~/libs/formatCurrency';
 import { IProductDetail } from '~/types/product';
 import { useProductDetail } from '../stores/useProductDetail';
 import AddToCart from './AddToCart';
+import useDevice from '@/core/hooks/useDevice';
 
 type Props = {
   product: IProductDetail;
@@ -25,7 +26,7 @@ const PriceAction = ({ product }: Props) => {
     selectedVariant,
     sla,
   } = useProductDetail();
-
+  const { isDesktop, isMobile } = useDevice();
   useEffect(() => {
     setActive(selectedVariant);
     if (product.variants.length > 2 && product.variants[0].price.price === 0) {
@@ -53,7 +54,10 @@ const PriceAction = ({ product }: Props) => {
 
   return (
     <div
-      className='block md:sticky md:top-[150px] md:py-6 fixed bottom-0 left-0 right-0 bg-white p-2 z-10'
+      className={`block md:sticky md:top-[150px] md:py-6 fixed  bottom-0 left-0 right-0 bg-white p-2 z-10 ${
+        isMobile &&
+        'pb-8 pt-6  rounded-lg  shadow-[rgba(0,0,4,0.1)_0px_-4px_4px_0px] '
+      }`}
       id='price-section'
     >
       {!!activePrice && activePrice.price > 0 && (
-- 
cgit v1.2.3


From 337e0f377624e5a0b46aa0ed3c3c16ba4e289965 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 6 Nov 2024 16:36:57 +0700
Subject: <iman> update mobile view

---
 src-migrate/modules/product-detail/components/PriceAction.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(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 a44e35ec..b549d39f 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -58,7 +58,7 @@ const PriceAction = ({ product }: Props) => {
     <div
       className={`block md:sticky md:top-[150px] md:py-6 fixed  bottom-0 left-0 right-0 bg-white p-2 z-10 ${
         isMobile &&
-        'pb-8 pt-6  rounded-lg  shadow-[rgba(0,0,4,0.1)_0px_-4px_4px_0px] '
+        'pb-6 pt-6  rounded-lg  shadow-[rgba(0,0,4,0.1)_0px_-4px_4px_0px] '
       }`}
       id='price-section'
     >
-- 
cgit v1.2.3

