From 4d021a4634a6bc84ee25f0d43cbc6450d94265f0 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Mon, 31 Jul 2023 14:08:34 +0700
Subject: google sing up

---
 src/lib/auth/components/LoginDesktop.jsx | 11 +++++++++++
 1 file changed, 11 insertions(+)

(limited to 'src/lib/auth/components/LoginDesktop.jsx')

diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx
index 8ce2e4e3..74d259a8 100644
--- a/src/lib/auth/components/LoginDesktop.jsx
+++ b/src/lib/auth/components/LoginDesktop.jsx
@@ -3,11 +3,15 @@ import useLogin from '../hooks/useLogin'
 import Link from '@/core/components/elements/Link/Link'
 import PageContent from '@/lib/content/components/PageContent'
 import Alert from '@/core/components/elements/Alert/Alert'
+import {useSession, signIn, SignOut} from 'next-auth/react'
 
 const LoginDesktop = () => {
   const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } =
     useLogin()
 
+  const {data : session } = useSession
+  console.log('ini google', session)
+
   return (
     <DesktopView>
       <div className='container mx-auto'>
@@ -60,6 +64,13 @@ const LoginDesktop = () => {
                 {!isLoading ? 'Masuk' : 'Loading...'}
               </button>
             </form>
+            <button
+                type='submit'
+                className='btn-red w-full mt-2'
+                onClick={() => signIn()}
+              >
+                Masuk dengan google
+              </button>
 
             <div className='text-gray_r-11 mt-10'>
               Belum punya akun Indoteknik?{' '}
-- 
cgit v1.2.3


From 4cfe9157d64a76bf9913fe599d908497a18f5316 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Wed, 9 Aug 2023 10:45:53 +0700
Subject: google sign in

---
 src/lib/auth/components/LoginDesktop.jsx | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'src/lib/auth/components/LoginDesktop.jsx')

diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx
index 74d259a8..f5aa0018 100644
--- a/src/lib/auth/components/LoginDesktop.jsx
+++ b/src/lib/auth/components/LoginDesktop.jsx
@@ -9,8 +9,8 @@ const LoginDesktop = () => {
   const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } =
     useLogin()
 
-  const {data : session } = useSession
-  console.log('ini google', session)
+  const { data } = useSession()
+  console.log('ini google', data)
 
   return (
     <DesktopView>
@@ -66,10 +66,10 @@ const LoginDesktop = () => {
             </form>
             <button
                 type='submit'
-                className='btn-red w-full mt-2'
-                onClick={() => signIn()}
+                className='border border-gray-500 p-3 rounded-md hover:bg-gray-100  w-full mt-2'
+                onClick={() => signIn('google')}
               >
-                Masuk dengan google
+                Masuk dengan Google
               </button>
 
             <div className='text-gray_r-11 mt-10'>
-- 
cgit v1.2.3


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/lib/auth/components/LoginDesktop.jsx | 66 +++++++++++++++++++++++++++-----
 1 file changed, 57 insertions(+), 9 deletions(-)

(limited to 'src/lib/auth/components/LoginDesktop.jsx')

diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx
index f5aa0018..e3bff492 100644
--- a/src/lib/auth/components/LoginDesktop.jsx
+++ b/src/lib/auth/components/LoginDesktop.jsx
@@ -3,15 +3,50 @@ import useLogin from '../hooks/useLogin'
 import Link from '@/core/components/elements/Link/Link'
 import PageContent from '@/lib/content/components/PageContent'
 import Alert from '@/core/components/elements/Alert/Alert'
-import {useSession, signIn, SignOut} from 'next-auth/react'
+import { useSession, signIn, SignOut } from 'next-auth/react'
+import Image from 'next/image'
+import { useRouter } from 'next/router'
+import { useEffect, useState } from 'react'
+import Spinner from '@/core/components/elements/Spinner/Spinner'
 
 const LoginDesktop = () => {
   const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } =
     useLogin()
 
-  const { data } = useSession()
-  console.log('ini google', data)
+  const router = useRouter()
+  const [query, setQuery] = useState(router?.query?.next || '/')
+  const { data: session } = useSession()
+  const [googleLoading, setGoogleloading] = useState(true)
 
+  useEffect(() => {
+    // Simulate loading for 2 seconds
+    const delay = setTimeout(() => {
+      setGoogleloading(false);
+    }, 3000);
+
+    return () => {
+      clearTimeout(delay); // Clear the timeout if the component unmounts
+    };
+  }, []);
+
+
+  const handleGoogle = async () => {
+    await signIn('google', { callbackUrl: '/login' })
+  }
+
+  useEffect(() => {
+    if (session) {
+      router.push(query)
+    }
+  }, [session, query])
+
+  if (googleLoading) {
+    return (
+      <div className='flex justify-center my-6'>
+        <Spinner className='w-6 text-gray_r-12/50 fill-gray_r-12' />
+      </div>
+    )
+  }
   return (
     <DesktopView>
       <div className='container mx-auto'>
@@ -64,13 +99,26 @@ const LoginDesktop = () => {
                 {!isLoading ? 'Masuk' : 'Loading...'}
               </button>
             </form>
+            <div className='flex  items-center mt-3 mb-3'>
+              <hr className='flex-1' />
+              <p className='text-gray-400'>ATAU</p>
+              <hr className='flex-1' />
+            </div>
+
             <button
-                type='submit'
-                className='border border-gray-500 p-3 rounded-md hover:bg-gray-100  w-full mt-2'
-                onClick={() => signIn('google')}
-              >
-                Masuk dengan Google
-              </button>
+              type='submit'
+              className='border border-gray-500 p-2 rounded-md hover:bg-gray-100  w-full mt-2 flex items-center justify-center gap-x-2'
+              onClick={() => handleGoogle()}
+            >
+              <Image
+                src='/images/icons8-google.svg'
+                alt='google image'
+                className='h-7 w-7'
+                width={10}
+                height={10}
+              />
+              <p>Masuk dengan Google</p>
+            </button>
 
             <div className='text-gray_r-11 mt-10'>
               Belum punya akun Indoteknik?{' '}
-- 
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/lib/auth/components/LoginDesktop.jsx | 35 +++++++++-----------------------
 1 file changed, 10 insertions(+), 25 deletions(-)

(limited to 'src/lib/auth/components/LoginDesktop.jsx')

diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx
index e3bff492..06c90d45 100644
--- a/src/lib/auth/components/LoginDesktop.jsx
+++ b/src/lib/auth/components/LoginDesktop.jsx
@@ -6,8 +6,10 @@ import Alert from '@/core/components/elements/Alert/Alert'
 import { useSession, signIn, SignOut } from 'next-auth/react'
 import Image from 'next/image'
 import { useRouter } from 'next/router'
-import { useEffect, useState } from 'react'
+import { useContext, useEffect, useState } from 'react'
 import Spinner from '@/core/components/elements/Spinner/Spinner'
+import { AuthContext } from '@/pages/_app'
+import { getAuth, setAuth } from '@/core/utils/auth'
 
 const LoginDesktop = () => {
   const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } =
@@ -16,37 +18,20 @@ const LoginDesktop = () => {
   const router = useRouter()
   const [query, setQuery] = useState(router?.query?.next || '/')
   const { data: session } = useSession()
-  const [googleLoading, setGoogleloading] = useState(true)
-
-  useEffect(() => {
-    // Simulate loading for 2 seconds
-    const delay = setTimeout(() => {
-      setGoogleloading(false);
-    }, 3000);
-
-    return () => {
-      clearTimeout(delay); // Clear the timeout if the component unmounts
-    };
-  }, []);
-
+  const auth = getAuth()
+  const { setAuthenticated } = useContext(AuthContext)
 
   const handleGoogle = async () => {
-    await signIn('google', { callbackUrl: '/login' })
+    const url = query != '/' ? '/login?next=' + query : '/login'
+    await signIn('google', { callbackUrl: url })
   }
 
   useEffect(() => {
-    if (session) {
-      router.push(query)
+    if (session || auth) {
+      setAuthenticated(session ? session.odooUser : auth)
     }
-  }, [session, query])
+  }, [session])
 
-  if (googleLoading) {
-    return (
-      <div className='flex justify-center my-6'>
-        <Spinner className='w-6 text-gray_r-12/50 fill-gray_r-12' />
-      </div>
-    )
-  }
   return (
     <DesktopView>
       <div className='container mx-auto'>
-- 
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/lib/auth/components/LoginDesktop.jsx | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

(limited to 'src/lib/auth/components/LoginDesktop.jsx')

diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx
index 06c90d45..3a7477b9 100644
--- a/src/lib/auth/components/LoginDesktop.jsx
+++ b/src/lib/auth/components/LoginDesktop.jsx
@@ -7,9 +7,8 @@ import { useSession, signIn, SignOut } from 'next-auth/react'
 import Image from 'next/image'
 import { useRouter } from 'next/router'
 import { useContext, useEffect, useState } from 'react'
-import Spinner from '@/core/components/elements/Spinner/Spinner'
-import { AuthContext } from '@/pages/_app'
 import { getAuth, setAuth } from '@/core/utils/auth'
+import { setCookie } from 'cookies-next'
 
 const LoginDesktop = () => {
   const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } =
@@ -19,7 +18,6 @@ const LoginDesktop = () => {
   const [query, setQuery] = useState(router?.query?.next || '/')
   const { data: session } = useSession()
   const auth = getAuth()
-  const { setAuthenticated } = useContext(AuthContext)
 
   const handleGoogle = async () => {
     const url = query != '/' ? '/login?next=' + query : '/login'
@@ -27,10 +25,11 @@ const LoginDesktop = () => {
   }
 
   useEffect(() => {
-    if (session || auth) {
-      setAuthenticated(session ? session.odooUser : auth)
+    if(session){
+      setCookie('auth', JSON.stringify(session?.odooUser))
+      router.push(query)
     }
-  }, [session])
+  },[session])
 
   return (
     <DesktopView>
-- 
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/lib/auth/components/LoginDesktop.jsx | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

(limited to 'src/lib/auth/components/LoginDesktop.jsx')

diff --git a/src/lib/auth/components/LoginDesktop.jsx b/src/lib/auth/components/LoginDesktop.jsx
index 3a7477b9..42fa8896 100644
--- a/src/lib/auth/components/LoginDesktop.jsx
+++ b/src/lib/auth/components/LoginDesktop.jsx
@@ -9,27 +9,39 @@ import { useRouter } from 'next/router'
 import { useContext, useEffect, useState } from 'react'
 import { getAuth, setAuth } from '@/core/utils/auth'
 import { setCookie } from 'cookies-next'
+import BottomPopup from '@/core/components/elements/Popup/BottomPopup'
+import Spinner from '@/core/components/elements/Spinner/Spinner'
+import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner'
+import odooApi from '@/core/api/odooApi'
 
 const LoginDesktop = () => {
-  const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef } =
+  const { handleSubmit, handleChangeInput, isLoading, isValid, alert, emailRef, passwordRef, handleGoogleSubmit } =
     useLogin()
 
   const router = useRouter()
   const [query, setQuery] = useState(router?.query?.next || '/')
   const { data: session } = useSession()
-  const auth = getAuth()
 
   const handleGoogle = async () => {
-    const url = query != '/' ? '/login?next=' + query : '/login'
+    const url = query != '/' ? '/login?source=google&next=' + query : '/login?source=google'
     await signIn('google', { callbackUrl: url })
   }
-
   useEffect(() => {
-    if(session){
-      setCookie('auth', JSON.stringify(session?.odooUser))
-      router.push(query)
+    if (session) {
+      handleGoogleSubmit(session)
     }
-  },[session])
+  }, [session])
+
+  if (router.query.source) {
+    return (
+      <BottomPopup active={true} close=''>
+        <div className='leading-7 text-gray_r-12/80 flex justify-center'>Mohon Tunggu</div>
+        <div className='container flex justify-center my-4'>
+          <LogoSpinner width={48} height={48} />
+        </div>
+      </BottomPopup>
+    )
+  }
 
   return (
     <DesktopView>
-- 
cgit v1.2.3

