Repository URL to install this package:
|
Version:
2.1.0 ▾
|
import { businessPremiumPlans, privatePremiumPlans, notCancelledPlans, hadPremiumPlans } from '../constants/segments';
import { modalTypes } from '../constants/paywall';
export default ({ segments, isForeignMandator }) => {
// For phase-out of Private/Starter plan existing users will be allowed to use Business/Pro plan features
// until they subscription runs our or until they upgrade
const isPrivatePlan = segments.some(segment => privatePremiumPlans.some(privatePlan => privatePlan === segment));
const isBusinessPlan = segments.some(segment =>
businessPremiumPlans.some(businessPremiumPlan => businessPremiumPlan === segment)
);
const isCancelled = !segments.some(segment =>
notCancelledPlans.some(notCancelledPlan => notCancelledPlan === segment)
);
const isHadPremiumPlans = segments.some(segment =>
hadPremiumPlans.some(hadPremiumPlan => hadPremiumPlan === segment)
);
switch (true) {
case isBusinessPlan || isPrivatePlan: {
return { shouldOpenModal: false };
}
case (!isBusinessPlan && isForeignMandator) || (!isPrivatePlan && isForeignMandator): {
return {
shouldOpenModal: true,
modalType: modalTypes.foreignSubscriptionUnavailable,
};
}
case !segments.length: {
return {
shouldOpenModal: true,
modalType: modalTypes.getTrialPC,
};
}
case isCancelled: {
return {
shouldOpenModal: true,
modalType: modalTypes.getPremiumPC,
};
}
case isHadPremiumPlans: {
return {
shouldOpenModal: true,
modalType: modalTypes.getPremiumPC,
};
}
default: {
return {
shouldOpenModal: true,
modalType: modalTypes.getTrialPC,
};
}
}
};