From 01e86fb4a54b801a9b8124455611c312e5de4af0 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Mon, 14 Aug 2023 15:04:45 +0700
Subject: google sign in

---
 src/core/components/layouts/BasicLayout.jsx | 93 ++++++++++++++++++-----------
 1 file changed, 57 insertions(+), 36 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 073303fe..e8f6434b 100644
--- a/src/core/components/layouts/BasicLayout.jsx
+++ b/src/core/components/layouts/BasicLayout.jsx
@@ -6,10 +6,11 @@ import { useEffect, useState } from 'react'
 import axios from 'axios'
 import odooApi from '@/core/api/odooApi'
 import { useRouter } from 'next/router'
-import { getURL } from 'next/dist/shared/lib/utils'
 import productApi from '@/lib/product/api/productApi'
-import { getAuth } from '@/core/utils/auth'
+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'
 
 const Navbar = dynamic(() => import('../elements/Navbar/Navbar'))
 const AnimationLayout = dynamic(() => import('./AnimationLayout'))
@@ -17,10 +18,26 @@ const AnimationLayout = dynamic(() => import('./AnimationLayout'))
 const BasicLayout = ({ children }) => {
   const [templateWA, setTemplateWA] = useState(null)
   const [payloadWA, setPayloadWa] = useState(null)
+  const [isLoading, setIsloading] = useState(false)
 
   const router = useRouter()
+  const { data: session } = useSession()
+  const auth = getAuth()
+  const setting = async () => {
+    if (!auth && session) {
+      setCookie('auth', JSON.stringify(session?.odooUser))
+      setIsloading(false)
+    }
+  }
+
+  useEffect(() => {
+    setting()
+  }, [session])
 
   useEffect(() => {
+    setting()
+    console.log('ini session', session)
+    console.log('ini auth', getAuth())
     const getIP = async () => {
       const ip = await odooApi('GET', '/api/ip-address')
       const data = {
@@ -46,42 +63,46 @@ const BasicLayout = ({ children }) => {
       }
       getProduct()
       setTemplateWA('product')
-     
     }
   }, [])
-  return (
-    <>
-      <Navbar />
-      <AnimationLayout>
-        {children}
-        <div className='fixed bottom-4 right-4 sm:bottom-14 sm:right-10 z-50'>
-          <a
-            href={whatsappUrl(templateWA, payloadWA)}
-            className='py-2 pl-3 pr-4 rounded-full bg-[#4FB84A] border border-green-300 flex items-center'
-            rel='noopener noreferrer'
-            target='_blank'
-          >
-            <Image
-              src='/images/socials/WHATSAPP.svg'
-              alt='Whatsapp'
-              className='block sm:hidden'
-              width={36}
-              height={36}
-            />
-            <Image
-              src='/images/socials/WHATSAPP.svg'
-              alt='Whatsapp'
-              className='hidden sm:block'
-              width={44}
-              height={44}
-            />
-            <span className='text-white font-bold ml-1.5'>Whatsapp</span>
-          </a>
-        </div>
-      </AnimationLayout>
-      <BasicFooter />
-    </>
-  )
+  if(isLoading){
+
+  }else{
+    return (
+      <>
+        <Navbar />
+        <AnimationLayout>
+          {children}
+          <div className='fixed bottom-4 right-4 sm:bottom-14 sm:right-10 z-50'>
+            <a
+              href={whatsappUrl(templateWA, payloadWA)}
+              className='py-2 pl-3 pr-4 rounded-full bg-[#4FB84A] border border-green-300 flex items-center'
+              rel='noopener noreferrer'
+              target='_blank'
+            >
+              <Image
+                src='/images/socials/WHATSAPP.svg'
+                alt='Whatsapp'
+                className='block sm:hidden'
+                width={36}
+                height={36}
+              />
+              <Image
+                src='/images/socials/WHATSAPP.svg'
+                alt='Whatsapp'
+                className='hidden sm:block'
+                width={44}
+                height={44}
+              />
+              <span className='text-white font-bold ml-1.5'>Whatsapp</span>
+            </a>
+          </div>
+        </AnimationLayout>
+        <BasicFooter />
+      </>
+    )
+  }
+  
 }
 
 export default BasicLayout
-- 
cgit v1.2.3


From 9a33f3a391a402807cc5e7913b1a97e430a7aaa2 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Tue, 15 Aug 2023 15:16:38 +0700
Subject: sign in

---
 src/core/components/layouts/BasicLayout.jsx | 87 +++++++++++++----------------
 1 file changed, 38 insertions(+), 49 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 e8f6434b..e5c6908a 100644
--- a/src/core/components/layouts/BasicLayout.jsx
+++ b/src/core/components/layouts/BasicLayout.jsx
@@ -18,26 +18,20 @@ const AnimationLayout = dynamic(() => import('./AnimationLayout'))
 const BasicLayout = ({ children }) => {
   const [templateWA, setTemplateWA] = useState(null)
   const [payloadWA, setPayloadWa] = useState(null)
-  const [isLoading, setIsloading] = useState(false)
 
   const router = useRouter()
   const { data: session } = useSession()
   const auth = getAuth()
   const setting = async () => {
-    if (!auth && session) {
-      setCookie('auth', JSON.stringify(session?.odooUser))
-      setIsloading(false)
-    }
+    setCookie('auth', JSON.stringify(session?.odooUser))
   }
 
   useEffect(() => {
-    setting()
-  }, [session])
-
-  useEffect(() => {
-    setting()
+    // if (!auth && session) {
+    //   setting()
+    // }
+    console.log('ini auth', auth)
     console.log('ini session', session)
-    console.log('ini auth', getAuth())
     const getIP = async () => {
       const ip = await odooApi('GET', '/api/ip-address')
       const data = {
@@ -65,44 +59,39 @@ const BasicLayout = ({ children }) => {
       setTemplateWA('product')
     }
   }, [])
-  if(isLoading){
-
-  }else{
-    return (
-      <>
-        <Navbar />
-        <AnimationLayout>
-          {children}
-          <div className='fixed bottom-4 right-4 sm:bottom-14 sm:right-10 z-50'>
-            <a
-              href={whatsappUrl(templateWA, payloadWA)}
-              className='py-2 pl-3 pr-4 rounded-full bg-[#4FB84A] border border-green-300 flex items-center'
-              rel='noopener noreferrer'
-              target='_blank'
-            >
-              <Image
-                src='/images/socials/WHATSAPP.svg'
-                alt='Whatsapp'
-                className='block sm:hidden'
-                width={36}
-                height={36}
-              />
-              <Image
-                src='/images/socials/WHATSAPP.svg'
-                alt='Whatsapp'
-                className='hidden sm:block'
-                width={44}
-                height={44}
-              />
-              <span className='text-white font-bold ml-1.5'>Whatsapp</span>
-            </a>
-          </div>
-        </AnimationLayout>
-        <BasicFooter />
-      </>
-    )
-  }
-  
+  return (
+    <>
+      <Navbar />
+      <AnimationLayout>
+        {children}
+        <div className='fixed bottom-4 right-4 sm:bottom-14 sm:right-10 z-50'>
+          <a
+            href={whatsappUrl(templateWA, payloadWA)}
+            className='py-2 pl-3 pr-4 rounded-full bg-[#4FB84A] border border-green-300 flex items-center'
+            rel='noopener noreferrer'
+            target='_blank'
+          >
+            <Image
+              src='/images/socials/WHATSAPP.svg'
+              alt='Whatsapp'
+              className='block sm:hidden'
+              width={36}
+              height={36}
+            />
+            <Image
+              src='/images/socials/WHATSAPP.svg'
+              alt='Whatsapp'
+              className='hidden sm:block'
+              width={44}
+              height={44}
+            />
+            <span className='text-white font-bold ml-1.5'>Whatsapp</span>
+          </a>
+        </div>
+      </AnimationLayout>
+      <BasicFooter />
+    </>
+  )
 }
 
 export default BasicLayout
-- 
cgit v1.2.3


From f01f28a7eac76c6da5bf857bfc80fd347586ce7f Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Wed, 16 Aug 2023 09:39:47 +0700
Subject: register google

---
 src/core/components/layouts/BasicLayout.jsx | 6 +++---
 1 file changed, 3 insertions(+), 3 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 e5c6908a..0fea1a3b 100644
--- a/src/core/components/layouts/BasicLayout.jsx
+++ b/src/core/components/layouts/BasicLayout.jsx
@@ -27,9 +27,9 @@ const BasicLayout = ({ children }) => {
   }
 
   useEffect(() => {
-    // if (!auth && session) {
-    //   setting()
-    // }
+    if (!auth && session) {
+      setting()
+    }
     console.log('ini auth', auth)
     console.log('ini session', session)
     const getIP = async () => {
-- 
cgit v1.2.3


From b6f6bf23f90ff0dfadf9bf0af8866c2cfc17aa9c Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Fri, 18 Aug 2023 11:02:39 +0700
Subject: handling redirect login

---
 src/core/components/layouts/BasicLayout.jsx | 10 ----------
 1 file changed, 10 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 0fea1a3b..272440c2 100644
--- a/src/core/components/layouts/BasicLayout.jsx
+++ b/src/core/components/layouts/BasicLayout.jsx
@@ -20,18 +20,8 @@ const BasicLayout = ({ children }) => {
   const [payloadWA, setPayloadWa] = useState(null)
 
   const router = useRouter()
-  const { data: session } = useSession()
-  const auth = getAuth()
-  const setting = async () => {
-    setCookie('auth', JSON.stringify(session?.odooUser))
-  }
 
   useEffect(() => {
-    if (!auth && session) {
-      setting()
-    }
-    console.log('ini auth', auth)
-    console.log('ini session', session)
     const getIP = async () => {
       const ip = await odooApi('GET', '/api/ip-address')
       const data = {
-- 
cgit v1.2.3

