From 62c6c84dfae2564e92e2b3228c67d2fb12f5c3e5 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Thu, 22 Jun 2023 15:08:05 +0700
Subject: get promotion progrm

---
 src/lib/product/components/Product/ProductDesktop.jsx | 13 +++++++++++++
 1 file changed, 13 insertions(+)

(limited to 'src/lib/product/components/Product/ProductDesktop.jsx')

diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx
index d9c95327..c1243a50 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -17,6 +17,7 @@ import productSimilarApi from '../../api/productSimilarApi'
 import whatsappUrl from '@/core/utils/whatsappUrl'
 import PromotionType from '@/lib/promotinProgram/components/PromotionType'
 import useAuth from '@/core/hooks/useAuth'
+import odooApi from '@/core/api/odooApi'
 
 const ProductDesktop = ({ product, wishlist, toggleWishlist }) => {
   const router = useRouter()
@@ -36,6 +37,13 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => {
     return lowest
   }, [product])
 
+  useEffect(() => {
+    if(product.variants.length > 1){
+      const listProgram = getPromotionProgram(product.variants[0].id)
+      console.log('promotion list', listProgram)
+    }
+  },[product])
+
   useEffect(() => {
     const lowest = getLowestPrice()
     setLowestPrice(lowest)
@@ -486,4 +494,9 @@ const TabContent = ({ children, active, className = '', ...props }) => (
   </div>
 )
 
+const getPromotionProgram = async ({id}) => {
+  const listProgram = await odooApi('GET', `/api/v1/product_variant/${id}/promotions`)
+
+  return listProgram
+}
 export default ProductDesktop
-- 
cgit v1.2.3

