From f62b2345f463695ef0f8f79830cd76b6e0332821 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Sat, 13 Jan 2024 10:35:22 +0700
Subject: Refactor src migrate folder

---
 src/core/components/layouts/BasicLayout.jsx | 82 ++++++++++++++++-------------
 1 file changed, 44 insertions(+), 38 deletions(-)

(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 9441dbd7..2962a08b 100644
--- a/src/core/components/layouts/BasicLayout.jsx
+++ b/src/core/components/layouts/BasicLayout.jsx
@@ -1,55 +1,61 @@
-import dynamic from 'next/dynamic'
-import BasicFooter from '../elements/Footer/BasicFooter'
-import Image from 'next/image'
-import whatsappUrl from '@/core/utils/whatsappUrl'
-import { useEffect, useState } from 'react'
-import axios from 'axios'
-import odooApi from '@/core/api/odooApi'
-import { useRouter } from 'next/router'
-import productApi from '@/lib/product/api/productApi'
-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'
+import dynamic from 'next/dynamic';
+import Image from 'next/image';
+import { useEffect, useState } from 'react';
+import axios from 'axios';
 
-const Navbar = dynamic(() => import('../elements/Navbar/Navbar'))
-const AnimationLayout = dynamic(() => import('./AnimationLayout'))
+import whatsappUrl from '@/core/utils/whatsappUrl';
+import odooApi from '@/core/api/odooApi';
+import { useRouter } from 'next/router';
+import { useProductContext } from '@/contexts/ProductContext';
+
+const Navbar = dynamic(() => import('../elements/Navbar/Navbar'), {
+  ssr: false,
+});
+const AnimationLayout = dynamic(() => import('./AnimationLayout'), {
+  ssr: false,
+});
+const BasicFooter = dynamic(() => import('../elements/Footer/BasicFooter'), {
+  ssr: false,
+});
 
 const BasicLayout = ({ children }) => {
-  const [templateWA, setTemplateWA] = useState(null)
-  const [payloadWA, setPayloadWa] = useState(null)
-  const [urlPath, setUrlPath] = useState(null)
+  const [templateWA, setTemplateWA] = useState(null);
+  const [payloadWA, setPayloadWa] = useState(null);
+  const [urlPath, setUrlPath] = useState(null);
 
-  const router = useRouter()
+  const router = useRouter();
 
-  const { product } = useProductContext()
+  const { product } = useProductContext();
   useEffect(() => {
-    if (router.pathname === '/shop/product/[slug]' || router.pathname === '/shop/product/variant/[slug]') {
+    if (
+      router.pathname === '/shop/product/[slug]' ||
+      router.pathname === '/shop/product/variant/[slug]'
+    ) {
       setPayloadWa({
         name: product?.name,
         manufacture: product?.manufacture.name,
-        url: process.env.NEXT_PUBLIC_SELF_HOST + router.asPath
-      })
-      setTemplateWA('product')
+        url: process.env.NEXT_PUBLIC_SELF_HOST + router.asPath,
+      });
+      setTemplateWA('product');
 
-      setUrlPath(router.asPath)
+      setUrlPath(router.asPath);
     }
-  }, [product, router])
-
+  }, [product, router]);
 
   useEffect(() => {
     const getIP = async () => {
-      const ip = await odooApi('GET', '/api/ip-address')
+      const ip = await odooApi('GET', '/api/ip-address');
       const data = {
         page_title: document.title,
         url: window.location.href,
-        ip: ip
-      }
-      axios.get(`/api/user-activity?page_title=${data.page_title}&url=${data.url}&ip=${data.ip}`)
-    }
-    getIP()
-  }, [])
+        ip: ip,
+      };
+      axios.get(
+        `/api/user-activity?page_title=${data.page_title}&url=${data.url}&ip=${data.ip}`
+      );
+    };
+    getIP();
+  }, []);
   return (
     <>
       <Navbar />
@@ -82,7 +88,7 @@ const BasicLayout = ({ children }) => {
       </AnimationLayout>
       <BasicFooter />
     </>
-  )
-}
+  );
+};
 
-export default BasicLayout
+export default BasicLayout;
-- 
cgit v1.2.3

