Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ STRIPE_TEAM_PRODUCT_ID=
# It is a price ID in the product with id STRIPE_ORG_PRODUCT_ID
STRIPE_ORG_MONTHLY_PRICE_ID=
STRIPE_ORG_PRODUCT_ID=
STRIPE_ORG_TRIAL_DAYS=

STRIPE_WEBHOOK_SECRET=
STRIPE_WEBHOOK_SECRET_APPS=
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"use client";

import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Alert } from "@calcom/ui/components/alert";
import { WizardLayout } from "@calcom/ui/components/layout";

interface OrganizationWizardLayoutProps {
children: React.ReactNode;
currentStep: number;
maxSteps?: number;
isOptionalCallback?: () => void;
footer?: React.ReactNode;
}

export function OrganizationWizardLayout({
children,
currentStep,
maxSteps = 5,
isOptionalCallback,
footer,
}: OrganizationWizardLayoutProps) {
const { t } = useLocale();

const defaultFooter = <Alert severity="warning" message={t("organization_trial_workspace_warning")} />;

return (
<WizardLayout
currentStep={currentStep}
maxSteps={maxSteps}
isOptionalCallback={isOptionalCallback}
footer={footer ?? defaultFooter}>
{children}
</WizardLayout>
);
}
9 changes: 3 additions & 6 deletions apps/web/modules/settings/organizations/new/about-view.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
"use client";

import { AboutOrganizationForm } from "@calcom/features/ee/organizations/components";
import { WizardLayout } from "@calcom/ui/components/layout";

import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";

export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
return (
<WizardLayout currentStep={2} maxSteps={5}>
{children}
</WizardLayout>
);
return <OrganizationWizardLayout currentStep={2}>{children}</OrganizationWizardLayout>;
};

export default AboutOrganizationForm;
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
"use client";

import { WizardLayout } from "@calcom/ui/components/layout";

import { AddNewTeamsForm } from "./_components/AddNewTeamsForm";
import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";

export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
return (
<WizardLayout currentStep={3} maxSteps={5}>
{children}
</WizardLayout>
);
return <OrganizationWizardLayout currentStep={3}>{children}</OrganizationWizardLayout>;
};

export default AddNewTeamsForm;
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import { CreateANewOrganizationForm } from "@calcom/features/ee/organizations/components";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Alert } from "@calcom/ui/components/alert";
import { WizardLayout } from "@calcom/ui/components/layout";
import { useGetUserAttributes } from "@calcom/web/components/settings/platform/hooks/useGetUserAttributes";

import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";

export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
const { t } = useLocale();
const { isPlatformUser } = useGetUserAttributes();
Expand All @@ -20,11 +21,7 @@ export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
);
}

return (
<WizardLayout currentStep={1} maxSteps={5}>
{children}
</WizardLayout>
);
return <OrganizationWizardLayout currentStep={1}>{children}</OrganizationWizardLayout>;
};

export default CreateANewOrganizationForm;
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
"use client";

import { WizardLayout } from "@calcom/ui/components/layout";

import AddNewTeamMembers from "./_components/OnboardMembersView";
import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";

export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
return (
<WizardLayout currentStep={4} maxSteps={5}>
{children}
</WizardLayout>
);
return <OrganizationWizardLayout currentStep={4}>{children}</OrganizationWizardLayout>;
};

export default AddNewTeamMembers;
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
"use client";

import { WizardLayout } from "@calcom/ui/components/layout";

import PaymentStatusView from "~/settings/organizations/new/_components/PaymentStatusView";

import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";

export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
return (
<WizardLayout currentStep={5} maxSteps={5}>
{children}
</WizardLayout>
);
return <OrganizationWizardLayout currentStep={5}>{children}</OrganizationWizardLayout>;
};

export default PaymentStatusView;
9 changes: 3 additions & 6 deletions apps/web/modules/settings/organizations/new/resume-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import { useEffect } from "react";
import { useOnboarding } from "@calcom/features/ee/organizations/lib/onboardingStore";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Alert } from "@calcom/ui/components/alert";
import { WizardLayout } from "@calcom/ui/components/layout";
import { SkeletonContainer, SkeletonText } from "@calcom/ui/components/skeleton";

import { OrganizationWizardLayout } from "./_components/OrganizationWizardLayout";

export const LayoutWrapper = ({ children }: { children: React.ReactNode }) => {
return (
<WizardLayout currentStep={1} maxSteps={5}>
{children}
</WizardLayout>
);
return <OrganizationWizardLayout currentStep={1}>{children}</OrganizationWizardLayout>;
};

const ResumeOnboardingView = () => {
Expand Down
1 change: 1 addition & 0 deletions apps/web/public/static/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -2490,6 +2490,7 @@
"currency": "Currency",
"organization_banner_description": "Create an environment where your teams can create shared apps, workflows and event types with round-robin and collective scheduling.",
"organization_banner_title": "Manage organizations with multiple teams",
"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.",
"set_up_your_organization": "Set up your organization",
"set_up_your_platform_organization": "Set up your platform",
"organizations_description": "Organizations are shared environments where teams can create shared event types, apps, workflows and more.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ export class OrganizationPaymentService {
organizationOnboardingId,
})
);

const trialDays = process.env.STRIPE_ORG_TRIAL_DAYS
? parseInt(process.env.STRIPE_ORG_TRIAL_DAYS, 10)
: undefined;

const subscriptionData =
trialDays && !isNaN(trialDays) && trialDays > 0
? {
trial_period_days: trialDays,
}
: undefined;

return this.billingService.createSubscriptionCheckout({
customerId: stripeCustomerId,
successUrl: `${WEBAPP_URL}/settings/organizations/new/status?session_id={CHECKOUT_SESSION_ID}&paymentStatus=success&${params.toString()}`,
Expand All @@ -288,6 +300,7 @@ export class OrganizationPaymentService {
pricePerSeat: config.pricePerSeat,
billingPeriod: config.billingPeriod,
},
...(subscriptionData && { subscriptionData }),
});
}

Expand Down
5 changes: 5 additions & 0 deletions packages/features/ee/teams/lib/payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ export const purchaseTeamOrOrgSubscription = async (input: {
priceId = fixedPrice as string;
}

const orgTrialDays = process.env.STRIPE_ORG_TRIAL_DAYS
? parseInt(process.env.STRIPE_ORG_TRIAL_DAYS)
: null;

const session = await stripe.checkout.sessions.create({
customer,
mode: "subscription",
Expand Down Expand Up @@ -198,6 +202,7 @@ export const purchaseTeamOrOrgSubscription = async (input: {
teamId,
dubCustomerId: userId,
},
...(isOrg && !!orgTrialDays && { trial_period_days: orgTrialDays }),
},
});
return { url: session.url };
Expand Down
6 changes: 4 additions & 2 deletions packages/ui/components/layout/WizardLayout.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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();
Expand Down Expand Up @@ -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 && (
Expand Down
3 changes: 3 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@
"STRIPE_TEAM_MONTHLY_PRICE_ID",
"STRIPE_TEAM_PRODUCT_ID",
"STRIPE_ORG_MONTHLY_PRICE_ID",
"STRIPE_ORG_PRODUCT_ID",
"STRIPE_ORG_TRIAL_DAYS",
"ORG_MONTHLY_CREDITS",
"TANDEM_BASE_URL",
"TANDEM_CLIENT_ID",
Expand Down Expand Up @@ -343,6 +345,7 @@
"ORG_MONTHLY_CREDITS",
"STRIPE_ORG_MONTHLY_PRICE_ID",
"STRIPE_ORG_PRODUCT_ID",
"STRIPE_ORG_TRIAL_DAYS",
"NEXT_PUBLIC_API_V2_URL",
"NEXT_PUBLIC_VAPID_PUBLIC_KEY",
"NEXT_PUBLIC_SENTRY_DSN_CLIENT",
Expand Down
Loading