chore: Onboarding path service plus redirects (#24679)
* i18n * WIP icon stuff * More icon work * More gradient tuning * Mvoe plan-icon to planicon.tsx * Fix cubic suggestion * Fix darkmode icon and gradients * Fix type error * Onboarding path service * Update usages of onboarding path and getting started hook
This commit is contained in:
1 parent
3418a25a85
commit
fa884e8516
10 files changed
+72
-16
No files matched your search
@@ -42,9 +42,10 @@ export function useRedirectToOnboardingIfNeeded() {
|
||||
|
||||
useEffect(() => {
|
||||
if (canRedirect) {
|
||||
router.replace("/getting-started");
|
||||
const gettingStartedPath = flags["onboarding-v3"] ? "/onboarding/getting-started" : "/getting-started";
|
||||
router.replace(gettingStartedPath);
|
||||
}
|
||||
}, [canRedirect, router]);
|
||||
}, [canRedirect, router, flags]);
|
||||
|
||||
return {
|
||||
isLoading,
|
||||
|
||||
@@ -7,6 +7,7 @@ import { TeamRepository } from "@calcom/features/ee/teams/repositories/TeamRepos
|
||||
import { WorkflowService } from "@calcom/features/ee/workflows/lib/service/WorkflowService";
|
||||
import { createAProfileForAnExistingUser } from "@calcom/features/profile/lib/createAProfileForAnExistingUser";
|
||||
import { ProfileRepository } from "@calcom/features/profile/repositories/ProfileRepository";
|
||||
import { OnboardingPathService } from "@calcom/features/onboarding/lib/onboarding-path.service";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { deleteDomain } from "@calcom/lib/domainManager/organization";
|
||||
import logger from "@calcom/lib/logger";
|
||||
@@ -76,7 +77,7 @@ export class TeamService {
|
||||
if (!existingToken) throw new TRPCError({ code: "NOT_FOUND", message: "Invite token not found" });
|
||||
return {
|
||||
token: existingToken.token,
|
||||
inviteLink: TeamService.buildInviteLink(existingToken.token, isOrganizationOrATeamInOrganization),
|
||||
inviteLink: await TeamService.buildInviteLink(existingToken.token, isOrganizationOrATeamInOrganization),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -93,14 +94,18 @@ export class TeamService {
|
||||
|
||||
return {
|
||||
token,
|
||||
inviteLink: TeamService.buildInviteLink(token, isOrganizationOrATeamInOrganization),
|
||||
inviteLink: await TeamService.buildInviteLink(token, isOrganizationOrATeamInOrganization),
|
||||
};
|
||||
}
|
||||
|
||||
private static buildInviteLink(token: string, isOrgContext: boolean): string {
|
||||
private static async buildInviteLink(token: string, isOrgContext: boolean): Promise<string> {
|
||||
const teamInviteLink = `${WEBAPP_URL}/teams?token=${token}`;
|
||||
const orgInviteLink = `${WEBAPP_URL}/signup?token=${token}&callbackUrl=/getting-started`;
|
||||
return isOrgContext ? orgInviteLink : teamInviteLink;
|
||||
if (!isOrgContext) {
|
||||
return teamInviteLink;
|
||||
}
|
||||
const gettingStartedPath = await OnboardingPathService.getGettingStartedPath(prisma);
|
||||
const orgInviteLink = `${WEBAPP_URL}/signup?token=${token}&callbackUrl=${gettingStartedPath}`;
|
||||
return orgInviteLink;
|
||||
}
|
||||
/**
|
||||
* Deletes a team and all its associated data in a safe, transactional order.
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
|
||||
export class OnboardingPathService {
|
||||
static async getGettingStartedPath(prisma: PrismaClient): Promise<string> {
|
||||
const featuresRepository = new FeaturesRepository(prisma);
|
||||
const onboardingV3Enabled = await featuresRepository.checkIfFeatureIsEnabledGlobally("onboarding-v3");
|
||||
return onboardingV3Enabled ? "/onboarding/getting-started" : "/getting-started";
|
||||
}
|
||||
|
||||
static async getGettingStartedPathWithParams(
|
||||
prisma: PrismaClient,
|
||||
queryParams?: Record<string, string>
|
||||
): Promise<string> {
|
||||
const basePath = await OnboardingPathService.getGettingStartedPath(prisma);
|
||||
|
||||
if (!queryParams || Object.keys(queryParams).length === 0) {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
const params = new URLSearchParams(queryParams);
|
||||
return `${basePath}?${params.toString()}`;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user