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]>
This commit is contained in:
15 files changed
+77
-46
No files matched your search
@@ -25,11 +25,8 @@ import { RadioAreaGroup as RadioArea } from "@calcom/ui/components/radio";
|
||||
import { useOnboarding } from "../lib/onboardingStore";
|
||||
|
||||
function extractDomainFromEmail(email: string) {
|
||||
let out = "";
|
||||
try {
|
||||
const match = email.match(/^(?:.*?:\/\/)?.*?([\w\-]*(?:\.\w{2,}|\.\w{2,}\.\w{2}))(?:[\/?#:]|$)/);
|
||||
out = (match && match[1]) ?? "";
|
||||
} catch (ignore) {}
|
||||
const match = email.match(/^(?:.*?:\/\/)?.*?([\w-]*(?:\.\w{2,}|\.\w{2,}\.\w{2}))(?:[/?#:]|$)/);
|
||||
const out = (match && match[1]) ?? "";
|
||||
return out.split(".")[0];
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
ORGANIZATION_SELF_SERVE_MIN_SEATS,
|
||||
ORGANIZATION_SELF_SERVE_PRICE,
|
||||
WEBAPP_URL,
|
||||
ORG_TRIAL_DAYS,
|
||||
} from "@calcom/lib/constants";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
@@ -277,6 +278,13 @@ export class OrganizationPaymentService {
|
||||
organizationOnboardingId,
|
||||
})
|
||||
);
|
||||
|
||||
const subscriptionData = ORG_TRIAL_DAYS
|
||||
? {
|
||||
trial_period_days: ORG_TRIAL_DAYS,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
return this.billingService.createSubscriptionCheckout({
|
||||
customerId: stripeCustomerId,
|
||||
successUrl: `${WEBAPP_URL}/settings/organizations/new/status?session_id={CHECKOUT_SESSION_ID}&paymentStatus=success&${params.toString()}`,
|
||||
@@ -289,6 +297,7 @@ export class OrganizationPaymentService {
|
||||
pricePerSeat: config.pricePerSeat,
|
||||
billingPeriod: config.billingPeriod,
|
||||
},
|
||||
...(subscriptionData && { subscriptionData }),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
ORGANIZATION_SELF_SERVE_MIN_SEATS,
|
||||
ORGANIZATION_SELF_SERVE_PRICE,
|
||||
WEBAPP_URL,
|
||||
ORG_TRIAL_DAYS,
|
||||
} from "@calcom/lib/constants";
|
||||
import logger from "@calcom/lib/logger";
|
||||
import { safeStringify } from "@calcom/lib/safeStringify";
|
||||
@@ -198,6 +199,7 @@ export const purchaseTeamOrOrgSubscription = async (input: {
|
||||
teamId,
|
||||
dubCustomerId: userId,
|
||||
},
|
||||
...(isOrg && ORG_TRIAL_DAYS && { trial_period_days: ORG_TRIAL_DAYS }),
|
||||
},
|
||||
});
|
||||
return { url: session.url };
|
||||
|
||||
@@ -254,3 +254,7 @@ export const RETELL_AI_TEST_EVENT_TYPE_MAP = (() => {
|
||||
/* This is an internal environment variable and is not meant to be used by the self-hosters. It is planned to be removed later by either having it as an option in Event Type or by some other customer configurable approaches*/
|
||||
export const ENV_PAST_BOOKING_RESCHEDULE_CHANGE_TEAM_IDS =
|
||||
process.env._CAL_INTERNAL_PAST_BOOKING_RESCHEDULE_CHANGE_TEAM_IDS;
|
||||
|
||||
export const ORG_TRIAL_DAYS = process.env.STRIPE_ORG_TRIAL_DAYS
|
||||
? Math.max(0, parseInt(process.env.STRIPE_ORG_TRIAL_DAYS, 10))
|
||||
: null;
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
|
||||
import { usePathname } from "next/navigation";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Toaster } from "sonner";
|
||||
@@ -18,9 +18,10 @@ export function WizardLayout({
|
||||
maxSteps = 2,
|
||||
currentStep = 0,
|
||||
isOptionalCallback,
|
||||
footer,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
} & { maxSteps?: number; currentStep?: number; isOptionalCallback?: () => void }) {
|
||||
} & { maxSteps?: number; currentStep?: number; isOptionalCallback?: () => void; footer?: React.ReactNode }) {
|
||||
const { t, isLocaleReady } = useLocale();
|
||||
const [meta, setMeta] = useState({ title: "", subtitle: " " });
|
||||
const pathname = usePathname();
|
||||
@@ -60,6 +61,7 @@ export function WizardLayout({
|
||||
<Steps maxSteps={maxSteps} currentStep={currentStep} disableNavigation />
|
||||
</div>
|
||||
<StepCard>{children}</StepCard>
|
||||
{footer && <div className="mt-4">{footer}</div>}
|
||||
</div>
|
||||
</div>
|
||||
{isOptionalCallback && (
|
||||
|
||||
Reference in new issue
Block a user