mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix lint
This commit is contained in:
@@ -54,9 +54,11 @@ export default class SubscriptionPlan {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public static isFreePlan(planId: string, env: JSONObject): boolean {
|
||||
const plan: SubscriptionPlan | undefined =
|
||||
this.getSubscriptionPlanById(planId, env);
|
||||
public static isFreePlan(planId: string, env: JSONObject): boolean {
|
||||
const plan: SubscriptionPlan | undefined = this.getSubscriptionPlanById(
|
||||
planId,
|
||||
env
|
||||
);
|
||||
if (plan) {
|
||||
if (
|
||||
plan.getMonthlyPlanId() === planId &&
|
||||
@@ -76,9 +78,14 @@ export default class SubscriptionPlan {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static isCustomPricingPlan(planId: string, env: JSONObject): boolean {
|
||||
const plan: SubscriptionPlan | undefined =
|
||||
this.getSubscriptionPlanById(planId, env);
|
||||
public static isCustomPricingPlan(
|
||||
planId: string,
|
||||
env: JSONObject
|
||||
): boolean {
|
||||
const plan: SubscriptionPlan | undefined = this.getSubscriptionPlanById(
|
||||
planId,
|
||||
env
|
||||
);
|
||||
if (plan) {
|
||||
if (plan.getMonthlyPlanId() === planId && plan.isCustomPricing()) {
|
||||
return true;
|
||||
@@ -147,13 +154,15 @@ export default class SubscriptionPlan {
|
||||
});
|
||||
}
|
||||
|
||||
public static isValidPlanId(planId: string, env: JSONObject): boolean {
|
||||
public static isValidPlanId(planId: string, env: JSONObject): boolean {
|
||||
return Boolean(this.getSubscriptionPlanById(planId, env));
|
||||
}
|
||||
|
||||
public static getPlanSelect(planId: string, env: JSONObject): PlanSelect {
|
||||
const plan: SubscriptionPlan | undefined =
|
||||
this.getSubscriptionPlanById(planId, env);
|
||||
public static getPlanSelect(planId: string, env: JSONObject): PlanSelect {
|
||||
const plan: SubscriptionPlan | undefined = this.getSubscriptionPlanById(
|
||||
planId,
|
||||
env
|
||||
);
|
||||
if (!plan) {
|
||||
throw new BadDataException('Plan ID is invalid');
|
||||
}
|
||||
@@ -198,9 +207,11 @@ export default class SubscriptionPlan {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static isYearlyPlan(planId: string, env: JSONObject): boolean {
|
||||
const plan: SubscriptionPlan | undefined =
|
||||
this.getSubscriptionPlanById(planId, env);
|
||||
public static isYearlyPlan(planId: string, env: JSONObject): boolean {
|
||||
const plan: SubscriptionPlan | undefined = this.getSubscriptionPlanById(
|
||||
planId,
|
||||
env
|
||||
);
|
||||
return plan?.getYearlyPlanId() === planId;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import Route from 'Common/Types/API/Route';
|
||||
import SubscriptionPlan from 'Common/Types/Billing/SubscriptionPlan';
|
||||
import { JSONObject } from 'Common/Types/JSON';
|
||||
|
||||
|
||||
export const getAllEnvVars: Function = (): JSONObject => {
|
||||
return process.env;
|
||||
};
|
||||
|
||||
@@ -59,7 +59,10 @@ export class Service extends DatabaseService<Model> {
|
||||
}
|
||||
|
||||
if (
|
||||
!SubscriptionPlan.isValidPlanId(data.data.paymentProviderPlanId, getAllEnvVars())
|
||||
!SubscriptionPlan.isValidPlanId(
|
||||
data.data.paymentProviderPlanId,
|
||||
getAllEnvVars()
|
||||
)
|
||||
) {
|
||||
throw new BadDataException('Plan is invalid.');
|
||||
}
|
||||
@@ -137,7 +140,8 @@ export class Service extends DatabaseService<Model> {
|
||||
) {
|
||||
const plan: SubscriptionPlan | undefined =
|
||||
SubscriptionPlan.getSubscriptionPlanById(
|
||||
updateBy.data.paymentProviderPlanId! as string, getAllEnvVars()
|
||||
updateBy.data.paymentProviderPlanId! as string,
|
||||
getAllEnvVars()
|
||||
);
|
||||
|
||||
if (!plan) {
|
||||
@@ -248,7 +252,8 @@ export class Service extends DatabaseService<Model> {
|
||||
|
||||
const plan: SubscriptionPlan | undefined =
|
||||
SubscriptionPlan.getSubscriptionPlanById(
|
||||
createdItem.paymentProviderPlanId!, getAllEnvVars()
|
||||
createdItem.paymentProviderPlanId!,
|
||||
getAllEnvVars()
|
||||
);
|
||||
|
||||
if (!plan) {
|
||||
@@ -647,7 +652,10 @@ export class Service extends DatabaseService<Model> {
|
||||
}
|
||||
|
||||
return {
|
||||
plan: SubscriptionPlan.getPlanSelect(project.paymentProviderPlanId, getAllEnvVars()),
|
||||
plan: SubscriptionPlan.getPlanSelect(
|
||||
project.paymentProviderPlanId,
|
||||
getAllEnvVars()
|
||||
),
|
||||
isSubscriptionUnpaid: SubscriptionPlan.isUnpaid(
|
||||
project.paymentProviderSubscriptionStatus || 'active'
|
||||
),
|
||||
|
||||
@@ -209,10 +209,12 @@ const DashboardHeader: FunctionComponent<ComponentProps> = (
|
||||
props.selectedProject?.id &&
|
||||
props.selectedProject.paymentProviderPlanId &&
|
||||
!SubscriptionPlan.isFreePlan(
|
||||
props.selectedProject.paymentProviderPlanId, getAllEnvVars()
|
||||
props.selectedProject.paymentProviderPlanId,
|
||||
getAllEnvVars()
|
||||
) &&
|
||||
!SubscriptionPlan.isCustomPricingPlan(
|
||||
props.selectedProject.paymentProviderPlanId, getAllEnvVars()
|
||||
props.selectedProject.paymentProviderPlanId,
|
||||
getAllEnvVars()
|
||||
) &&
|
||||
!isPaymentMethodCountLoading &&
|
||||
paymentMethodCount === 0 ? (
|
||||
@@ -240,7 +242,8 @@ const DashboardHeader: FunctionComponent<ComponentProps> = (
|
||||
props.selectedProject?.id &&
|
||||
props.selectedProject.paymentProviderPlanId &&
|
||||
SubscriptionPlan.isFreePlan(
|
||||
props.selectedProject.paymentProviderPlanId, getAllEnvVars()
|
||||
props.selectedProject.paymentProviderPlanId,
|
||||
getAllEnvVars()
|
||||
) ? (
|
||||
<Upgrade projectId={props.selectedProject.id} />
|
||||
) : (
|
||||
|
||||
@@ -219,7 +219,8 @@ const Settings: FunctionComponent<ComponentProps> = (
|
||||
|
||||
const isYearlyPlan: boolean =
|
||||
SubscriptionPlan.isYearlyPlan(
|
||||
item['paymentProviderPlanId'] as string,getAllEnvVars()
|
||||
item['paymentProviderPlanId'] as string,
|
||||
getAllEnvVars()
|
||||
);
|
||||
|
||||
let description: string = plan.isCustomPricing()
|
||||
|
||||
@@ -132,7 +132,8 @@ const StatusPageDelete: FunctionComponent<PageComponentProps> = (
|
||||
},
|
||||
]}
|
||||
currentPlan={SubscriptionPlan.getPlanSelect(
|
||||
props.currentProject?.paymentProviderPlanId!, getAllEnvVars()
|
||||
props.currentProject?.paymentProviderPlanId!,
|
||||
getAllEnvVars()
|
||||
)}
|
||||
/>
|
||||
</Page>
|
||||
|
||||
Reference in New Issue
Block a user