Skip to content

Commit 9ea8145

Browse files
Merge pull request #2039 from lumi-tip/development-lumi-9211
🐛 infinite loading on coupons
2 parents 909e2c1 + c07708f commit 9ea8145

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/pages/checkout/index.jsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,27 @@ function Checkout() {
7676
const { t } = useTranslation('signup');
7777
const router = useRouter();
7878
const {
79-
couponError,
8079
setCouponError,
81-
checkInfoLoader,
8280
getDiscountValue,
8381
renderPlanDetails,
8482
calculateTotalPrice,
8583
handleCoupon,
84+
setDiscountCode,
8685
setUserSelectedPlan,
8786
saveCouponToBag,
87+
setDiscountCoupon,
88+
couponError,
89+
checkInfoLoader,
8890
processedPrice,
8991
allCoupons,
9092
originalPlan,
9193
discountCode,
92-
setDiscountCode,
9394
currencySymbol,
9495
couponValue,
9596
planFormated,
9697
planId,
9798
fixedCouponExist,
9899
discountCoupon,
99-
setDiscountCoupon,
100100
} = useCheckout();
101101
const { query } = router;
102102
const [showPaymentDetails, setShowPaymentDetails] = useState(true);
@@ -421,10 +421,9 @@ function Checkout() {
421421
padding="10px"
422422
height="auto"
423423
onClick={() => {
424-
console.log('checkingData', checkingData);
424+
setDiscountCode('');
425425
saveCouponToBag([''], checkingData?.id);
426426
removeSessionStorageItem('coupon');
427-
setDiscountCode('');
428427
setDiscountCoupon(null);
429428
setCouponError(false);
430429
}}

src/pages/checkout/useCheckout.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ const useCheckout = () => {
6464
}).applyCoupon(bagId);
6565

6666
const couponsList = resp?.data?.coupons;
67+
68+
if (coupons[0] === '') {
69+
setDiscountCoupon(null);
70+
setCheckingData({
71+
...checkingData,
72+
coupons: [],
73+
});
74+
setCouponError(false);
75+
return;
76+
}
77+
6778
if (couponsList?.length > 0) {
6879
const couponToFind = specificCoupon || discountCode;
6980
const couponData = couponsList.find(({ slug }) => slug === couponToFind);
@@ -473,6 +484,7 @@ const useCheckout = () => {
473484
planId,
474485
discountCoupon,
475486
setDiscountCoupon,
487+
handleCoupon,
476488
};
477489
};
478490
export default useCheckout;

0 commit comments

Comments
 (0)