From afe4248799e9a4f5db7f9df1fa65227a06173bc2 Mon Sep 17 00:00:00 2001 From: Lindy <33708359+Lindysen@users.noreply.github.com> Date: Mon, 7 Sep 2020 20:11:47 +0800 Subject: [PATCH] fix(CouponCell): fix discounted price (#7123) --- src/coupon-cell/index.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/coupon-cell/index.tsx b/src/coupon-cell/index.tsx index 46259f10f..87a9c1aa1 100644 --- a/src/coupon-cell/index.tsx +++ b/src/coupon-cell/index.tsx @@ -1,5 +1,5 @@ // Utils -import { createNamespace } from '../utils'; +import { createNamespace, isDef } from '../utils'; import { inherit } from '../utils/functional'; // Components @@ -26,7 +26,15 @@ function formatValue(props: CouponCellProps) { const coupon = coupons[+chosenCoupon]; if (coupon) { - const value = coupon.value || coupon.denominations || 0; + let value = 0; + if (isDef(coupon.value)) { + ({ value } = coupon); + } + + if (isDef(coupon.denominations)) { + value = coupon.denominations!; + } + return `-${currency} ${(value / 100).toFixed(2)}`; }