poc - cal.com integration in onboarding flow (#12530)
This commit is contained in:
@ -83,6 +83,7 @@ describe('ClientConfigController', () => {
|
||||
isGoogleMessagingEnabled: false,
|
||||
isGoogleCalendarEnabled: false,
|
||||
isConfigVariablesInDbEnabled: false,
|
||||
calendarBookingPageId: undefined,
|
||||
};
|
||||
|
||||
jest
|
||||
|
||||
@ -147,4 +147,7 @@ export class ClientConfig {
|
||||
|
||||
@Field(() => Boolean)
|
||||
isConfigVariablesInDbEnabled: boolean;
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
calendarBookingPageId?: string;
|
||||
}
|
||||
|
||||
@ -78,6 +78,7 @@ describe('ClientConfigService', () => {
|
||||
MESSAGING_PROVIDER_GMAIL_ENABLED: true,
|
||||
CALENDAR_PROVIDER_GOOGLE_ENABLED: true,
|
||||
IS_CONFIG_VARIABLES_IN_DB_ENABLED: false,
|
||||
CALENDAR_BOOKING_PAGE_ID: 'team/twenty/talk-to-us',
|
||||
};
|
||||
|
||||
return mockValues[key];
|
||||
@ -145,6 +146,7 @@ describe('ClientConfigService', () => {
|
||||
isGoogleMessagingEnabled: true,
|
||||
isGoogleCalendarEnabled: true,
|
||||
isConfigVariablesInDbEnabled: false,
|
||||
calendarBookingPageId: 'team/twenty/talk-to-us',
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -102,6 +102,9 @@ export class ClientConfigService {
|
||||
isConfigVariablesInDbEnabled: this.twentyConfigService.get(
|
||||
'IS_CONFIG_VARIABLES_IN_DB_ENABLED',
|
||||
),
|
||||
calendarBookingPageId: this.twentyConfigService.get(
|
||||
'CALENDAR_BOOKING_PAGE_ID',
|
||||
),
|
||||
};
|
||||
|
||||
return clientConfig;
|
||||
|
||||
@ -4,5 +4,6 @@ export enum OnboardingStatus {
|
||||
PROFILE_CREATION = 'PROFILE_CREATION',
|
||||
SYNC_EMAIL = 'SYNC_EMAIL',
|
||||
INVITE_TEAM = 'INVITE_TEAM',
|
||||
BOOK_ONBOARDING = 'BOOK_ONBOARDING',
|
||||
COMPLETED = 'COMPLETED',
|
||||
}
|
||||
|
||||
@ -28,4 +28,16 @@ export class OnboardingResolver {
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
@Mutation(() => OnboardingStepSuccess)
|
||||
async skipBookOnboardingStep(
|
||||
@AuthWorkspace() workspace: Workspace,
|
||||
): Promise<OnboardingStepSuccess> {
|
||||
await this.onboardingService.setOnboardingBookOnboardingPending({
|
||||
workspaceId: workspace.id,
|
||||
value: false,
|
||||
});
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,12 +12,14 @@ export enum OnboardingStepKeys {
|
||||
ONBOARDING_CONNECT_ACCOUNT_PENDING = 'ONBOARDING_CONNECT_ACCOUNT_PENDING',
|
||||
ONBOARDING_INVITE_TEAM_PENDING = 'ONBOARDING_INVITE_TEAM_PENDING',
|
||||
ONBOARDING_CREATE_PROFILE_PENDING = 'ONBOARDING_CREATE_PROFILE_PENDING',
|
||||
ONBOARDING_BOOK_ONBOARDING_PENDING = 'ONBOARDING_BOOK_ONBOARDING_PENDING',
|
||||
}
|
||||
|
||||
export type OnboardingKeyValueTypeMap = {
|
||||
[OnboardingStepKeys.ONBOARDING_CONNECT_ACCOUNT_PENDING]: boolean;
|
||||
[OnboardingStepKeys.ONBOARDING_INVITE_TEAM_PENDING]: boolean;
|
||||
[OnboardingStepKeys.ONBOARDING_CREATE_PROFILE_PENDING]: boolean;
|
||||
[OnboardingStepKeys.ONBOARDING_BOOK_ONBOARDING_PENDING]: boolean;
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
@ -62,6 +64,10 @@ export class OnboardingService {
|
||||
const isInviteTeamPending =
|
||||
userVars.get(OnboardingStepKeys.ONBOARDING_INVITE_TEAM_PENDING) === true;
|
||||
|
||||
const isBookOnboardingPending =
|
||||
userVars.get(OnboardingStepKeys.ONBOARDING_BOOK_ONBOARDING_PENDING) ===
|
||||
true;
|
||||
|
||||
if (isProfileCreationPending) {
|
||||
return OnboardingStatus.PROFILE_CREATION;
|
||||
}
|
||||
@ -74,6 +80,10 @@ export class OnboardingService {
|
||||
return OnboardingStatus.INVITE_TEAM;
|
||||
}
|
||||
|
||||
if (isBookOnboardingPending) {
|
||||
return OnboardingStatus.BOOK_ONBOARDING;
|
||||
}
|
||||
|
||||
return OnboardingStatus.COMPLETED;
|
||||
}
|
||||
|
||||
@ -153,4 +163,27 @@ export class OnboardingService {
|
||||
value: true,
|
||||
});
|
||||
}
|
||||
|
||||
async setOnboardingBookOnboardingPending({
|
||||
workspaceId,
|
||||
value,
|
||||
}: {
|
||||
workspaceId: string;
|
||||
value: boolean;
|
||||
}) {
|
||||
if (!value) {
|
||||
await this.userVarsService.delete({
|
||||
workspaceId,
|
||||
key: OnboardingStepKeys.ONBOARDING_BOOK_ONBOARDING_PENDING,
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
await this.userVarsService.set({
|
||||
workspaceId,
|
||||
key: OnboardingStepKeys.ONBOARDING_BOOK_ONBOARDING_PENDING,
|
||||
value: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -630,6 +630,14 @@ export class ConfigVariables {
|
||||
@IsOptional()
|
||||
CHROME_EXTENSION_ID: string;
|
||||
|
||||
@ConfigVariablesMetadata({
|
||||
group: ConfigVariablesGroup.Other,
|
||||
description: 'Page ID for Cal.com booking integration',
|
||||
type: ConfigVariableType.STRING,
|
||||
})
|
||||
@IsOptional()
|
||||
CALENDAR_BOOKING_PAGE_ID?: string;
|
||||
|
||||
@ConfigVariablesMetadata({
|
||||
group: ConfigVariablesGroup.Logging,
|
||||
description: 'Enable or disable buffering for logs before sending',
|
||||
|
||||
@ -70,6 +70,7 @@ describe('WorkspaceInvitationService', () => {
|
||||
provide: OnboardingService,
|
||||
useValue: {
|
||||
setOnboardingInviteTeamPending: jest.fn(),
|
||||
setOnboardingBookOnboardingPending: jest.fn(),
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -181,6 +182,12 @@ describe('WorkspaceInvitationService', () => {
|
||||
workspaceId: workspace.id,
|
||||
value: false,
|
||||
});
|
||||
expect(
|
||||
onboardingService.setOnboardingBookOnboardingPending,
|
||||
).toHaveBeenCalledWith({
|
||||
workspaceId: workspace.id,
|
||||
value: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -324,6 +324,11 @@ export class WorkspaceInvitationService {
|
||||
value: false,
|
||||
});
|
||||
|
||||
await this.onboardingService.setOnboardingBookOnboardingPending({
|
||||
workspaceId: workspace.id,
|
||||
value: true,
|
||||
});
|
||||
|
||||
const result = invitationsPr.reduce<{
|
||||
errors: string[];
|
||||
result: ReturnType<
|
||||
|
||||
Reference in New Issue
Block a user