From 556cbc1e5ea1c1ef0170c9a1b8f470a3d92d888e Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Tue, 2 Jul 2024 10:40:06 +0700
Subject: IS SO APPROVAL

---
 .../product-detail/components/PriceAction.tsx      | 75 +++++++++++++++-------
 1 file changed, 52 insertions(+), 23 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 f25847a5..d91ea49c 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -1,15 +1,16 @@
-import style from '../styles/price-action.module.css'
+import style from '../styles/price-action.module.css';
 
-import React, { 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 React, { 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';
 
 type Props = {
-  product: IProductDetail
-}
+  product: IProductDetail;
+};
 
 const PriceAction = ({ product }: Props) => {
   const {
@@ -18,15 +19,22 @@ const PriceAction = ({ product }: Props) => {
     activeVariantId,
     quantityInput,
     setQuantityInput,
-    askAdminUrl
-  } = useProductDetail()
+    askAdminUrl,
+    isApproval,
+    setIsApproval,
+  } = useProductDetail();
 
   useEffect(() => {
-    setActive(product.variants[0])
+    setActive(product.variants[0]);
   }, [product, setActive]);
 
+
+
   return (
-    <div className='block md:sticky top-[150px] bg-white py-0 md:py-6 z-10' id='price-section'>
+    <div
+      className='block md:sticky top-[150px] bg-white py-0 md:py-6 z-10'
+      id='price-section'
+    >
       {!!activePrice && activePrice.price > 0 && (
         <>
           <div className='flex items-end gap-x-2'>
@@ -46,8 +54,8 @@ const PriceAction = ({ product }: Props) => {
           </div>
           <div className='h-1' />
           <div className={style['secondary-text']}>
-            Termasuk PPN: {' '}
-            Rp {formatCurrency(Math.round(activePrice.price_discount * 1.11))}
+            Termasuk PPN: Rp{' '}
+            {formatCurrency(Math.round(activePrice.price_discount * 1.11))}
           </div>
         </>
       )}
@@ -55,7 +63,11 @@ const PriceAction = ({ product }: Props) => {
       {!!activePrice && activePrice.price === 0 && (
         <span>
           Hubungi kami untuk dapatkan harga terbaik,{' '}
-          <Link href={askAdminUrl} target='_blank' className={style['contact-us']}>
+          <Link
+            href={askAdminUrl}
+            target='_blank'
+            className={style['contact-us']}
+          >
             klik disini
           </Link>
         </span>
@@ -64,13 +76,30 @@ const PriceAction = ({ product }: Props) => {
       <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)} />
-        <AddToCart source='buy' variantId={activeVariantId} quantity={Number(quantityInput)} />
+        <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)}
+        />
+        {!isApproval && (
+          <AddToCart
+            source='buy'
+            variantId={activeVariantId}
+            quantity={Number(quantityInput)}
+          />
+        )}
       </div>
     </div>
-  )
-}
+  );
+};
 
-export default PriceAction
\ No newline at end of file
+export default PriceAction;
-- 
cgit v1.2.3

