fix(issue-72): reset coupon code and pricing calculation after purchasse
This commit is contained in:
parent
8dc9d871d9
commit
847b1999b8
29
src/App.tsx
29
src/App.tsx
|
|
@ -114,6 +114,10 @@ export default function App() {
|
|||
} else {
|
||||
switchTab('subscriptions');
|
||||
setVerificationResult(null);
|
||||
setCart([]);
|
||||
setAppliedCoupon(null);
|
||||
setCouponCode('');
|
||||
setPricingCalc(null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -341,6 +345,8 @@ export default function App() {
|
|||
setLoggedInUser(null);
|
||||
setCart([]);
|
||||
setAppliedCoupon(null);
|
||||
setCouponCode('');
|
||||
setPricingCalc(null);
|
||||
switchTab('storefront');
|
||||
setShowProfileDrawer(false);
|
||||
setProfileDisplayName('');
|
||||
|
|
@ -682,7 +688,13 @@ export default function App() {
|
|||
|
||||
const exists = cart.find(item => item.code === module.code);
|
||||
if (exists) {
|
||||
setCart(cart.filter(item => item.code !== module.code));
|
||||
const nextCart = cart.filter(item => item.code !== module.code);
|
||||
setCart(nextCart);
|
||||
if (nextCart.length === 0) {
|
||||
setAppliedCoupon(null);
|
||||
setCouponCode('');
|
||||
setPricingCalc(null);
|
||||
}
|
||||
} else {
|
||||
if (module.code === 'LIFETIME_ALL') {
|
||||
setCart([dynamicModule]);
|
||||
|
|
@ -754,6 +766,11 @@ export default function App() {
|
|||
const filteredCart = cart.filter(item => !isModuleUnlocked(item.code));
|
||||
if (filteredCart.length !== cart.length) {
|
||||
setCart(filteredCart);
|
||||
if (filteredCart.length === 0) {
|
||||
setAppliedCoupon(null);
|
||||
setCouponCode('');
|
||||
setPricingCalc(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [loggedInUser, cart]);
|
||||
|
|
@ -904,6 +921,8 @@ export default function App() {
|
|||
|
||||
setCart([]);
|
||||
setAppliedCoupon(null);
|
||||
setCouponCode('');
|
||||
setPricingCalc(null);
|
||||
await fetchUserProfile(userToken);
|
||||
} catch (err: any) {
|
||||
setVerificationResult({
|
||||
|
|
@ -1099,7 +1118,13 @@ export default function App() {
|
|||
{verificationResult && verificationResult.status === 'success' && (
|
||||
<PaymentSuccessModal
|
||||
verificationResult={verificationResult}
|
||||
onClose={() => setVerificationResult(null)}
|
||||
onClose={() => {
|
||||
setVerificationResult(null);
|
||||
setCart([]);
|
||||
setAppliedCoupon(null);
|
||||
setCouponCode('');
|
||||
setPricingCalc(null);
|
||||
}}
|
||||
loggedInUser={loggedInUser}
|
||||
onDownloadInvoice={handleDownloadCheckoutInvoice}
|
||||
downloadingInvoice={downloadingModalInvoice}
|
||||
|
|
|
|||
Loading…
Reference in New Issue