Skip to content

Commit

Permalink
Allow free access for configuration using billing
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesBochet committed Aug 3, 2024
1 parent 76185c2 commit e2b42ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -100,9 +99,7 @@ export const usePageChangeEffectNavigateLocation = () => {

if (
onboardingStatus === OnboardingStatus.Completed &&
isMatchingOnboardingRoute &&
subscriptionStatus !== SubscriptionStatus.Canceled &&
(isDefined(subscriptionStatus) || !isMatchingLocation(AppPath.PlanRequired))
isMatchingOnboardingRoute
) {
return defaultHomePagePath;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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>,
) {}

Expand All @@ -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,
Expand Down

0 comments on commit e2b42ee

Please sign in to comment.