diff options
| author | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-06-15 15:45:43 +0700 |
|---|---|---|
| committer | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-06-15 15:45:43 +0700 |
| commit | e4b4f2c09ebd819acc204c2e58288fe9fc6294ea (patch) | |
| tree | a22399091ca0e4f35948ddcb58b2321d26c4c4c2 /src/lib/cart/components/Cart.jsx | |
| parent | eb4ae7be05ed97bd02b7f3e9cc56393f435188e2 (diff) | |
get dan delete cart
Diffstat (limited to 'src/lib/cart/components/Cart.jsx')
| -rw-r--r-- | src/lib/cart/components/Cart.jsx | 15 |
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) |
