summaryrefslogtreecommitdiff
path: root/src/contexts/ProductCartContext.js
blob: 06e97563b41a7d99f74bd48e61e9a9616f8123c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)
}