From e4b4f2c09ebd819acc204c2e58288fe9fc6294ea Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Thu, 15 Jun 2023 15:45:43 +0700
Subject: get dan delete cart

---
 src/lib/cart/components/Cart.jsx | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

(limited to 'src/lib/cart/components/Cart.jsx')

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)
-- 
cgit v1.2.3

