Allow free access for configuration using billing
This commit is contained in:
@ -6,7 +6,6 @@ import { useSubscriptionStatus } from '@/workspace/hooks/useSubscriptionStatus';
|
||||
import { OnboardingStatus, SubscriptionStatus } from '~/generated/graphql';
|
||||
import { useDefaultHomePagePath } from '~/hooks/useDefaultHomePagePath';
|
||||
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
|
||||
export const usePageChangeEffectNavigateLocation = () => {
|
||||
const isMatchingLocation = useIsMatchingLocation();
|
||||
@ -100,9 +99,7 @@ export const usePageChangeEffectNavigateLocation = () => {
|
||||
|
||||
if (
|
||||
onboardingStatus === OnboardingStatus.Completed &&
|
||||
isMatchingOnboardingRoute &&
|
||||
subscriptionStatus !== SubscriptionStatus.Canceled &&
|
||||
(isDefined(subscriptionStatus) || !isMatchingLocation(AppPath.PlanRequired))
|
||||
isMatchingOnboardingRoute
|
||||
) {
|
||||
return defaultHomePagePath;
|
||||
}
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { BillingModule } from 'src/engine/core-modules/billing/billing.module';
|
||||
import { FeatureFlagModule } from 'src/engine/core-modules/feature-flag/feature-flag.module';
|
||||
import { OnboardingResolver } from 'src/engine/core-modules/onboarding/onboarding.resolver';
|
||||
import { OnboardingService } from 'src/engine/core-modules/onboarding/onboarding.service';
|
||||
import { UserVarsModule } from 'src/engine/core-modules/user/user-vars/user-vars.module';
|
||||
|
||||
@Module({
|
||||
imports: [BillingModule, UserVarsModule],
|
||||
imports: [BillingModule, UserVarsModule, FeatureFlagModule],
|
||||
exports: [OnboardingService],
|
||||
providers: [OnboardingService, OnboardingResolver],
|
||||
})
|
||||
|
||||
@ -2,6 +2,8 @@ import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { SubscriptionStatus } from 'src/engine/core-modules/billing/entities/billing-subscription.entity';
|
||||
import { BillingSubscriptionService } from 'src/engine/core-modules/billing/services/billing-subscription.service';
|
||||
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
|
||||
import { IsFeatureEnabledService } from 'src/engine/core-modules/feature-flag/services/is-feature-enabled.service';
|
||||
import { OnboardingStatus } from 'src/engine/core-modules/onboarding/enums/onboarding-status.enum';
|
||||
import { UserVarsService } from 'src/engine/core-modules/user/user-vars/services/user-vars.service';
|
||||
import { User } from 'src/engine/core-modules/user/user.entity';
|
||||
@ -26,6 +28,7 @@ export class OnboardingService {
|
||||
constructor(
|
||||
private readonly billingSubscriptionService: BillingSubscriptionService,
|
||||
private readonly environmentService: EnvironmentService,
|
||||
private readonly isFeatureEnabledService: IsFeatureEnabledService,
|
||||
private readonly userVarsService: UserVarsService<OnboardingKeyValueTypeMap>,
|
||||
) {}
|
||||
|
||||
@ -36,6 +39,16 @@ export class OnboardingService {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isFreeAccessEnabled =
|
||||
await this.isFeatureEnabledService.isFeatureEnabled(
|
||||
FeatureFlagKey.IsFreeAccessEnabled,
|
||||
user.defaultWorkspaceId,
|
||||
);
|
||||
|
||||
if (isFreeAccessEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const currentBillingSubscription =
|
||||
await this.billingSubscriptionService.getCurrentBillingSubscription({
|
||||
workspaceId: user.defaultWorkspaceId,
|
||||
|
||||
Reference in New Issue
Block a user