From 898bff71f6e3f158b9cb73431306de00384b2e9d Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 26 Jul 2023 14:10:26 +0700 Subject: update cart mobile web --- src/lib/product/components/Product/ProductMobile.jsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/product/components/Product/ProductMobile.jsx b/src/lib/product/components/Product/ProductMobile.jsx index 91de173a..2edd1a5f 100644 --- a/src/lib/product/components/Product/ProductMobile.jsx +++ b/src/lib/product/components/Product/ProductMobile.jsx @@ -137,7 +137,15 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => { const handleClickBuy = () => { if (!validAction()) return - router.push(`/shop/checkout?productId=${activeVariant.id}&quantity=${quantity}`) + + updateItemCart({ + productId: activeVariant.id, + quantity, + programLineId: promotionActiveId, + selected: true, + source : 'buy' + }) + router.push(`/shop/checkout?source=buy`) } const productSimilarQuery = [ -- cgit v1.2.3 From 02fbca0f66aac32e562364ddfda9c5bae4177e96 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 26 Jul 2023 14:31:59 +0700 Subject: fix error quotation --- src/lib/quotation/components/Quotation.jsx | 41 +++++++++++++++++++----------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'src/lib') diff --git a/src/lib/quotation/components/Quotation.jsx b/src/lib/quotation/components/Quotation.jsx index 9ffc2fbb..c2a36001 100644 --- a/src/lib/quotation/components/Quotation.jsx +++ b/src/lib/quotation/components/Quotation.jsx @@ -9,17 +9,23 @@ import _ from 'lodash' import { deleteItemCart, getCart, getItemCart } from '@/core/utils/cart' import currencyFormat from '@/core/utils/currencyFormat' import { toast } from 'react-hot-toast' -import checkoutApi from '@/lib/checkout/api/checkoutApi' +// import checkoutApi from '@/lib/checkout/api/checkoutApi' import { useRouter } from 'next/router' import VariantGroupCard from '@/lib/variant/components/VariantGroupCard' import MobileView from '@/core/components/views/MobileView' import DesktopView from '@/core/components/views/DesktopView' import Image from '@/core/components/elements/Image/Image' +import { useQuery } from 'react-query' + +const { checkoutApi } = require('@/lib/checkout/api/checkoutApi') +const { getProductsCheckout } = require('@/lib/checkout/api/checkoutApi') const Quotation = () => { const router = useRouter() const auth = useAuth() + const { data: cartCheckout } = useQuery('cartCheckout', () => getProductsCheckout()) + const [products, setProducts] = useState(null) const [totalAmount, setTotalAmount] = useState(0) const [totalDiscountAmount, setTotalDiscountAmount] = useState(0) @@ -43,9 +49,13 @@ const Quotation = () => { }) } } - loadProducts() + // loadProducts() }, []) + useEffect(() => { + setProducts(cartCheckout?.products) + }, [cartCheckout]) + useEffect(() => { if (products) { let calculateTotalAmount = 0 @@ -118,26 +128,26 @@ const Quotation = () => {
Total Belanja
-
{currencyFormat(totalAmount)}
+
{currencyFormat(cartCheckout?.totalPurchase)}
-
Total Diskon
-
- {currencyFormat(totalDiscountAmount)}
+
Diskon Produk
+
- {currencyFormat(cartCheckout?.totalDiscount)}
Subtotal
-
{currencyFormat(totalAmount - totalDiscountAmount)}
+
{currencyFormat(cartCheckout?.subtotal)}
PPN 11%
-
{currencyFormat(taxTotal)}
+
{currencyFormat(cartCheckout?.tax)}

Grand Total
- {currencyFormat(totalAmount - totalDiscountAmount + taxTotal)} + {currencyFormat(cartCheckout?.grandTotal)}

*) Belum termasuk biaya pengiriman

@@ -237,23 +247,24 @@ const Quotation = () => {
-
Total Belanja
-
{currencyFormat(totalAmount)}
+
{currencyFormat(cartCheckout?.totalPurchase)}
-
Total Diskon
-
- {currencyFormat(totalDiscountAmount)}
+
Diskon Produk
+
+ - {currencyFormat(cartCheckout?.totalDiscount)} +
Subtotal
-
{currencyFormat(totalAmount - totalDiscountAmount)}
+
{currencyFormat(cartCheckout?.subtotal)}
PPN 11%
-
{currencyFormat(taxTotal)}
+
{currencyFormat(cartCheckout?.tax)}
@@ -262,7 +273,7 @@ const Quotation = () => {
Grand Total
- {currencyFormat(totalAmount - totalDiscountAmount + taxTotal)} + {currencyFormat(cartCheckout?.grandTotal)}

-- cgit v1.2.3