feat: redirect to Plan Required page if subscription status is not active (#2981)
* feat: redirect to Plan Required page if subscription status is not active Closes #2934 * feat: navigate to Plan Required in PageChangeEffect * feat: add Twenty logo to Plan Required modal * test: add Storybook story * Fix lint --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -2,17 +2,25 @@ import { CurrentWorkspace } from '@/auth/states/currentWorkspaceState';
|
||||
import { WorkspaceMember } from '@/workspace-member/types/WorkspaceMember';
|
||||
|
||||
export enum OnboardingStatus {
|
||||
Incomplete = 'incomplete',
|
||||
Canceled = 'canceled',
|
||||
OngoingUserCreation = 'ongoing_user_creation',
|
||||
OngoingWorkspaceCreation = 'ongoing_workspace_creation',
|
||||
OngoingProfileCreation = 'ongoing_profile_creation',
|
||||
Completed = 'completed',
|
||||
}
|
||||
|
||||
export const getOnboardingStatus = (
|
||||
isLoggedIn: boolean,
|
||||
currentWorkspaceMember: WorkspaceMember | null,
|
||||
currentWorkspace: CurrentWorkspace | null,
|
||||
) => {
|
||||
export const getOnboardingStatus = ({
|
||||
isLoggedIn,
|
||||
currentWorkspaceMember,
|
||||
currentWorkspace,
|
||||
isBillingEnabled,
|
||||
}: {
|
||||
isLoggedIn: boolean;
|
||||
currentWorkspaceMember: WorkspaceMember | null;
|
||||
currentWorkspace: CurrentWorkspace | null;
|
||||
isBillingEnabled?: boolean;
|
||||
}) => {
|
||||
if (!isLoggedIn) {
|
||||
return OnboardingStatus.OngoingUserCreation;
|
||||
}
|
||||
@ -22,6 +30,17 @@ export const getOnboardingStatus = (
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (
|
||||
isBillingEnabled &&
|
||||
currentWorkspace?.subscriptionStatus === 'incomplete'
|
||||
) {
|
||||
return OnboardingStatus.Incomplete;
|
||||
}
|
||||
|
||||
if (isBillingEnabled && currentWorkspace?.subscriptionStatus === 'canceled') {
|
||||
return OnboardingStatus.Canceled;
|
||||
}
|
||||
|
||||
if (!currentWorkspace?.displayName) {
|
||||
return OnboardingStatus.OngoingWorkspaceCreation;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user