Skip to content

Commit dc3df12

Browse files
joeauyeungdevin-ai-integration[bot]Udit-takkar
authored
feat: Add configurable trial days to org subscriptions + wizard warning (#25229)
* feat: Add trial days to organization subscriptions and workspace warning - Add ORGANIZATION_TRIAL_DAYS environment variable for configurable trial periods - Implement trial days in Stripe checkout session (only when env var is set) - Add warning message to organization setup page about workspace structure - Add translation string for organization trial workspace warning - Add ORGANIZATION_TRIAL_DAYS to turbo.json env vars - Fix pre-existing linting warnings in CreateANewOrganizationForm.tsx - Add ESLint disable comments for turbo/no-undeclared-env-vars warnings Co-Authored-By: [email protected] <[email protected]> * Rename variable * Add trial days to `purchaseTeamOrOrgSubscription` * fix: Move organization trial warning to spot 3 below form card - Add optional footer prop to WizardLayout component - Use footer prop in create-new-view.tsx to render warning at spot 3 - Remove warning from inside CreateANewOrganizationForm component - Warning now appears below the form card as requested Co-Authored-By: [email protected] <[email protected]> * feat: Add organization trial warning to all wizard steps - Add warning footer to step 2 (about-view.tsx) - Add warning footer to step 3 (add-teams-view.tsx) - Add warning footer to step 4 (onboard-members-view.tsx) - Add warning footer to step 5 (payment-status-view.tsx) - Add warning footer to resume-view.tsx (step 1 resume page) - Warning now appears on all steps of the organization creation wizard Co-Authored-By: [email protected] <[email protected]> * fix: Correct environment variable name to STRIPE_ORG_TRIAL_DAYS - Changed ORGANIZATION_TRIAL_DAYS to STRIPE_ORG_TRIAL_DAYS in turbo.json - This matches the actual usage in OrganizationPaymentService.ts and payments.ts - Ensures the environment variable is properly recognized by the build system Co-Authored-By: [email protected] <[email protected]> * refactor: Create shared OrganizationWizardLayout component - Create OrganizationWizardLayout component that wraps WizardLayout - Centralizes the trial warning footer logic in one place - Update all 6 wizard pages to use the shared component: - create-new-view.tsx - about-view.tsx - add-teams-view.tsx - onboard-members-view.tsx - payment-status-view.tsx - resume-view.tsx - Remove duplicate useLocale/Alert imports and footer props from pages - Simplifies maintenance by having warning logic in a single location Co-Authored-By: [email protected] <[email protected]> * Fix lint error * Add `ORG_TRIAL_DAYS` as constant * Add comment * Ensure no negative number is passed --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Udit Takkar <[email protected]>
1 parent 176fb77 commit dc3df12

File tree

15 files changed

+77
-46
lines changed

15 files changed

+77
-46
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ STRIPE_TEAM_PRODUCT_ID=
214214
# It is a price ID in the product with id STRIPE_ORG_PRODUCT_ID
215215
STRIPE_ORG_MONTHLY_PRICE_ID=
216216
STRIPE_ORG_PRODUCT_ID=
217+
# Used to pass trial days for orgs during the Stripe checkout session
218+
STRIPE_ORG_TRIAL_DAYS=
217219

218220
STRIPE_WEBHOOK_SECRET=
219221
STRIPE_WEBHOOK_SECRET_APPS=
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"use client";
2+
3+
import { useLocale } from "@calcom/lib/hooks/useLocale";
4+
import { Alert } from "@calcom/ui/components/alert";
5+
import { WizardLayout } from "@calcom/ui/components/layout";
6+
7+
interface OrganizationWizardLayoutProps {
8+
children: React.ReactNode;
9+
currentStep: number;
10+
maxSteps?: number;
11+
isOptionalCallback?: () => void;
12+
footer?: React.ReactNode;
13+
}
14+
15+
export function OrganizationWizardLayout({
16+
children,
17+
currentStep,
18+
maxSteps = 5,
19+
isOptionalCallback,
20+
footer,
21+
}: OrganizationWizardLayoutProps) {
22+
const { t } = useLocale();
23+
24+
const defaultFooter = <Alert severity="warning" message={t("organization_trial_workspace_warning")} />;
25+
26+
return (
27+
<WizardLayout
28+
currentStep={currentStep}
29+
maxSteps={maxSteps}
30+
isOptionalCallback={isOptionalCallback}
31+
footer={footer ?? defaultFooter}>
32+
{children}
33+
</WizardLayout>
34+
);
35+
}
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
"use client";
22

33
import { AboutOrganizationForm } from "@calcom/features/ee/organizations/components";
4-
import { WizardLayout } from "@calcom/ui/components/layout";
4+
5+
import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";
56

67
export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
7-
return (
8-
<WizardLayout currentStep={2} maxSteps={5}>
9-
{children}
10-
</WizardLayout>
11-
);
8+
return <OrganizationWizardLayout currentStep={2}>{children}</OrganizationWizardLayout>;
129
};
1310

1411
export default AboutOrganizationForm;
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
"use client";
22

3-
import { WizardLayout } from "@calcom/ui/components/layout";
4-
53
import { AddNewTeamsForm } from "./_components/AddNewTeamsForm";
4+
import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";
65

76
export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
8-
return (
9-
<WizardLayout currentStep={3} maxSteps={5}>
10-
{children}
11-
</WizardLayout>
12-
);
7+
return <OrganizationWizardLayout currentStep={3}>{children}</OrganizationWizardLayout>;
138
};
149

1510
export default AddNewTeamsForm;

apps/web/modules/settings/organizations/new/create-new-view.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
import { CreateANewOrganizationForm } from "@calcom/features/ee/organizations/components";
44
import { useLocale } from "@calcom/lib/hooks/useLocale";
55
import { Alert } from "@calcom/ui/components/alert";
6-
import { WizardLayout } from "@calcom/ui/components/layout";
76
import { useGetUserAttributes } from "@calcom/web/components/settings/platform/hooks/useGetUserAttributes";
87

8+
import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";
9+
910
export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
1011
const { t } = useLocale();
1112
const { isPlatformUser } = useGetUserAttributes();
@@ -20,11 +21,7 @@ export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
2021
);
2122
}
2223

23-
return (
24-
<WizardLayout currentStep={1} maxSteps={5}>
25-
{children}
26-
</WizardLayout>
27-
);
24+
return <OrganizationWizardLayout currentStep={1}>{children}</OrganizationWizardLayout>;
2825
};
2926

3027
export default CreateANewOrganizationForm;
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
"use client";
22

3-
import { WizardLayout } from "@calcom/ui/components/layout";
4-
53
import AddNewTeamMembers from "./_components/OnboardMembersView";
4+
import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";
65

76
export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
8-
return (
9-
<WizardLayout currentStep={4} maxSteps={5}>
10-
{children}
11-
</WizardLayout>
12-
);
7+
return <OrganizationWizardLayout currentStep={4}>{children}</OrganizationWizardLayout>;
138
};
149

1510
export default AddNewTeamMembers;
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
"use client";
22

3-
import { WizardLayout } from "@calcom/ui/components/layout";
4-
53
import PaymentStatusView from "~/settings/organizations/new/_components/PaymentStatusView";
64

5+
import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";
6+
77
export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
8-
return (
9-
<WizardLayout currentStep={5} maxSteps={5}>
10-
{children}
11-
</WizardLayout>
12-
);
8+
return <OrganizationWizardLayout currentStep={5}>{children}</OrganizationWizardLayout>;
139
};
1410

1511
export default PaymentStatusView;

apps/web/modules/settings/organizations/new/resume-view.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ import { useEffect } from "react";
66
import { useOnboarding } from "@calcom/features/ee/organizations/lib/onboardingStore";
77
import { useLocale } from "@calcom/lib/hooks/useLocale";
88
import { Alert } from "@calcom/ui/components/alert";
9-
import { WizardLayout } from "@calcom/ui/components/layout";
109
import { SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";
1110

11+
import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";
12+
1213
export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
13-
return (
14-
<WizardLayout currentStep={1} maxSteps={5}>
15-
{children}
16-
</WizardLayout>
17-
);
14+
return <OrganizationWizardLayout currentStep={1}>{children}</OrganizationWizardLayout>;
1815
};
1916

2017
const ResumeOnboardingView = () => {

apps/web/public/static/locales/en/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2501,6 +2501,7 @@
25012501
"currency": "Currency",
25022502
"organization_banner_description": "Create an environment where your teams can create shared apps, workflows and event types with round-robin and collective scheduling.",
25032503
"organization_banner_title": "Manage organizations with multiple teams",
2504+
"organization_trial_workspace_warning": "This trial uses the Organizations workspace structure. Your current data will move with you into Organizations, but it won't transfer back if you switch to Teams later. If you prefer Teams again in the future, you can create a new team.",
25042505
"set_up_your_organization": "Set up your organization",
25052506
"set_up_your_platform_organization": "Set up your platform",
25062507
"organizations_description": "Organizations are shared environments where teams can create shared event types, apps, workflows and more.",

packages/features/ee/organizations/components/CreateANewOrganizationForm.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@ import { RadioAreaGroup as RadioArea } from "@calcom/ui/components/radio";
2525
import { useOnboarding } from "../lib/onboardingStore";
2626

2727
function extractDomainFromEmail(email: string) {
28-
let out = "";
29-
try {
30-
const match = email.match(/^(?:.*?:\/\/)?.*?([\w\-]*(?:\.\w{2,}|\.\w{2,}\.\w{2}))(?:[\/?#:]|$)/);
31-
out = (match && match[1]) ?? "";
32-
} catch (ignore) {}
28+
const match = email.match(/^(?:.*?:\/\/)?.*?([\w-]*(?:\.\w{2,}|\.\w{2,}\.\w{2}))(?:[/?#:]|$)/);
29+
const out = (match && match[1]) ?? "";
3330
return out.split(".")[0];
3431
}
3532

0 commit comments

Comments
 (0)