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