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/RegisterMobile.jsx | 39 ++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

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

diff --git a/src/lib/auth/components/RegisterMobile.jsx b/src/lib/auth/components/RegisterMobile.jsx
index da6efaf5..c21c9325 100644
--- a/src/lib/auth/components/RegisterMobile.jsx
+++ b/src/lib/auth/components/RegisterMobile.jsx
@@ -7,6 +7,10 @@ import MobileView from '@/core/components/views/MobileView'
 import BottomPopup from '@/core/components/elements/Popup/BottomPopup'
 import PageContent from '@/lib/content/components/PageContent'
 import ReCAPTCHA from 'react-google-recaptcha'
+import { signIn, useSession } from 'next-auth/react'
+import { useRouter } from 'next/router'
+import { setCookie } from 'cookies-next'
+import { useEffect } from 'react'
 
 const RegisterMobile = () => {
   const {
@@ -24,6 +28,20 @@ const RegisterMobile = () => {
     setTnd
   } = useRegister()
 
+  const { data: session } = useSession()
+  const router = useRouter()
+  
+  const handleGoogle = async () => {
+    await signIn('google', { callbackUrl: '/register' })
+  }
+
+  useEffect(() => {
+    if(session){
+      setCookie('auth', JSON.stringify(session?.odooUser))
+      router.push('/')
+    }
+  },[session])
+
   return (
     <MobileView>
       <div className='p-6 pt-10 flex flex-col items-center min-h-screen'>
@@ -122,6 +140,27 @@ const RegisterMobile = () => {
           </BottomPopup>
         </div>
 
+        <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-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>Daftar dengan Google</p>
+        </button>
+
         <div className='text-gray_r-11 mt-4'>
           Sudah punya akun Indoteknik?{' '}
           <Link href='/login' className='inline'>
-- 
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/RegisterMobile.jsx | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

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

diff --git a/src/lib/auth/components/RegisterMobile.jsx b/src/lib/auth/components/RegisterMobile.jsx
index c21c9325..2e918a14 100644
--- a/src/lib/auth/components/RegisterMobile.jsx
+++ b/src/lib/auth/components/RegisterMobile.jsx
@@ -11,6 +11,7 @@ import { signIn, useSession } from 'next-auth/react'
 import { useRouter } from 'next/router'
 import { setCookie } from 'cookies-next'
 import { useEffect } from 'react'
+import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner'
 
 const RegisterMobile = () => {
   const {
@@ -32,7 +33,7 @@ const RegisterMobile = () => {
   const router = useRouter()
   
   const handleGoogle = async () => {
-    await signIn('google', { callbackUrl: '/register' })
+    await signIn('google', { callbackUrl: '/register?source=google' })
   }
 
   useEffect(() => {
@@ -42,6 +43,16 @@ const RegisterMobile = () => {
     }
   },[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 (
     <MobileView>
       <div className='p-6 pt-10 flex flex-col items-center min-h-screen'>
-- 
cgit v1.2.3


From 6b1083de2c5ad57953c6653d00a42b2da3fea108 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Fri, 1 Sep 2023 17:09:16 +0700
Subject: hide google sign up button

---
 src/lib/auth/components/RegisterMobile.jsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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

diff --git a/src/lib/auth/components/RegisterMobile.jsx b/src/lib/auth/components/RegisterMobile.jsx
index 2e918a14..1b0d2adf 100644
--- a/src/lib/auth/components/RegisterMobile.jsx
+++ b/src/lib/auth/components/RegisterMobile.jsx
@@ -151,7 +151,7 @@ const RegisterMobile = () => {
           </BottomPopup>
         </div>
 
-        <div className='flex  items-center mt-3 mb-3'>
+        {/* <div className='flex  items-center mt-3 mb-3'>
           <hr className='flex-1' />
           <p className='text-gray-400'>ATAU</p>
           <hr className='flex-1' />
@@ -170,7 +170,7 @@ const RegisterMobile = () => {
             height={10}
           />
           <p>Daftar dengan Google</p>
-        </button>
+        </button> */}
 
         <div className='text-gray_r-11 mt-4'>
           Sudah punya akun Indoteknik?{' '}
-- 
cgit v1.2.3

