summaryrefslogtreecommitdiff
path: root/src/lib/cart/components/Cart.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/cart/components/Cart.jsx')
-rw-r--r--src/lib/cart/components/Cart.jsx15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx
index 718541af..561a0064 100644
--- a/src/lib/cart/components/Cart.jsx
+++ b/src/lib/cart/components/Cart.jsx
@@ -4,7 +4,7 @@ import Image from '@/core/components/elements/Image/Image'
import NextImage from 'next/image'
import currencyFormat from '@/core/utils/currencyFormat'
import { useEffect, useState } from 'react'
-import { deleteItemCart, getItemCart, updateItemCart } from '@/core/utils/cart'
+import { deleteItemCart, getCart, getCartnew, getItemCart, updateItemCart } from '@/core/utils/cart'
import { CheckIcon, TrashIcon } from '@heroicons/react/24/outline'
import { createSlug } from '@/core/utils/slug'
import { useRouter } from 'next/router'
@@ -19,14 +19,27 @@ import productSearchApi from '@/lib/product/api/productSearchApi'
import whatsappUrl from '@/core/utils/whatsappUrl'
import useAuth from '@/core/hooks/useAuth'
+
+const { useQuery } = require('react-query')
+const { getCartApi } = require('../api/CartApi')
+
const Cart = () => {
const router = useRouter()
const [products, setProducts] = useState(null)
const auth = useAuth()
+ const { data: listCart } = useQuery('listCart', getCartApi)
useEffect(() => {
if (!auth) return
}, [auth])
+
+ useEffect(() => {
+ if(listCart){
+ setProducts(listCart.products)
+ }
+ }, [listCart])
+
+ console.log('product', products)
const { cart } = useCart({ enabled: !products })
const [totalPriceBeforeTax, setTotalPriceBeforeTax] = useState(0)