feat: Onboarding V3 (#24299)

* feat: redirect to new onboarding flow

* Getting started

* Brand details

* Preview organization brands

* Orgs team pages

* Invite team steps

* Move to global zustand store

* Few darkmdoe fixes

* Wip onboarding + stripe flow

* Default plan state

Server Action for gettting slug satus of org

* Remove onboardingId

* Confirmation prompt

* Update old onboarding flow handlers to handle new fields

* update onboarding hook

* Filter out organization section for none -company emails

* Match placeholders to users domain

* Drop migration

* Wip new onboarding intent

* WIP flow for self-hosted. Same service call just split logic

* WIP

* Add TODO

* Use onboarding user type instead of trpc session

* WIP

* WIP

* pass role and team name from onboarding to save in schema

* Add test to ensure role + name + team are persisted into onboarding table

* migrate roles to enum values

* Update ENUM

* Fix type error

* Redirect if flag is disabled

* Revert packages

* Revert all packages/* changes to original branch point

* Layout fixes + design

* Add slugify

* Support saving brand,logo and banner

* Cleanup

* iMobile fixes

* More mobile and darkmdoe fixes

* Add I18n

* Fix lock file

* Fix types

* Fix types errors

* Copy changes
This commit is contained in:
sean-brydon authored and GitHub committed 2025-10-23 20:01:54 +01:00
1 parent fcd9480f9f
commit 8e0cdf3671
25 files changed
+1871 -12

No files matched your search

@@ -191,14 +191,9 @@ export async function assertCanCreateOrg({
"email-verification"
);
const verifiedUser =
orgOwner.completedOnboarding && (emailVerificationEnabled ? !!orgOwner.emailVerified : true);
const verifiedUser = emailVerificationEnabled ? !!orgOwner.emailVerified : true;
if (!verifiedUser) {
log.warn(
"you_need_to_complete_user_onboarding_before_creating_an_organization",
safeStringify({ userId: orgOwner.id })
);
throw new OrgCreationError("you_need_to_complete_user_onboarding_before_creating_an_organization");
throw new OrgCreationError("you_need_to_verify_your_email_before_creating_an_organization");
}
if (isNotACompanyEmail(orgOwner.email) && !isPlatform) {
@@ -810,5 +810,59 @@ describe("BillingEnabledOrgOnboardingService", () => {
})
);
});
it("should transfer branding data (logo, brandColor, bannerUrl) from onboarding to organization", async () => {
vi.spyOn(constants, "IS_SELF_HOSTED", "get").mockReturnValue(false);
const onboardingWithBranding = await createTestOnboarding({
logo: "https://example.com/logo.png",
bio: "Test organization bio",
brandColor: "#FF5733",
bannerUrl: "https://example.com/banner.jpg",
});
await createTestUser({
email: onboardingWithBranding.orgOwnerEmail,
onboardingCompleted: true,
emailVerified: new Date(),
});
const { organization } = await service.createOrganization(onboardingWithBranding, {
subscriptionId: "sub_123",
subscriptionItemId: "si_123",
});
expect(organization.logoUrl).toBe("https://example.com/logo.png");
expect(organization.bio).toBe("Test organization bio");
expect(organization.brandColor).toBe("#FF5733");
expect(organization.bannerUrl).toBe("https://example.com/banner.jpg");
});
it("should handle null branding data correctly", async () => {
vi.spyOn(constants, "IS_SELF_HOSTED", "get").mockReturnValue(false);
const onboardingWithNullBranding = await createTestOnboarding({
logo: null,
bio: null,
brandColor: null,
bannerUrl: null,
});
await createTestUser({
email: onboardingWithNullBranding.orgOwnerEmail,
onboardingCompleted: true,
emailVerified: new Date(),
});
const { organization } = await service.createOrganization(onboardingWithNullBranding, {
subscriptionId: "sub_123",
subscriptionItemId: "si_123",
});
expect(organization.logoUrl).toBeNull();
expect(organization.bio).toBeNull();
expect(organization.brandColor).toBeNull();
expect(organization.bannerUrl).toBeNull();
});
});
});
@@ -1,8 +1,8 @@
export function extractDomainFromEmail(email: string) {
let out = "";
try {
const match = email.match(/^(?:.*?:\/\/)?.*?(?<root>[\w\-]*(?:\.\w{2,}|\.\w{2,}\.\w{2}))(?:[\/?#:]|$)/);
out = (match && match.groups?.root) ?? "";
const match = email.match(/^(?:.*?:\/\/)?.*?([\w\-]*(?:\.\w{2,}|\.\w{2,}\.\w{2}))(?:[\/?#:]|$)/);
out = (match && match[1]) ?? "";
} catch (ignore) {}
return out.split(".")[0];
}
@@ -150,3 +150,64 @@ describe("Organization.getVerifiedOrganizationByAutoAcceptEmailDomain", () => {
expect(result).toEqual(null);
});
});
describe("Organization.create", () => {
it("should create organization with branding data (logoUrl, brandColor, bannerUrl)", async () => {
const orgData = {
name: "Test Organization",
slug: "test-org",
isOrganizationConfigured: true,
isOrganizationAdminReviewed: true,
autoAcceptEmail: "test.com",
seats: 10,
pricePerSeat: 15,
isPlatform: false,
billingPeriod: "MONTHLY" as const,
logoUrl: "https://example.com/logo.png",
bio: "Test organization bio",
brandColor: "#FF5733",
bannerUrl: "https://example.com/banner.jpg",
};
const organization = await OrganizationRepository.create(orgData);
expect(organization).toMatchObject({
name: "Test Organization",
slug: "test-org",
isOrganization: true,
logoUrl: "https://example.com/logo.png",
bio: "Test organization bio",
brandColor: "#FF5733",
bannerUrl: "https://example.com/banner.jpg",
});
});
it("should create organization with null branding data", async () => {
const orgData = {
name: "Test Organization",
slug: "test-org-2",
isOrganizationConfigured: true,
isOrganizationAdminReviewed: true,
autoAcceptEmail: "test.com",
seats: null,
pricePerSeat: null,
isPlatform: false,
logoUrl: null,
bio: null,
brandColor: null,
bannerUrl: null,
};
const organization = await OrganizationRepository.create(orgData);
expect(organization).toMatchObject({
name: "Test Organization",
slug: "test-org-2",
isOrganization: true,
logoUrl: null,
bio: null,
brandColor: null,
bannerUrl: null,
});
});
});
@@ -36,6 +36,8 @@ export class OrganizationRepository {
billingPeriod?: "MONTHLY" | "ANNUALLY";
logoUrl: string | null;
bio: string | null;
brandColor: string | null;
bannerUrl: string | null;
requestedSlug?: string | null;
};
owner: {
@@ -84,6 +86,8 @@ export class OrganizationRepository {
isPlatform: boolean;
logoUrl: string | null;
bio: string | null;
brandColor: string | null;
bannerUrl: string | null;
};
owner: {
email: string;
@@ -133,6 +137,8 @@ export class OrganizationRepository {
isPlatform: boolean;
logoUrl: string | null;
bio: string | null;
brandColor: string | null;
bannerUrl: string | null;
requestedSlug?: string | null;
}) {
return await prisma.team.create({
@@ -140,9 +146,10 @@ export class OrganizationRepository {
name: orgData.name,
isOrganization: true,
slug: orgData.slug,
// This is huge and causes issues, we need to have the logic to convert logo to logoUrl and then use that url ehre.
// logoUrl: orgData.logoUrl,
logoUrl: orgData.logoUrl,
bio: orgData.bio,
brandColor: orgData.brandColor,
bannerUrl: orgData.bannerUrl,
organizationSettings: {
create: {
isAdminReviewed: orgData.isOrganizationAdminReviewed,