From e5c08cb213d0c6dbfa5a931e03eeccac518ddba1 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Fri, 15 Sep 2023 09:32:12 +0700
Subject: change get product odoo to solr di page navbar & basiclayout & bugfix
 redirect login next page null

---
 src/core/components/layouts/BasicLayout.jsx | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

(limited to 'src/core/components/layouts/BasicLayout.jsx')

diff --git a/src/core/components/layouts/BasicLayout.jsx b/src/core/components/layouts/BasicLayout.jsx
index 266223d8..030f916c 100644
--- a/src/core/components/layouts/BasicLayout.jsx
+++ b/src/core/components/layouts/BasicLayout.jsx
@@ -11,6 +11,7 @@ import { getAuth, setAuth } from '@/core/utils/auth'
 import { createSlug, getIdFromSlug } from '@/core/utils/slug'
 import { useSession } from 'next-auth/react'
 import { setCookie } from 'cookies-next'
+import { useProductContext } from '@/contexts/ProductContext'
 
 const Navbar = dynamic(() => import('../elements/Navbar/Navbar'))
 const AnimationLayout = dynamic(() => import('./AnimationLayout'))
@@ -22,6 +23,22 @@ const BasicLayout = ({ children }) => {
 
   const router = useRouter()
 
+  const { product } = useProductContext()
+
+  useEffect(() => {
+    if (router.pathname === '/shop/product/[slug]') {
+      setPayloadWa({
+        name: product?.name,
+        manufacture: product?.manufacture.name,
+        url: createSlug('/shop/product/', product?.name, product?.id, true)
+      })
+      setTemplateWA('product')
+
+      setUrlPath(router.asPath)
+    }
+  }, [product, router])
+
+
   useEffect(() => {
     const getIP = async () => {
       const ip = await odooApi('GET', '/api/ip-address')
-- 
cgit v1.2.3

