This commit is contained in:
Manav Rathi
2024-11-06 13:57:03 +05:30
parent eb5f2e5e46
commit 8225070dd3
2 changed files with 12 additions and 14 deletions

View File

@@ -55,10 +55,8 @@ import {
hasPaidSubscription,
hasStripeSubscription,
isOnFreePlan,
isPopularPlan,
isSubscriptionActive,
isSubscriptionCancelled,
isUserSubscribedPlan,
planSelectionOutcome,
} from "utils/billing";
@@ -508,6 +506,18 @@ const Plans = ({
);
};
function isUserSubscribedPlan(plan: Plan, subscription: Subscription) {
return (
isSubscriptionActive(subscription) &&
(plan.stripeID === subscription.productID ||
plan.iosID === subscription.productID ||
plan.androidID === subscription.productID)
);
}
const isPopularPlan = (plan: Plan) =>
plan.storage === 100 * 1024 * 1024 * 1024; /* 100 GB */
interface PlanRowProps {
plan: Plan;
subscription: Subscription;

View File

@@ -8,7 +8,6 @@ import { getData, LS_KEYS } from "@ente/shared/storage/localStorage";
import { t } from "i18next";
import type { NextRouter } from "next/router";
import billingService, {
Plan,
redirectToCustomerPortal,
Subscription,
} from "services/billingService";
@@ -107,14 +106,6 @@ export function getLocalUserSubscription(): Subscription {
return getData(LS_KEYS.SUBSCRIPTION);
}
export function isUserSubscribedPlan(plan: Plan, subscription: Subscription) {
return (
isSubscriptionActive(subscription) &&
(plan.stripeID === subscription.productID ||
plan.iosID === subscription.productID ||
plan.androidID === subscription.productID)
);
}
export function hasStripeSubscription(subscription: Subscription) {
return subscription.paymentProvider == "stripe";
}
@@ -141,9 +132,6 @@ export function isSubscriptionPastDue(subscription: Subscription) {
);
}
export const isPopularPlan = (plan: Plan) =>
plan.storage === 100 * 1024 * 1024 * 1024; /* 100 GB */
/**
* When the payments app redirects back to us after a plan purchase or update
* completes, it sets various query parameters to relay the status of the action