From 357e700e32fed599b43dd74ad2cc4d75cc6fc674 Mon Sep 17 00:00:00 2001 From: lytrankieio123 Date: Thu, 21 Oct 2021 09:52:15 +0700 Subject: [PATCH] :recycle: enhan: normalize shippingLine price :%s --- framework/vendure/utils/normalize.ts | 2 +- .../modules/checkout/CheckoutBill/CheckoutBill.tsx | 9 ++++----- .../modules/checkout/CheckoutInfo/CheckoutInfo.tsx | 13 ------------- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/framework/vendure/utils/normalize.ts b/framework/vendure/utils/normalize.ts index e318d7535..7a2ab0d24 100644 --- a/framework/vendure/utils/normalize.ts +++ b/framework/vendure/utils/normalize.ts @@ -95,7 +95,7 @@ export function normalizeCartForCheckout(order: CartFragment): CartCheckout { phoneNumber: order.shippingAddress?.phoneNumber || '', }, shippingLine: { - priceWithTax: order.shippingLines[0].priceWithTax, + priceWithTax: order.shippingLines[0].priceWithTax / 100, shippingMethod: order.shippingLines[0].shippingMethod as ShippingMethod }, totalDiscount: order.discounts?.reduce((total, item) => total + item.amountWithTax, 0) / 100 || 0, diff --git a/src/components/modules/checkout/CheckoutBill/CheckoutBill.tsx b/src/components/modules/checkout/CheckoutBill/CheckoutBill.tsx index 59a0eee20..dc4462704 100644 --- a/src/components/modules/checkout/CheckoutBill/CheckoutBill.tsx +++ b/src/components/modules/checkout/CheckoutBill/CheckoutBill.tsx @@ -13,7 +13,6 @@ interface CheckoutBillProps { } const CheckoutBill = ({ data }: CheckoutBillProps) => { - // console.log("data here***: ", data) return (
@@ -40,22 +39,22 @@ const CheckoutBill = ({ data }: CheckoutBillProps) => {
Discount {(data?.discounts?.length || 0) > 0 && `(${data?.discounts?.map(item => item.description).join(",")})`}
- {data?.totalDiscount ? `${data?.totalDiscount} ${data?.currency?.code}` : "0"} + {data?.totalDiscount || 0} {data?.currency?.code}
Subtotal
- {data?.subtotalPrice ? `${data?.subtotalPrice} ${data?.currency?.code}` : "0"} + {data?.subtotalPrice || 0} {data?.currency?.code}
Shipping -
Free
+
{data?.shippingLine.priceWithTax || 0} {data?.currency?.code}
Estimated Total -
{data?.totalPrice ? `${data?.totalPrice} ${data?.currency?.code}` : "0"}
+
{data?.totalPrice || 0} {data?.currency?.code}
diff --git a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx index 47f5ed7a0..f48a41920 100644 --- a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx +++ b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx @@ -119,21 +119,8 @@ const CheckoutInfo = ({ onViewCart, currency = "" }: CheckoutInfoProps) => { }, ] - // TODO: remove - // const { addProduct } = useAddProductToCart() - - // const createOrder = () => { - // addProduct({ variantId: "92", quantity: 2 }, handleAddToCartCallback) - // } - // const handleAddToCartCallback = (isSuccess: boolean, message?: string) => { - // // console.log("after create order: ", isSuccess, message) - // } - return (
- {/* TODO: remove */} - {/* test create order */} - doneSteps = {JSON.stringify(doneSteps)}
View cart