From 01e86fb4a54b801a9b8124455611c312e5de4af0 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" 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 ( - <> - - - {children} -
- - Whatsapp - Whatsapp - Whatsapp - -
-
- - - ) + if(isLoading){ + + }else{ + return ( + <> + + + {children} + + + + + ) + } + } export default BasicLayout -- cgit v1.2.3