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/pages/_app.jsx | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

(limited to 'src/pages/_app.jsx')

diff --git a/src/pages/_app.jsx b/src/pages/_app.jsx
index 4c4fed89..cda9e970 100644
--- a/src/pages/_app.jsx
+++ b/src/pages/_app.jsx
@@ -7,12 +7,14 @@ import { QueryClient, QueryClientProvider } from 'react-query'
 import useDevice from '@/core/hooks/useDevice'
 import { useEffect, useState } from 'react'
 import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner'
+import { SessionProvider } from 'next-auth/react'
 
 const queryClient = new QueryClient()
 
-function MyApp({ Component, pageProps }) {
+function MyApp({ Component, pageProps :{session, ...pageProps} }) {
   const router = useRouter()
   const { isMobile } = useDevice()
+  console.log('ini session', session)
 
   const [animateLoader, setAnimateLoader] = useState(false)
 
@@ -47,7 +49,7 @@ function MyApp({ Component, pageProps }) {
   }, [isMobile])
 
   return (
-    <>
+    <SessionProvider session={session}>
       <AnimatePresence>
         {animateLoader && (
           <motion.div
@@ -81,7 +83,7 @@ function MyApp({ Component, pageProps }) {
           {!animateLoader && <Component {...pageProps} key={router.asPath} />}
         </AnimatePresence>
       </QueryClientProvider>
-    </>
+    </SessionProvider>
   )
 }
 
-- 
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/pages/_app.jsx | 87 +++++++++++++++++++++++++++++++-----------------------
 1 file changed, 50 insertions(+), 37 deletions(-)

(limited to 'src/pages/_app.jsx')

diff --git a/src/pages/_app.jsx b/src/pages/_app.jsx
index cda9e970..9f30752a 100644
--- a/src/pages/_app.jsx
+++ b/src/pages/_app.jsx
@@ -5,18 +5,29 @@ import { AnimatePresence, motion } from 'framer-motion'
 import { Toaster } from 'react-hot-toast'
 import { QueryClient, QueryClientProvider } from 'react-query'
 import useDevice from '@/core/hooks/useDevice'
-import { useEffect, useState } from 'react'
+import { createContext, useContext, useEffect, useState } from 'react'
 import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner'
 import { SessionProvider } from 'next-auth/react'
+import { getAuth } from '@/core/utils/auth'
 
 const queryClient = new QueryClient()
 
-function MyApp({ Component, pageProps :{session, ...pageProps} }) {
+export const AuthContext = createContext({
+  authenticated : false,
+  setAuthenticated : (auth) => {}
+})
+
+function MyApp({ Component, pageProps: { session, ...pageProps } }) {
   const router = useRouter()
   const { isMobile } = useDevice()
-  console.log('ini session', session)
 
   const [animateLoader, setAnimateLoader] = useState(false)
+  const [authenticated, setAuthenticated] = useState(null)
+  const auth = getAuth()
+
+  useEffect(() => {
+    setAuthenticated(auth)
+  }, [auth])
 
   useEffect(() => {
     const handleRouteChangeStart = () => setAnimateLoader(true)
@@ -49,41 +60,43 @@ function MyApp({ Component, pageProps :{session, ...pageProps} }) {
   }, [isMobile])
 
   return (
-    <SessionProvider session={session}>
-      <AnimatePresence>
-        {animateLoader && (
-          <motion.div
-            initial={{ opacity: 0 }}
-            animate={{ opacity: 1 }}
-            exit={{ opacity: 0 }}
-            transition={{
-              duration: 0.1
-            }}
-            className='fixed w-screen h-screen z-[500] bg-white flex justify-center items-center'
-          >
-            <LogoSpinner />
-          </motion.div>
-        )}
-      </AnimatePresence>
-      <Toaster
-        position='top-center'
-        containerStyle={toasterStyle}
-        toastOptions={{
-          duration: 3000,
-          className: 'border border-gray_r-8'
-        }}
-      />
-      <NextProgress color='#F01C21' options={{ showSpinner: false }} />
-      <QueryClientProvider client={queryClient}>
-        <AnimatePresence
-          mode='popLayout'
-          initial={false}
-          onExitComplete={() => window.scrollTo(0, 0)}
-        >
-          {!animateLoader && <Component {...pageProps} key={router.asPath} />}
+    <AuthContext.Provider value={{authenticated, setAuthenticated}}>
+      <SessionProvider session={session}>
+        <AnimatePresence>
+          {animateLoader && (
+            <motion.div
+              initial={{ opacity: 0 }}
+              animate={{ opacity: 1 }}
+              exit={{ opacity: 0 }}
+              transition={{
+                duration: 0.1
+              }}
+              className='fixed w-screen h-screen z-[500] bg-white flex justify-center items-center'
+            >
+              <LogoSpinner />
+            </motion.div>
+          )}
         </AnimatePresence>
-      </QueryClientProvider>
-    </SessionProvider>
+        <Toaster
+          position='top-center'
+          containerStyle={toasterStyle}
+          toastOptions={{
+            duration: 3000,
+            className: 'border border-gray_r-8'
+          }}
+        />
+        <NextProgress color='#F01C21' options={{ showSpinner: false }} />
+        <QueryClientProvider client={queryClient}>
+          <AnimatePresence
+            mode='popLayout'
+            initial={false}
+            onExitComplete={() => window.scrollTo(0, 0)}
+          >
+            {!animateLoader && <Component {...pageProps} key={router.asPath} />}
+          </AnimatePresence>
+        </QueryClientProvider>
+      </SessionProvider>
+    </AuthContext.Provider>
   )
 }
 
-- 
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/pages/_app.jsx | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'src/pages/_app.jsx')

diff --git a/src/pages/_app.jsx b/src/pages/_app.jsx
index 9f30752a..86cbe963 100644
--- a/src/pages/_app.jsx
+++ b/src/pages/_app.jsx
@@ -25,9 +25,9 @@ function MyApp({ Component, pageProps: { session, ...pageProps } }) {
   const [authenticated, setAuthenticated] = useState(null)
   const auth = getAuth()
 
-  useEffect(() => {
-    setAuthenticated(auth)
-  }, [auth])
+  // useEffect(() => {
+  //   setAuthenticated(auth)
+  // }, [auth])
 
   useEffect(() => {
     const handleRouteChangeStart = () => setAnimateLoader(true)
@@ -60,7 +60,7 @@ function MyApp({ Component, pageProps: { session, ...pageProps } }) {
   }, [isMobile])
 
   return (
-    <AuthContext.Provider value={{authenticated, setAuthenticated}}>
+    // <AuthContext.Provider value={{authenticated, setAuthenticated}}>
       <SessionProvider session={session}>
         <AnimatePresence>
           {animateLoader && (
@@ -96,7 +96,7 @@ function MyApp({ Component, pageProps: { session, ...pageProps } }) {
           </AnimatePresence>
         </QueryClientProvider>
       </SessionProvider>
-    </AuthContext.Provider>
+    // </AuthContext.Provider>
   )
 }
 
-- 
cgit v1.2.3

