File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -76,27 +76,27 @@ function Checkout() {
76
76
const { t } = useTranslation ( 'signup' ) ;
77
77
const router = useRouter ( ) ;
78
78
const {
79
- couponError,
80
79
setCouponError,
81
- checkInfoLoader,
82
80
getDiscountValue,
83
81
renderPlanDetails,
84
82
calculateTotalPrice,
85
83
handleCoupon,
84
+ setDiscountCode,
86
85
setUserSelectedPlan,
87
86
saveCouponToBag,
87
+ setDiscountCoupon,
88
+ couponError,
89
+ checkInfoLoader,
88
90
processedPrice,
89
91
allCoupons,
90
92
originalPlan,
91
93
discountCode,
92
- setDiscountCode,
93
94
currencySymbol,
94
95
couponValue,
95
96
planFormated,
96
97
planId,
97
98
fixedCouponExist,
98
99
discountCoupon,
99
- setDiscountCoupon,
100
100
} = useCheckout ( ) ;
101
101
const { query } = router ;
102
102
const [ showPaymentDetails , setShowPaymentDetails ] = useState ( true ) ;
@@ -421,10 +421,9 @@ function Checkout() {
421
421
padding = "10px"
422
422
height = "auto"
423
423
onClick = { ( ) => {
424
- console . log ( 'checkingData' , checkingData ) ;
424
+ setDiscountCode ( '' ) ;
425
425
saveCouponToBag ( [ '' ] , checkingData ?. id ) ;
426
426
removeSessionStorageItem ( 'coupon' ) ;
427
- setDiscountCode ( '' ) ;
428
427
setDiscountCoupon ( null ) ;
429
428
setCouponError ( false ) ;
430
429
} }
Original file line number Diff line number Diff line change @@ -64,6 +64,17 @@ const useCheckout = () => {
64
64
} ) . applyCoupon ( bagId ) ;
65
65
66
66
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
+
67
78
if ( couponsList ?. length > 0 ) {
68
79
const couponToFind = specificCoupon || discountCode ;
69
80
const couponData = couponsList . find ( ( { slug } ) => slug === couponToFind ) ;
@@ -473,6 +484,7 @@ const useCheckout = () => {
473
484
planId,
474
485
discountCoupon,
475
486
setDiscountCoupon,
487
+ handleCoupon,
476
488
} ;
477
489
} ;
478
490
export default useCheckout ;
You can’t perform that action at this time.
0 commit comments