From f90ec98c509fad7146c169d8d762b4c847d07af8 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 15 Sep 2023 09:15:54 +0700 Subject: Add product context provider --- src/contexts/ProductContext.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/contexts/ProductContext.js (limited to 'src/contexts') 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 ( + {children} + ) +} + +export const useProductContext = () => { + return useContext(ProductContext) +} -- cgit v1.2.3 From 4f285349adec93a040e41d1d8c0c1c7b57749397 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 21 Sep 2023 14:56:35 +0700 Subject: add context for list product popup cart --- src/contexts/ProductCartContext.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/contexts/ProductCartContext.js (limited to 'src/contexts') 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 ( + + {children} + + ) +} + +export const useProductCartContext = () => { + return useContext(ProductCartContext) +} -- cgit v1.2.3