5622 add a syncemail onboarding step (#5689)
- add sync email onboarding step - refactor calendar and email visibility enums - add a new table `keyValuePair` in `core` schema - add a new resolved boolean field `skipSyncEmail` in current user https://github.com/twentyhq/twenty/assets/29927851/de791475-5bfe-47f9-8e90-76c349fba56f
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { CurrentUser } from '@/auth/states/currentUserState';
|
||||
import { CurrentWorkspace } from '@/auth/states/currentWorkspaceState';
|
||||
import { WorkspaceMember } from '@/workspace-member/types/WorkspaceMember';
|
||||
|
||||
@ -9,6 +10,7 @@ describe('getOnboardingStatus', () => {
|
||||
isLoggedIn: false,
|
||||
currentWorkspaceMember: null,
|
||||
currentWorkspace: null,
|
||||
currentUser: null,
|
||||
isBillingEnabled: false,
|
||||
});
|
||||
|
||||
@ -19,6 +21,9 @@ describe('getOnboardingStatus', () => {
|
||||
id: '1',
|
||||
activationStatus: 'inactive',
|
||||
} as CurrentWorkspace,
|
||||
currentUser: {
|
||||
state: { skipSyncEmailOnboardingStep: true },
|
||||
} as CurrentUser,
|
||||
isBillingEnabled: false,
|
||||
});
|
||||
|
||||
@ -32,6 +37,28 @@ describe('getOnboardingStatus', () => {
|
||||
id: '1',
|
||||
activationStatus: 'active',
|
||||
} as CurrentWorkspace,
|
||||
currentUser: {
|
||||
state: { skipSyncEmailOnboardingStep: true },
|
||||
} as CurrentUser,
|
||||
isBillingEnabled: false,
|
||||
});
|
||||
|
||||
const ongoingSyncEmail = getOnboardingStatus({
|
||||
isLoggedIn: true,
|
||||
currentWorkspaceMember: {
|
||||
id: '1',
|
||||
name: {
|
||||
firstName: 'John',
|
||||
lastName: 'Doe',
|
||||
},
|
||||
} as WorkspaceMember,
|
||||
currentWorkspace: {
|
||||
id: '1',
|
||||
activationStatus: 'active',
|
||||
} as CurrentWorkspace,
|
||||
currentUser: {
|
||||
state: { skipSyncEmailOnboardingStep: false },
|
||||
} as CurrentUser,
|
||||
isBillingEnabled: false,
|
||||
});
|
||||
|
||||
@ -48,6 +75,9 @@ describe('getOnboardingStatus', () => {
|
||||
id: '1',
|
||||
activationStatus: 'active',
|
||||
} as CurrentWorkspace,
|
||||
currentUser: {
|
||||
state: { skipSyncEmailOnboardingStep: true },
|
||||
} as CurrentUser,
|
||||
isBillingEnabled: false,
|
||||
});
|
||||
|
||||
@ -65,6 +95,9 @@ describe('getOnboardingStatus', () => {
|
||||
activationStatus: 'active',
|
||||
subscriptionStatus: 'incomplete',
|
||||
} as CurrentWorkspace,
|
||||
currentUser: {
|
||||
state: { skipSyncEmailOnboardingStep: true },
|
||||
} as CurrentUser,
|
||||
isBillingEnabled: true,
|
||||
});
|
||||
|
||||
@ -82,6 +115,9 @@ describe('getOnboardingStatus', () => {
|
||||
activationStatus: 'active',
|
||||
subscriptionStatus: 'incomplete',
|
||||
} as CurrentWorkspace,
|
||||
currentUser: {
|
||||
state: { skipSyncEmailOnboardingStep: true },
|
||||
} as CurrentUser,
|
||||
isBillingEnabled: false,
|
||||
});
|
||||
|
||||
@ -99,12 +135,16 @@ describe('getOnboardingStatus', () => {
|
||||
activationStatus: 'active',
|
||||
subscriptionStatus: 'canceled',
|
||||
} as CurrentWorkspace,
|
||||
currentUser: {
|
||||
state: { skipSyncEmailOnboardingStep: true },
|
||||
} as CurrentUser,
|
||||
isBillingEnabled: true,
|
||||
});
|
||||
|
||||
expect(ongoingUserCreation).toBe('ongoing_user_creation');
|
||||
expect(ongoingWorkspaceActivation).toBe('ongoing_workspace_activation');
|
||||
expect(ongoingProfileCreation).toBe('ongoing_profile_creation');
|
||||
expect(ongoingSyncEmail).toBe('ongoing_sync_email');
|
||||
expect(completed).toBe('completed');
|
||||
expect(incomplete).toBe('incomplete');
|
||||
expect(canceled).toBe('canceled');
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { CurrentUser } from '@/auth/states/currentUserState';
|
||||
import { CurrentWorkspace } from '@/auth/states/currentWorkspaceState';
|
||||
import { WorkspaceMember } from '@/workspace-member/types/WorkspaceMember';
|
||||
|
||||
@ -9,6 +10,7 @@ export enum OnboardingStatus {
|
||||
OngoingUserCreation = 'ongoing_user_creation',
|
||||
OngoingWorkspaceActivation = 'ongoing_workspace_activation',
|
||||
OngoingProfileCreation = 'ongoing_profile_creation',
|
||||
OngoingSyncEmail = 'ongoing_sync_email',
|
||||
Completed = 'completed',
|
||||
CompletedWithoutSubscription = 'completed_without_subscription',
|
||||
}
|
||||
@ -17,6 +19,7 @@ export const getOnboardingStatus = ({
|
||||
isLoggedIn,
|
||||
currentWorkspaceMember,
|
||||
currentWorkspace,
|
||||
currentUser,
|
||||
isBillingEnabled,
|
||||
}: {
|
||||
isLoggedIn: boolean;
|
||||
@ -25,6 +28,7 @@ export const getOnboardingStatus = ({
|
||||
'createdAt' | 'updatedAt' | 'userId' | 'userEmail' | '__typename'
|
||||
> | null;
|
||||
currentWorkspace: CurrentWorkspace | null;
|
||||
currentUser: CurrentUser | null;
|
||||
isBillingEnabled: boolean;
|
||||
}) => {
|
||||
if (!isLoggedIn) {
|
||||
@ -33,7 +37,7 @@ export const getOnboardingStatus = ({
|
||||
|
||||
// After SignInUp, the user should have a current workspace assigned.
|
||||
// If not, it indicates that the data is still being requested.
|
||||
if (!currentWorkspace) {
|
||||
if (!currentWorkspace || !currentUser) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -55,6 +59,10 @@ export const getOnboardingStatus = ({
|
||||
return OnboardingStatus.OngoingProfileCreation;
|
||||
}
|
||||
|
||||
if (!currentUser.state.skipSyncEmailOnboardingStep) {
|
||||
return OnboardingStatus.OngoingSyncEmail;
|
||||
}
|
||||
|
||||
if (isBillingEnabled && currentWorkspace.subscriptionStatus === 'canceled') {
|
||||
return OnboardingStatus.Canceled;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user