summaryrefslogtreecommitdiff
path: root/src/contexts
diff options
context:
space:
mode:
Diffstat (limited to 'src/contexts')
-rw-r--r--src/contexts/ProductCartContext.js21
-rw-r--r--src/contexts/ProductContext.js15
2 files changed, 36 insertions, 0 deletions
diff --git a/src/contexts/ProductCartContext.js b/src/contexts/ProductCartContext.js
new file mode 100644
index 00000000..06e97563
--- /dev/null
+++ b/src/contexts/ProductCartContext.js
@@ -0,0 +1,21 @@
+import { createContext, useCallback, useContext, useEffect, useState } from 'react'
+
+const ProductCartContext = createContext()
+
+export const ProductCartProvider = ({ children }) => {
+ const [productCart, setProductCart] = useState(null)
+ const [refreshCart, setRefreshCart] = useState(false)
+ const [isLoading, setIsloading] = useState(false)
+
+ return (
+ <ProductCartContext.Provider
+ value={{ productCart, setProductCart, refreshCart, setRefreshCart, isLoading, setIsloading }}
+ >
+ {children}
+ </ProductCartContext.Provider>
+ )
+}
+
+export const useProductCartContext = () => {
+ return useContext(ProductCartContext)
+}
diff --git a/src/contexts/ProductContext.js b/src/contexts/ProductContext.js
new file mode 100644
index 00000000..7bf65989
--- /dev/null
+++ b/src/contexts/ProductContext.js
@@ -0,0 +1,15 @@
+import { createContext, useContext, useState } from 'react'
+
+const ProductContext = createContext()
+
+export const ProductProvider = ({ children }) => {
+ const [product, setProduct] = useState(null)
+
+ return (
+ <ProductContext.Provider value={{ product, setProduct }}>{children}</ProductContext.Provider>
+ )
+}
+
+export const useProductContext = () => {
+ return useContext(ProductContext)
+}