show cancel subscription on mobile popup for subscription change request by non stripe subscription user

This commit is contained in:
Abhinav-grd 2021-04-23 10:55:57 +05:30
parent 03a03ad36a
commit 612e415e26
2 changed files with 22 additions and 9 deletions

View file

@ -7,7 +7,6 @@ import {
convertBytesToGBs,
getPlans,
getUserSubscription,
hasPaidPlan,
isUserSubscribedPlan,
isSubscriptionCancelled,
updatePaymentMethod,
@ -17,6 +16,9 @@ import {
updateSubscription,
activateSubscription,
cancelSubscription,
hasStripeSubscription,
hasPaidSubscription,
isOnFreePlan,
} from 'utils/billingUtil';
import { CONFIRM_ACTION } from 'components/ConfirmDialog';
import { LoadingOverlay } from './CollectionSelector';
@ -61,7 +63,16 @@ function PlanSelector(props: Props) {
};
async function onPlanSelect(plan: Plan) {
if (hasPaidPlan(subscription)) {
if (
!hasStripeSubscription(subscription) &&
!isSubscriptionCancelled(subscription)
) {
props.setDialogMessage({
title: constants.ERROR,
content: constants.CANCEL_SUBSCRIPTION_ON_MOBILE,
close: { variant: 'danger' },
});
} else if (hasStripeSubscription(subscription)) {
props.setConfirmAction({
action: CONFIRM_ACTION.UPDATE_SUBSCRIPTION,
callback: updateSubscription.bind(
@ -133,7 +144,7 @@ function PlanSelector(props: Props) {
dialogClassName="modal-90w"
style={{ maxWidth: '100%' }}
centered
backdrop={hasPaidPlan(subscription) ? 'true' : `static`}
backdrop={hasPaidSubscription(subscription) ? 'true' : `static`}
>
<Modal.Header closeButton>
<Modal.Title
@ -144,7 +155,7 @@ function PlanSelector(props: Props) {
}}
>
<span>
{hasPaidPlan(subscription)
{hasPaidSubscription(subscription)
? constants.MANAGE_PLAN
: constants.CHOOSE_PLAN}
</span>
@ -182,7 +193,7 @@ function PlanSelector(props: Props) {
)}
</div>
<DeadCenter style={{ marginBottom: '30px' }}>
{hasPaidPlan(subscription) ? (
{hasStripeSubscription(subscription) ? (
<>
{isSubscriptionCancelled(subscription) ? (
<LinkButton
@ -241,10 +252,12 @@ function PlanSelector(props: Props) {
</>
) : (
<LinkButton
variant="secondary"
variant="primary"
onClick={props.closeModal}
>
{constants.SKIP}
{isOnFreePlan(subscription)
? constants.SKIP
: constants.CLOSE}
</LinkButton>
)}
</DeadCenter>

View file

@ -185,7 +185,7 @@ const englishConstants = {
MANAGE: 'manage',
MANAGEMENT_PORTAL: 'manage payment method',
CHOOSE_PLAN: 'choose your subscription plan',
MANAGE_PLAN: 'update your subscription plan',
MANAGE_PLAN: 'manage your subscription',
FREE_SUBSCRIPTION_INFO: (expiryTime) => (
<>
@ -257,7 +257,7 @@ const englishConstants = {
SUBSCRIPTION_ACTIVATE_FAILED: 'failed to reactivate subscription renewals',
SUBSCRIPTION_PURCHASE_SUCCESS_TITLE: 'thank you',
SUBSCRIPTION_MANAGEMENT_NOT_POSSIBLE: `please use the mobile app to manage your subscription`,
CANCEL_SUBSCRIPTION_ON_MOBILE: `please cancel your subscription from the mobile app to activate a subscription here`,
};
export default englishConstants;