From 4f285349adec93a040e41d1d8c0c1c7b57749397 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Thu, 21 Sep 2023 14:56:35 +0700
Subject: add context for list product popup cart

---
 src/pages/_app.jsx | 77 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 40 insertions(+), 37 deletions(-)

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

diff --git a/src/pages/_app.jsx b/src/pages/_app.jsx
index ef737794..0062f7fc 100644
--- a/src/pages/_app.jsx
+++ b/src/pages/_app.jsx
@@ -11,12 +11,13 @@ import LogoSpinner from '@/core/components/elements/Spinner/LogoSpinner'
 import { SessionProvider } from 'next-auth/react'
 import { getAuth } from '@/core/utils/auth'
 import { ProductProvider } from '@/contexts/ProductContext'
+import { ProductCartProvider } from '@/contexts/ProductCartContext'
 
 const queryClient = new QueryClient()
 
 export const AuthContext = createContext({
-  authenticated : false,
-  setAuthenticated : (auth) => {}
+  authenticated: false,
+  setAuthenticated: (auth) => {}
 })
 
 function MyApp({ Component, pageProps: { session, ...pageProps } }) {
@@ -63,43 +64,45 @@ function MyApp({ Component, pageProps: { session, ...pageProps } }) {
 
   return (
     // <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>
-        <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)}
+    <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'
           >
-            <ProductProvider>
+            <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)}
+        >
+          <ProductProvider>
+            <ProductCartProvider>
               {!animateLoader && <Component {...pageProps} key={router.asPath} />}
-            </ProductProvider>
-          </AnimatePresence>
-        </QueryClientProvider>
-      </SessionProvider>
+            </ProductCartProvider>
+          </ProductProvider>
+        </AnimatePresence>
+      </QueryClientProvider>
+    </SessionProvider>
     // </AuthContext.Provider>
   )
 }
-- 
cgit v1.2.3

