6129444c5c
* Wip * WIP * Removed concole log * Add relations to workspace init (#2511) * Add relations to workspace init * remove logs * update prefill * add missing isSystem * comment relation fields * Migrate v2 core models to graphql schema (#2509) * migrate v2 core models to graphql schema * Migrate to new workspace member schema * Continue work * migrated-main * Finished accountOwner nested field integration on companies * Introduce bug * Fix --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com> Co-authored-by: Weiko <corentin@twenty.com>
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { CurrentWorkspaceMember } from '@/auth/states/currentWorkspaceMemberState';
|
|
import { CurrentWorkspace } from '@/auth/states/currentWorkspaceState';
|
|
|
|
export enum OnboardingStatus {
|
|
OngoingUserCreation = 'ongoing_user_creation',
|
|
OngoingWorkspaceCreation = 'ongoing_workspace_creation',
|
|
OngoingProfileCreation = 'ongoing_profile_creation',
|
|
Completed = 'completed',
|
|
}
|
|
|
|
export const getOnboardingStatus = (
|
|
isLoggedIn: boolean,
|
|
currentWorkspaceMember: CurrentWorkspaceMember | null,
|
|
currentWorkspace: CurrentWorkspace | null,
|
|
) => {
|
|
if (!isLoggedIn) {
|
|
return OnboardingStatus.OngoingUserCreation;
|
|
}
|
|
|
|
// if the user has not been fetched yet, we can't know the onboarding status
|
|
if (!currentWorkspaceMember) {
|
|
return undefined;
|
|
}
|
|
|
|
if (!currentWorkspace?.displayName) {
|
|
return OnboardingStatus.OngoingWorkspaceCreation;
|
|
}
|
|
if (!currentWorkspaceMember.firstName || !currentWorkspaceMember.lastName) {
|
|
return OnboardingStatus.OngoingProfileCreation;
|
|
}
|
|
|
|
return OnboardingStatus.Completed;
|
|
};
|