|
@@ -9,7 +9,6 @@ import {
|
|
|
isOnFreePlan,
|
|
|
planForSubscription,
|
|
|
hasMobileSubscription,
|
|
|
- hasPaypalSubscription,
|
|
|
getLocalUserSubscription,
|
|
|
hasPaidSubscription,
|
|
|
getTotalFamilyUsage,
|
|
@@ -105,23 +104,20 @@ function PlanSelectorCard(props: Props) {
|
|
|
|
|
|
async function onPlanSelect(plan: Plan) {
|
|
|
if (
|
|
|
- hasMobileSubscription(subscription) &&
|
|
|
- !isSubscriptionCancelled(subscription)
|
|
|
+ !hasPaidSubscription(subscription) ||
|
|
|
+ isSubscriptionCancelled(subscription)
|
|
|
) {
|
|
|
- appContext.setDialogMessage({
|
|
|
- title: constants.ERROR,
|
|
|
- content: constants.CANCEL_SUBSCRIPTION_ON_MOBILE,
|
|
|
- close: { variant: 'danger' },
|
|
|
- });
|
|
|
- } else if (
|
|
|
- hasPaypalSubscription(subscription) &&
|
|
|
- !isSubscriptionCancelled(subscription)
|
|
|
- ) {
|
|
|
- appContext.setDialogMessage({
|
|
|
- title: constants.MANAGE_PLAN,
|
|
|
- content: constants.PAYPAL_MANAGE_NOT_SUPPORTED_MESSAGE(),
|
|
|
- close: { variant: 'danger' },
|
|
|
- });
|
|
|
+ try {
|
|
|
+ props.setLoading(true);
|
|
|
+ await billingService.buySubscription(plan.stripeID);
|
|
|
+ } catch (e) {
|
|
|
+ props.setLoading(false);
|
|
|
+ appContext.setDialogMessage({
|
|
|
+ title: constants.ERROR,
|
|
|
+ content: constants.SUBSCRIPTION_PURCHASE_FAILED,
|
|
|
+ close: { variant: 'danger' },
|
|
|
+ });
|
|
|
+ }
|
|
|
} else if (hasStripeSubscription(subscription)) {
|
|
|
appContext.setDialogMessage({
|
|
|
title: `${constants.CONFIRM} ${reverseString(
|
|
@@ -141,18 +137,18 @@ function PlanSelectorCard(props: Props) {
|
|
|
},
|
|
|
close: { text: constants.CANCEL },
|
|
|
});
|
|
|
+ } else if (hasMobileSubscription(subscription)) {
|
|
|
+ appContext.setDialogMessage({
|
|
|
+ title: constants.CANCEL_SUBSCRIPTION_ON_MOBILE,
|
|
|
+ content: constants.CANCEL_SUBSCRIPTION_ON_MOBILE_MESSAGE,
|
|
|
+ close: { variant: 'secondary' },
|
|
|
+ });
|
|
|
} else {
|
|
|
- try {
|
|
|
- props.setLoading(true);
|
|
|
- await billingService.buySubscription(plan.stripeID);
|
|
|
- } catch (e) {
|
|
|
- props.setLoading(false);
|
|
|
- appContext.setDialogMessage({
|
|
|
- title: constants.ERROR,
|
|
|
- content: constants.SUBSCRIPTION_PURCHASE_FAILED,
|
|
|
- close: { variant: 'danger' },
|
|
|
- });
|
|
|
- }
|
|
|
+ appContext.setDialogMessage({
|
|
|
+ title: constants.MANAGE_PLAN,
|
|
|
+ content: constants.MAIL_TO_MANAGE_SUBSCRIPTION,
|
|
|
+ close: { variant: 'secondary' },
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|