Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(frontend): integrate onboarding trial into plan cards (#14768)

Toran Bruce Richards45275cbb0bb3
diff --git a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/page.tsx b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/page.tsx
index 599d0206b5..8c99aebc12 100644
--- a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/page.tsx
+++ b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/page.tsx
@@ -15,6 +15,7 @@ import { ArrowLeft01Icon, Logout03Icon } from "@hugeicons/core-free-icons";
import { Button } from "@/components/atoms/Button/Button";
import { Text } from "@/components/atoms/Text/Text";
import { ErrorCard } from "@/components/molecules/ErrorCard/ErrorCard";
+import { cn } from "@/lib/utils";
export default function OnboardingPage() {
const {
@@ -78,7 +79,14 @@ export default function OnboardingPage() {
</Button>
)}
- <div className="flex w-full min-w-0 flex-1 items-center justify-center pb-8 pt-16">
+ <div
+ className={cn(
+ "flex w-full min-w-0 flex-1 items-center justify-center",
+ currentStep === steps.subscription
+ ? "pb-8 pt-3 lg:pb-2"
+ : "pb-8 pt-16",
+ )}
+ >
{currentStep === steps.team && <IntroStep slide="team" />}
{currentStep === steps.autopilot && <IntroStep slide="autopilot" />}
{currentStep === steps.role && <RoleStep />}
@@ -100,7 +108,11 @@ export default function OnboardingPage() {
</div>
{showDots && (
- <div className="pb-8">
+ <div
+ className={
+ currentStep === steps.subscription ? "pb-8 lg:pb-4" : "pb-8"
+ }
+ >
<StepIndicator totalSteps={totalSteps} currentStep={currentStep} />
</div>
)}
diff --git a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/SubscriptionStep/SubscriptionStep.tsx b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/SubscriptionStep/SubscriptionStep.tsx
index 8680bbac4c..b95ec5f1ab 100644
--- a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/SubscriptionStep/SubscriptionStep.tsx
+++ b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/SubscriptionStep/SubscriptionStep.tsx
@@ -1,121 +1,46 @@
"use client";
-import { AutoGPTLogo } from "@/components/atoms/AutoGPTLogo/AutoGPTLogo";
import { FadeIn } from "@/components/atoms/FadeIn/FadeIn";
-import { Text } from "@/components/atoms/Text/Text";
-import { cn } from "@/lib/utils";
-import { PlanCard } from "@/components/molecules/PlanCard/PlanCard";
-import { PLAN_KEYS } from "@/components/molecules/PlanCard/plans";
+import { supportsTrialPlan } from "@/components/organisms/SubscriptionPlans/helpers";
+import { SubscriptionPlans } from "@/components/organisms/SubscriptionPlans/SubscriptionPlans";
+import { TrialCardContent } from "@/components/organisms/TrialCard/TrialCard";
+import { useTrialCard } from "@/components/organisms/TrialCard/useTrialCard";
import { useSubscriptionStep } from "./useSubscriptionStep";
-import { TrialCard } from "@/components/organisms/TrialCard/TrialCard";
export function SubscriptionStep() {
- const {
- billing,
- setBilling,
- plans,
- country,
- isYearly,
- handlePlanSelect,
- isUpdatingTier,
- selectedPlan,
- } = useSubscriptionStep();
+ const subscription = useSubscriptionStep();
+ const trial = useTrialCard("onboarding");
+ const offer =
+ !trial.isLoading &&
+ !trial.queryError &&
+ trial.trial?.eligible &&
+ !trial.trial.converted &&
+ trial.trial.offer &&
+ supportsTrialPlan(trial.trial.offer.tier) &&
+ subscription.plans.some((plan) => plan.key === trial.trial?.offer?.tier)
+ ? trial.trial.offer
+ : null;
return (
- <FadeIn>
- <div className="-mt-[2rem] flex w-full flex-col items-center gap-4 px-4">
- <AutoGPTLogo
- className="relative right-[1.5rem] h-10 w-[6.5rem]"
- hideText
- />
-
- <div className="flex flex-col items-center gap-1 text-center">
- <Text
- variant="h3"
- className="!text-[1.375rem] !leading-[1.6rem] md:!text-[1.75rem] md:!leading-[2.5rem]"
- >
- Choose the plan that&apos;s right for{" "}
- <span className="bg-gradient-to-r from-purple-500 to-indigo-500 bg-clip-text text-transparent">
- you
- </span>
- </Text>
- <Text variant="body" className="!text-zinc-500">
- Upgrade, downgrade, or change plans anytime. All plans include core
- features to get you started.
- </Text>
- </div>
-
- <div className="w-full max-w-3xl">
- <TrialCard returnTo="onboarding" />
- </div>
- <div className="mt-6 flex w-full flex-col items-center gap-3">
- <div className="inline-flex rounded-full border border-[#d8d8d8] bg-zinc-100 p-[3px]">
- {(["monthly", "yearly"] as const).map((cycle) => (
- <button
- key={cycle}
- type="button"
- onClick={() => setBilling(cycle)}
- // Read by DataFast's script directly (delegated click listener on
- // document), the same way the marketing site tags its CTAs — no
- // JS needed. The `-cycle` suffix becomes the `cycle` metadata key.
- data-fast-goal="paywall_billing_toggle"
- data-fast-goal-cycle={cycle}
- data-fast-goal-surface="onboarding_paywall"
- className={cn(
- "rounded-full border-none px-4 py-1.5 text-xs font-medium transition-all",
- billing === cycle
- ? "bg-white text-zinc-900 shadow-sm"
- : "bg-transparent text-zinc-500 hover:text-zinc-700",
- )}
- >
- {cycle === "monthly" ? (
- "Monthly billing"
- ) : (
- <>
- Yearly billing{" "}
- <span className="ml-1.5 bg-gradient-to-r from-green-500 via-emerald-500 to-teal-500 bg-clip-text text-[11px] font-semibold text-transparent">
- Save 15%
- </span>
- </>
- )}
- </button>
- ))}
- </div>
-
- <div className="relative w-full max-w-[75.625rem]">
- <div className="grid w-full grid-cols-1 gap-4 px-[1rem] md:grid-cols-3 md:px-0">
- {plans.map((plan) => (
- <PlanCard
- key={plan.key}
- plan={plan}
- country={country}
- isYearly={isYearly}
- onSelect={handlePlanSelect}
- loading={isUpdatingTier && selectedPlan === plan.key}
- disabled={isUpdatingTier && selectedPlan !== plan.key}
- priceCaption="billing-period"
- ctaGoalSurface="onboarding_paywall"
- className={cn(
- plan.key === PLAN_KEYS.MAX && "order-1 md:order-none",
- plan.key === PLAN_KEYS.PRO && "order-2 md:order-none",
- plan.key === PLAN_KEYS.TEAM && "order-3 md:order-none",
- )}
- />
- ))}
- </div>
- </div>
- </div>
-
- <Text variant="body" className="!text-zinc-500">
- Need something custom?{" "}
- <a
- href="mailto:[email protected]"
- className="font-medium text-purple-500 no-underline hover:text-purple-600"
- >
- Talk to sales.
- </a>
- </Text>
- </div>
+ <FadeIn className="w-full">
+ <SubscriptionPlans
+ plans={subscription.plans}
+ country={subscription.country}
+ billing={subscription.billing}
+ onBillingChange={subscription.setBilling}
+ onSelectPlan={subscription.handlePlanSelect}
+ isUpdatingTier={subscription.isUpdatingTier}
+ selectedPlan={subscription.selectedPlan}
+ trialOffer={offer}
+ onStartTrial={trial.startTrial}
+ isStartingTrial={trial.isStarting}
+ trialError={trial.error}
+ trialStatus={
+ !offer && (
+ <TrialCardContent returnTo="onboarding" controller={trial} />
+ )
+ }
+ />
</FadeIn>
);
}
diff --git a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/__tests__/SubscriptionStep.trial.test.tsx b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/__tests__/SubscriptionStep.trial.test.tsx
new file mode 100644
index 0000000000..f8e59a64d0
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/__tests__/SubscriptionStep.trial.test.tsx
@@ -0,0 +1,297 @@
+import {
+ getGetTrialsGetTrialStatusMockHandler200,
+ getPostTrialsCancelTrialMockHandler200,
+ getPostTrialsStartTrialCheckoutMockHandler200,
+} from "@/app/api/__generated__/endpoints/trials/trials.msw";
+import { server } from "@/mocks/mock-server";
+import { environment } from "@/services/environment";
+import {
+ installGtagShim,
+ removeGtagShim,
+} from "@/tests/integrations/gtag-shim";
+import {
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+ within,
+} from "@/tests/integrations/test-utils";
+import {
+ setTrialUser,
+ trialOffer,
+ trialResponse,
+} from "@/tests/integrations/trial-fixtures";
+import { http, HttpResponse } from "msw";
+import { afterEach, beforeEach, expect, test, vi } from "vitest";
+import { useOnboardingWizardStore } from "../../store";
+import { SubscriptionStep } from "../SubscriptionStep/SubscriptionStep";
+
+const posthog = vi.hoisted(() => ({ capture: vi.fn() }));
+vi.mock("@posthog/react", () => ({
+ useFeatureFlagVariantKey: () => undefined,
+ usePostHog: () => posthog,
+}));
+
+const originalLocation = window.location;
+let checkoutLocation = {
+ origin: "http://localhost",
+ href: "http://localhost/",
+ assign: vi.fn(),
+};
+
+beforeEach(() => {
+ setTrialUser();
+ posthog.capture.mockClear();
+ useOnboardingWizardStore.getState().reset();
+ useOnboardingWizardStore.getState().goToStep(3);
+ vi.spyOn(environment, "isLocal").mockReturnValue(false);
+ checkoutLocation = {
+ origin: "http://localhost",
+ href: "http://localhost/",
+ assign: vi.fn(),
+ };
+ Object.defineProperty(window, "location", {
+ configurable: true,
+ writable: true,
+ value: checkoutLocation,
+ });
+});
+
+afterEach(() => {
+ setTrialUser(null);
+ Object.defineProperty(window, "location", {
+ configurable: true,
+ writable: true,
+ value: originalLocation,
+ });
+ removeGtagShim();
+ vi.unstubAllEnvs();
+ vi.restoreAllMocks();
+});
+
+function eligible(offer = trialOffer) {
+ return trialResponse({ eligible: true, active: false, status: null, offer });
+}
+
+function mockStatus(response = eligible()) {
+ server.use(getGetTrialsGetTrialStatusMockHandler200(response));
+}
+
+test.each([
+ ["PRO", "Pro"],
+ ["MAX", "Max"],
+] as const)(
+ "starts the integrated %s trial with the accepted token and onboarding destination",
+ async (tier, name) => {
+ mockStatus(eligible({ ...trialOffer, tier }));
+ const requestBody = vi.fn();
+ server.use(
+ getPostTrialsStartTrialCheckoutMockHandler200(async ({ request }) => {
+ requestBody(await request.json());
+ return { url: "https://checkout.stripe.com/trial" };
+ }),
+ );
+ render(<SubscriptionStep />);
+ const card = within(
+ await screen.findByRole("region", { name: `${name} plan` }),
+ );
+ const start = await card.findByRole("button", {
+ name: "Start 7-day trial",
+ });
+ expect(start.getAttribute("data-fast-goal")).not.toBe("plan_cta_click");
+ fireEvent.click(start);
+ await waitFor(() =>
+ expect(checkoutLocation.assign).toHaveBeenCalledWith(
+ "https://checkout.stripe.com/trial",
+ ),
+ );
+ expect(requestBody).toHaveBeenCalledExactlyOnceWith({
+ offer_token: trialOffer.token,
+ return_to: "onboarding",
+ });
+ expect(posthog.capture).toHaveBeenCalledWith(
+ "subscription_trial_checkout_started",
+ { trial_offer_version: trialOffer.version, surface: "onboarding" },
+ );
+ expect(useOnboardingWizardStore.getState().selectedPlan).toBeNull();
+ },
+);
+
+test("uses the server's duration, currency, renewal cycle, and terms", async () => {
+ mockStatus(
+ eligible({
+ ...trialOffer,
+ tier: "MAX",
+ duration_days: 14,
+ currency: "jpy",
+ unit_amount: 1234,
+ billing_cycle: "yearly",
+ }),
+ );
+ useOnboardingWizardStore.getState().setSelectedBilling("yearly");
+ render(<SubscriptionStep />);
+ const max = within(await screen.findByRole("region", { name: "Max plan" }));
+ await max.findByRole("button", { name: "Start 14-day trial" });
+ expect(max.getByText("¥1,234")).toBeDefined();
+ expect(max.getByText("/ year")).toBeDefined();
+ fireEvent.click(max.getByRole("button", { name: "Trial details" }));
+ const details = (await screen.findByRole("dialog")).textContent ?? "";
+ expect(details).toMatch(/14/);
+ expect(details).toMatch(/¥1,234\s*\/\s*year/);
+ expect(details).toMatch(/card required/i);
+ expect(details).toMatch(/applicable tax/i);
+ expect(details).toMatch(/cancel/i);
+});
+
+test("refreshes a rejected offer and submits its new token on retry", async () => {
+ let rejected = false;
+ const requestBody = vi.fn();
+ server.use(
+ getGetTrialsGetTrialStatusMockHandler200(() =>
+ eligible(
+ rejected
+ ? { ...trialOffer, token: "b".repeat(64), duration_days: 10 }
+ : trialOffer,
+ ),
+ ),
+ http.post("*/api/credits/trial", async ({ request }) => {
+ requestBody(await request.json());
+ if (rejected)
+ return HttpResponse.json({
+ url: "https://checkout.stripe.com/refreshed",
+ });
+ rejected = true;
+ return HttpResponse.json(
+ { detail: "Refresh the offer" },
+ { status: 409 },
+ );
+ }),
+ );
+ render(<SubscriptionStep />);
+ fireEvent.click(
+ await screen.findByRole("button", { name: "Start 7-day trial" }),
+ );
+ expect(await screen.findByRole("alert")).toBeDefined();
+ fireEvent.click(
+ await screen.findByRole("button", { name: "Start 10-day trial" }),
+ );
+ await waitFor(() =>
+ expect(checkoutLocation.assign).toHaveBeenCalledWith(
+ "https://checkout.stripe.com/refreshed",
+ ),
+ );
+ expect(requestBody).toHaveBeenLastCalledWith({
+ offer_token: "b".repeat(64),
+ return_to: "onboarding",
+ });
+});
+
+test("retains paid checkout, Google Ads value, and DataFast metadata while a trial is eligible", async () => {
+ mockStatus();
+ vi.stubEnv("NEXT_PUBLIC_GOOGLE_ADS_ID", "AW-123");
+ vi.stubEnv("NEXT_PUBLIC_GOOGLE_ADS_CONVERSION_LABELS", "begin_checkout=BC");
+ const gtag = installGtagShim();
+ const paid = vi.fn();
+ server.use(
+ http.post("*/api/credits/subscription", async ({ request }) => {
+ paid(await request.json());
+ return HttpResponse.json({ url: "https://checkout.stripe.com/paid" });
+ }),
+ );
+ render(<SubscriptionStep />);
+ await screen.findByRole("button", { name: "Start 7-day trial" });
+ const pro = within(
+ screen.getByRole("region", { name: "Pro plan" }),
+ ).getByRole("button", { name: /^Get Pro/ });
+ expect(pro.getAttribute("data-fast-goal")).toBe("plan_cta_click");
+ expect(pro.getAttribute("data-fast-goal-plan")).toBe("pro");
+ expect(pro.getAttribute("data-fast-goal-cycle")).toBe("monthly");
+ expect(pro.getAttribute("data-fast-goal-surface")).toBe("onboarding_paywall");
+ fireEvent.click(pro);
+ await waitFor(() =>
+ expect(checkoutLocation.href).toBe("https://checkout.stripe.com/paid"),
+ );
+ expect(paid).toHaveBeenCalledWith(
+ expect.objectContaining({ tier: "PRO", billing_cycle: "monthly" }),
+ );
+ expect(gtag).toContainEqual([
+ "event",
+ "conversion",
+ { send_to: "AW-123/BC", value: 50, currency: "USD" },
+ ]);
+ expect(checkoutLocation.assign).not.toHaveBeenCalled();
+});
+
+test("switches to the offered billing cycle without starting either checkout", async () => {
+ mockStatus();
+ useOnboardingWizardStore.getState().setSelectedBilling("yearly");
+ render(<SubscriptionStep />);
+ const alternative = await screen.findByRole("button", {
+ name: "Try Pro for 7 days instead",
+ });
+ expect(
+ screen.queryByRole("button", { name: "Start 7-day trial" }),
+ ).toBeNull();
+ const toggle = screen.getByRole("button", { name: /Monthly billing/i });
+ expect(toggle.getAttribute("data-fast-goal")).toBe("paywall_billing_toggle");
+ expect(toggle.getAttribute("data-fast-goal-cycle")).toBe("monthly");
+ fireEvent.click(alternative);
+ expect(useOnboardingWizardStore.getState().selectedBilling).toBe("monthly");
+ await screen.findByRole("button", { name: "Start 7-day trial" });
+ expect(useOnboardingWizardStore.getState().selectedPlan).toBeNull();
+ expect(checkoutLocation.assign).not.toHaveBeenCalled();
+ expect(checkoutLocation.href).toBe("http://localhost/");
+});
+
+test("preserves active-trial status and confirmed cancellation", async () => {
+ mockStatus(trialResponse());
+ const cancel = vi.fn(() =>
+ trialResponse({ active: false, status: "canceled" }),
+ );
+ server.use(getPostTrialsCancelTrialMockHandler200(cancel));
+ render(<SubscriptionStep />);
+ fireEvent.click(await screen.findByRole("button", { name: "Cancel trial" }));
+ expect(
+ screen.queryByRole("button", { name: "Start 7-day trial" }),
+ ).toBeNull();
+ expect(cancel).not.toHaveBeenCalled();
+ fireEvent.click(await screen.findByRole("button", { name: "End trial now" }));
+ await screen.findByText(/Cancellation confirmed/);
+ expect(cancel).toHaveBeenCalledOnce();
+ expect(screen.getByText("Your trial has ended")).toBeDefined();
+ expect(screen.queryByRole("button", { name: "Cancel trial" })).toBeNull();
+});
+
+test("does not surface an eligible offer after its trial has converted", async () => {
+ mockStatus({ ...eligible(), converted: true });
+ render(<SubscriptionStep />);
+ await waitFor(() =>
+ expect(posthog.capture).toHaveBeenCalledWith(
+ "subscription_trial_offer_viewed",
+ expect.any(Object),
+ ),
+ );
+ expect(screen.queryByRole("button", { name: /start.*trial/i })).toBeNull();
+ expect(screen.queryByRole("region", { name: "AutoGPT trial" })).toBeNull();
+ expect(screen.getByRole("button", { name: "Get Pro" })).toBeDefined();
+});
+
+test.each(["BASIC", "BUSINESS"] as const)(
+ "preserves the existing fallback for an eligible %s offer",
+ async (tier) => {
+ mockStatus(eligible({ ...trialOffer, tier }));
+ render(<SubscriptionStep />);
+ const fallback = within(
+ await screen.findByRole("region", { name: "AutoGPT trial" }),
+ );
+ expect(
+ fallback.getByRole("button", { name: "Start 7-day trial" }),
+ ).toBeDefined();
+ expect(
+ within(screen.getByRole("region", { name: "Pro plan" })).queryByRole(
+ "button",
+ { name: /start.*trial/i },
+ ),
+ ).toBeNull();
+ },
+);
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/SubscriptionPlans.stories.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/SubscriptionPlans.stories.tsx
new file mode 100644
index 0000000000..1b6057c830
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/SubscriptionPlans.stories.tsx
@@ -0,0 +1,87 @@
+import type { Meta, StoryObj } from "@storybook/nextjs";
+import { useState } from "react";
+import { fn } from "storybook/test";
+import { COUNTRIES } from "@/components/molecules/PlanCard/countries";
+import { PLANS } from "@/components/molecules/PlanCard/plans";
+import type { SubscriptionPlansProps } from "./helpers";
+import { SubscriptionPlans } from "./SubscriptionPlans";
+
+const trialOffer = {
+ token: "storybook-offer",
+ version: "trial-v1",
+ duration_days: 7,
+ tier: "PRO",
+ billing_cycle: "monthly",
+ unit_amount: 5000,
+ currency: "usd",
+ onboarding_credit_amount: 300,
+} as const;
+
+const meta = {
+ title: "Organisms/SubscriptionPlans",
+ component: SubscriptionPlans,
+ parameters: { layout: "fullscreen" },
+ args: {
+ plans: PLANS.map((plan) => ({
+ ...plan,
+ highlighted: false,
+ badge: plan.key === "TEAM" ? plan.badge : null,
+ })),
+ country: COUNTRIES[0],
+ billing: "monthly",
+ trialOffer,
+ isUpdatingTier: false,
+ selectedPlan: null,
+ isStartingTrial: false,
+ trialError: null,
+ onBillingChange: fn(),
+ onStartTrial: fn(),
+ onSelectPlan: fn(),
+ },
+ render: function Render(args) {
+ return <InteractivePlans {...args} />;
+ },
+} satisfies Meta<typeof SubscriptionPlans>;
+
+export default meta;
+type Story = StoryObj<typeof meta>;
+
+function InteractivePlans(args: SubscriptionPlansProps) {
+ const [billing, setBilling] = useState(args.billing);
+ return (
+ <div className="min-h-screen bg-gray-100 py-5">
+ <SubscriptionPlans
+ {...args}
+ billing={billing}
+ onBillingChange={(cycle) => {
+ args.onBillingChange(cycle);
+ setBilling(cycle);
+ }}
+ />
+ </div>
+ );
+}
+
+export const MonthlyTrial: Story = {};
+export const Yearly: Story = { args: { billing: "yearly" } };
+export const NoTrial: Story = { args: { trialOffer: null } };
+export const StartingTrial: Story = { args: { isStartingTrial: true } };
+export const PaidCheckout: Story = {
+ args: { isUpdatingTier: true, selectedPlan: "MAX" },
+};
+export const HighlightedMax: Story = { args: { plans: PLANS } };
+export const TrialError: Story = {
+ args: { trialError: "Unable to start trial checkout. Please try again." },
+};
+export const YearlyYenTrial: Story = {
+ args: {
+ billing: "yearly",
+ trialOffer: {
+ ...trialOffer,
+ duration_days: 14,
+ billing_cycle: "yearly",
+ currency: "jpy",
+ unit_amount: 72000,
+ },
+ },
+};
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/SubscriptionPlans.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/SubscriptionPlans.tsx
new file mode 100644
index 0000000000..4c3fd1c340
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/SubscriptionPlans.tsx
@@ -0,0 +1,45 @@
+"use client";
+
+import type { ReactNode } from "react";
+import { PlanDetailsDialog } from "./components/PlanDetailsDialog/PlanDetailsDialog";
+import { PlanFooter } from "./components/PlanFooter";
+import { PlanHeader } from "./components/PlanHeader";
+import { SubscriptionOffer } from "./components/SubscriptionOffer";
+import type { SubscriptionPlansProps } from "./helpers";
+import { useSubscriptionPlans } from "./useSubscriptionPlans";
+
+export function SubscriptionPlans({
+ trialStatus,
+ ...props
+}: SubscriptionPlansProps & { trialStatus?: ReactNode }) {
+ const { dialog, setDialog, setDialogOpen } = useSubscriptionPlans();
+ return (
+ <div className="mx-auto w-full max-w-7xl px-5 font-sans sm:px-8">
+ <section aria-label="Choose your AutoGPT plan">
+ <PlanHeader {...props} />
+ <div className="grid grid-cols-1 gap-4 lg:grid-cols-3">
+ {props.plans.map((plan) => (
+ <SubscriptionOffer
+ key={plan.key}
+ {...props}
+ plan={plan}
+ onTrialDetails={() => setDialog("trial")}
+ />
+ ))}
+ </div>
+ {trialStatus && (
+ <div className="mx-auto mt-4 w-full max-w-3xl empty:hidden">
+ {trialStatus}
+ </div>
+ )}
+ <PlanFooter onCompare={() => setDialog("compare")} />
+ </section>
+ <PlanDetailsDialog
+ kind={dialog}
+ setOpen={setDialogOpen}
+ trialOffer={props.trialOffer}
+ plans={props.plans}
+ />
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/OfferActions.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/OfferActions.tsx
new file mode 100644
index 0000000000..fb182eea0f
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/OfferActions.tsx
@@ -0,0 +1,137 @@
+import { Button } from "@/components/atoms/Button/Button";
+import { Text } from "@/components/atoms/Text/Text";
+import { PLAN_KEYS, type PlanDef } from "@/components/molecules/PlanCard/plans";
+import { formatTrialPrice } from "@/components/organisms/TrialCard/helpers";
+import { getPlanPresentation, type SubscriptionPlansProps } from "../helpers";
+
+interface Props extends SubscriptionPlansProps {
+ plan: PlanDef;
+ onTrialDetails: () => void;
+}
+
+export function OfferActions(props: Props) {
+ const { trial, offer, action } = getPlanPresentation(props.plan, props);
+ return (
+ <div className="mt-auto space-y-2">
+ {trial ? (
+ <Button
+ type="button"
+ variant="primary"
+ size="small"
+ className="w-full"
+ loading={props.isStartingTrial}
+ disabled={props.isStartingTrial}
+ onClick={props.onStartTrial}
+ >
+ {action}
+ </Button>
+ ) : (
+ <PaidPlanAction {...props} />
+ )}
+ <div className="min-h-10 text-center">
+ {trial ? (
+ <TrialActionDetails {...props} />
+ ) : offer ? (
+ <AlternativeTrial {...props} offer={offer} />
+ ) : (
+ <Text variant="small" tone="muted">
+ {props.plan.key === PLAN_KEYS.TEAM
+ ? "Find the right fit for your team."
+ : "Manage your plan and billing anytime."}
+ </Text>
+ )}
+ </div>
+ {offer && props.trialError && (
+ <p role="alert" className="text-sm text-destructive">
+ {props.trialError}
+ </p>
+ )}
+ </div>
+ );
+}
+
+function PaidPlanAction({
+ plan,
+ billing,
+ isUpdatingTier,
+ selectedPlan,
+ onSelectPlan,
+ inline = false,
+ price,
+}: Props & { inline?: boolean; price?: string | null }) {
+ function handleSelect() {
+ onSelectPlan(plan.key);
+ }
+
+ return (
+ <Button
+ type="button"
+ variant={inline ? "link" : plan.highlighted ? "primary" : "secondary"}
+ size="small"
+ className={inline ? "h-auto min-w-0 p-0 text-xs text-zinc-500" : "w-full"}
+ unmask={!inline}
+ loading={isUpdatingTier && selectedPlan === plan.key}
+ disabled={isUpdatingTier}
+ onClick={handleSelect}
+ data-fast-goal="plan_cta_click"
+ data-fast-goal-plan={plan.key.toLowerCase()}
+ data-fast-goal-cycle={billing}
+ data-fast-goal-surface="onboarding_paywall"
+ >
+ {plan.cta}
+ {price && ` · ${price}`}
+ </Button>
+ );
+}
+
+function TrialActionDetails(props: Props) {
+ const { paidActionPrice } = getPlanPresentation(props.plan, props);
+ return (
+ <Text variant="small" tone="muted" unmask={false}>
+ Card required. No subscription charge today.{" "}
+ <Button
+ type="button"
+ variant="link"
+ className="h-auto min-w-0 p-0 text-xs text-zinc-500"
+ onClick={props.onTrialDetails}
+ >
+ Trial details
+ </Button>
+ {" · "}
+ <PaidPlanAction {...props} inline price={paidActionPrice} />
+ </Text>
+ );
+}
+
+function AlternativeTrial({
+ plan,
+ offer,
+ onBillingChange,
+ isStartingTrial,
+}: Props & {
+ offer: NonNullable<SubscriptionPlansProps["trialOffer"]>;
+}) {
+ function handleSwitchCycle() {
+ onBillingChange(offer.billing_cycle);
+ }
+
+ return (
+ <div>
+ <Button
+ type="button"
+ variant="link"
+ className="h-auto min-w-0 p-0 text-xs text-purple-500"
+ disabled={isStartingTrial}
+ onClick={handleSwitchCycle}
+ data-fast-goal="paywall_billing_toggle"
+ data-fast-goal-cycle={offer.billing_cycle}
+ data-fast-goal-surface="onboarding_paywall"
+ >
+ Try {plan.name} for {offer.duration_days} days instead
+ </Button>
+ <Text variant="small" tone="muted" unmask={false}>
+ Renews at {formatTrialPrice(offer)} + applicable tax.
+ </Text>
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanDetailsDialog/PlanDetailsDialog.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanDetailsDialog/PlanDetailsDialog.tsx
new file mode 100644
index 0000000000..12a99d4bf5
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanDetailsDialog/PlanDetailsDialog.tsx
@@ -0,0 +1,32 @@
+import type { TrialOfferResponse } from "@/app/api/__generated__/models/trialOfferResponse";
+import { Dialog } from "@/components/molecules/Dialog/Dialog";
+import type { PlanDef } from "@/components/molecules/PlanCard/plans";
+import type { PlanDialog } from "../../helpers";
+import { PlanComparison } from "./components/PlanComparison";
+import { TrialDetails } from "./components/TrialDetails";
+
+interface Props {
+ kind: PlanDialog;
+ setOpen: (open: boolean) => void;
+ trialOffer: TrialOfferResponse | null;
+ plans: PlanDef[];
+}
+
+export function PlanDetailsDialog({ kind, setOpen, trialOffer, plans }: Props) {
+ return (
+ <Dialog
+ title={kind === "compare" ? "Compare plans" : "Your trial. No surprises."}
+ variant="compact"
+ controlled={{ isOpen: kind !== null, set: setOpen }}
+ className="max-w-2xl"
+ >
+ <Dialog.Content>
+ {kind === "compare" ? (
+ <PlanComparison plans={plans} />
+ ) : (
+ trialOffer && <TrialDetails offer={trialOffer} />
+ )}
+ </Dialog.Content>
+ </Dialog>
+ );
+}
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanDetailsDialog/components/PlanComparison.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanDetailsDialog/components/PlanComparison.tsx
new file mode 100644
index 0000000000..e362ae9161
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanDetailsDialog/components/PlanComparison.tsx
@@ -0,0 +1,41 @@
+import { Text } from "@/components/atoms/Text/Text";
+import type { PlanDef } from "@/components/molecules/PlanCard/plans";
+
+interface Props {
+ plans: PlanDef[];
+}
+
+export function PlanComparison({ plans }: Props) {
+ return (
+ <div className="space-y-4">
+ <table className="w-full table-fixed text-left font-sans text-sm text-zinc-800">
+ <thead>
+ <tr>
+ {plans.map((plan) => (
+ <th key={plan.key} scope="col" className="pb-3 pr-3 font-medium">
+ {plan.name}
+ {plan.usage && ` · ${plan.usage} usage`}
+ </th>
+ ))}
+ </tr>
+ </thead>
+ <tbody>
+ <tr className="border-t border-zinc-200">
+ {plans.map((plan) => (
+ <td key={plan.key} className="py-3 pr-3 align-top">
+ <ul className="space-y-3">
+ {plan.features.map((feature) => (
+ <li key={feature}>{feature}</li>
+ ))}
+ </ul>
+ </td>
+ ))}
+ </tr>
+ </tbody>
+ </table>
+ <Text variant="small" tone="secondary">
+ Trial usage is limited. Paid plan allowances apply after the trial.
+ </Text>
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanDetailsDialog/components/TrialDetails.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanDetailsDialog/components/TrialDetails.tsx
new file mode 100644
index 0000000000..032e76615d
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanDetailsDialog/components/TrialDetails.tsx
@@ -0,0 +1,45 @@
+import type { TrialOfferResponse } from "@/app/api/__generated__/models/trialOfferResponse";
+import { Text } from "@/components/atoms/Text/Text";
+import { formatTrialPrice } from "@/components/organisms/TrialCard/helpers";
+import { formatPlanAmount } from "../../../helpers";
+
+interface Props {
+ offer: TrialOfferResponse;
+}
+
+export function TrialDetails({ offer }: Props) {
+ return (
+ <div className="space-y-5">
+ <Text variant="body" tone="secondary">
+ {offer.duration_days} days to put AutoGPT to work.
+ </Text>
+ <dl className="divide-y divide-zinc-200 border-y border-zinc-200">
+ <div className="flex justify-between gap-4 py-4">
+ <Text as="dt" variant="body">
+ Today
+ </Text>
+ <Text as="dd" variant="lead-medium" unmask={false}>
+ {formatPlanAmount(0, offer.currency)}
+ </Text>
+ </div>
+ <div className="flex justify-between gap-4 py-4">
+ <Text as="dt" variant="body">
+ After {offer.duration_days} days
+ </Text>
+ <Text as="dd" variant="lead-medium" unmask={false}>
+ {formatTrialPrice(offer)}
+ </Text>
+ </div>
+ </dl>
+ <Text variant="body" tone="secondary">
+ Card required. No subscription charge today. Your paid subscription
+ starts automatically after the trial, plus applicable tax, unless you
+ cancel before it ends.
+ </Text>
+ <Text variant="body" tone="secondary">
+ Trial usage is limited. Canceling ends trial access immediately. You can
+ manage or cancel your plan in billing.
+ </Text>
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanFooter.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanFooter.tsx
new file mode 100644
index 0000000000..6d6445e60d
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanFooter.tsx
@@ -0,0 +1,30 @@
+import { Button } from "@/components/atoms/Button/Button";
+import { Text } from "@/components/atoms/Text/Text";
+
+interface Props {
+ onCompare: () => void;
+}
+
+export function PlanFooter({ onCompare }: Props) {
+ return (
+ <footer className="mt-3 flex flex-wrap items-center justify-center gap-x-5 gap-y-2">
+ <Text variant="small" tone="muted">
+ Need something custom?{" "}
+ <a
+ href="mailto:[email protected]"
+ className="font-medium text-purple-500 no-underline hover:text-purple-600"
+ >
+ Talk to sales.
+ </a>
+ </Text>
+ <Button
+ type="button"
+ variant="link"
+ className="h-auto min-w-0 p-0 text-xs text-zinc-500"
+ onClick={onCompare}
+ >
+ Compare plans
+ </Button>
+ </footer>
+ );
+}
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanHeader.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanHeader.tsx
new file mode 100644
index 0000000000..9d72ff2524
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanHeader.tsx
@@ -0,0 +1,56 @@
+import { AutoGPTLogo } from "@/components/atoms/AutoGPTLogo/AutoGPTLogo";
+import { Button } from "@/components/atoms/Button/Button";
+import { Text } from "@/components/atoms/Text/Text";
+import { cn } from "@/lib/utils";
+import type { SubscriptionPlansProps } from "../helpers";
+
+export function PlanHeader({
+ billing,
+ onBillingChange,
+}: Pick<SubscriptionPlansProps, "billing" | "onBillingChange">) {
+ return (
+ <header className="mb-5 flex flex-col items-center text-center">
+ <AutoGPTLogo hideText className="relative right-5 mb-2 h-8 w-20" />
+ <Text variant="h3" as="h1" className="leading-9">
+ Choose the plan that&apos;s right for{" "}
+ <span className="bg-gradient-to-r from-purple-500 to-indigo-500 bg-clip-text text-transparent">
+ you
+ </span>
+ </Text>
+ <Text variant="body" tone="muted" className="mt-1">
+ Upgrade, downgrade, or change plans anytime. All plans include core
+ features to get you started.
+ </Text>
+ <div
+ role="group"
+ aria-label="Billing period"
+ className="mt-3 flex rounded-full border border-zinc-200 bg-zinc-100 p-1"
+ >
+ {(["monthly", "yearly"] as const).map((cycle) => (
+ <Button
+ key={cycle}
+ type="button"
+ variant="ghost"
+ size="xs"
+ aria-pressed={billing === cycle}
+ onClick={() => onBillingChange(cycle)}
+ data-fast-goal="paywall_billing_toggle"
+ data-fast-goal-cycle={cycle}
+ data-fast-goal-surface="onboarding_paywall"
+ className={cn(
+ "rounded-full px-4 text-xs",
+ billing === cycle
+ ? "bg-white text-zinc-900 shadow-sm hover:bg-white"
+ : "text-zinc-500",
+ )}
+ >
+ {cycle === "monthly" ? "Monthly billing" : "Yearly billing"}
+ {cycle === "yearly" && (
+ <span className="text-xs text-emerald-600">Save 15%</span>
+ )}
+ </Button>
+ ))}
+ </div>
+ </header>
+ );
+}
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/SubscriptionOffer.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/SubscriptionOffer.tsx
new file mode 100644
index 0000000000..c45600101a
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/SubscriptionOffer.tsx
@@ -0,0 +1,149 @@
+import { Tick02Icon } from "@hugeicons/core-free-icons";
+import type { TrialOfferResponse } from "@/app/api/__generated__/models/trialOfferResponse";
+import { Card } from "@/components/atoms/Card/Card";
+import { Icon } from "@/components/atoms/Icon/Icon";
+import { Text } from "@/components/atoms/Text/Text";
+import { PLAN_KEYS, type PlanDef } from "@/components/molecules/PlanCard/plans";
+import { cn } from "@/lib/utils";
+import { getPlanPresentation, type SubscriptionPlansProps } from "../helpers";
+import { OfferActions } from "./OfferActions";
+
+interface Props extends SubscriptionPlansProps {
+ plan: PlanDef;
+ onTrialDetails: () => void;
+}
+
+export function SubscriptionOffer({ plan, onTrialDetails, ...props }: Props) {
+ const presentation = getPlanPresentation(plan, props);
+ return (
+ <section aria-label={`${plan.name} plan`} className="h-full">
+ <Card
+ className={cn(
+ "flex h-full flex-col rounded-2xl border border-zinc-300 bg-white p-5 shadow-none",
+ (presentation.trial || plan.highlighted) && "border-purple-300",
+ )}
+ >
+ <OfferHeading plan={plan} trial={presentation.trial} />
+ <OfferPrice presentation={presentation} />
+ <Text variant="body" tone="primary" className="min-h-11">
+ {plan.description}
+ </Text>
+ <OfferFeatures
+ features={plan.features}
+ isTeam={plan.key === PLAN_KEYS.TEAM}
+ />
+ <OfferActions {...props} plan={plan} onTrialDetails={onTrialDetails} />
+ </Card>
+ </section>
+ );
+}
+
+function OfferHeading({
+ plan,
+ trial,
+}: {
+ plan: PlanDef;
+ trial: TrialOfferResponse | null;
+}) {
+ return (
+ <div className="mb-3 flex flex-wrap items-center gap-2">
+ <Text variant="h5" as="h2" className="font-semibold text-zinc-800">
+ {plan.name}
+ </Text>
+ {plan.usage && (
+ <span className="rounded-full bg-purple-100 px-2 py-0.5 text-xs text-purple-700">
+ {plan.usage} usage
+ </span>
+ )}
+ {plan.badge && (
+ <span
+ className={cn(
+ "rounded-full px-2 py-0.5 text-xs",
+ plan.highlighted
+ ? "bg-purple-50 text-purple-700"
+ : "bg-zinc-100 text-zinc-500",
+ )}
+ >
+ {plan.badge}
+ </span>
+ )}
+ {trial && (
+ <span className="ml-auto rounded-full bg-purple-50 px-2 py-0.5 text-xs font-medium text-purple-700">
+ {trial.duration_days} days free
+ </span>
+ )}
+ </div>
+ );
+}
+
+function OfferPrice({
+ presentation,
+}: {
+ presentation: ReturnType<typeof getPlanPresentation>;
+}) {
+ return (
+ <>
+ <div className="mb-1 flex flex-wrap items-baseline gap-x-1.5">
+ <Text
+ variant="h3"
+ as="span"
+ aria-label={presentation.price}
+ unmask={false}
+ className="leading-9 text-zinc-800"
+ >
+ {presentation.price}
+ </Text>
+ {presentation.unit && (
+ <Text variant="small" as="span" tone="muted">
+ {presentation.unit}
+ </Text>
+ )}
+ </div>
+ <Text
+ variant="small"
+ tone={presentation.trial ? undefined : "muted"}
+ className={cn("mb-2 min-h-4", presentation.trial && "text-purple-700")}
+ >
+ {presentation.caption || "\u00a0"}
+ </Text>
+ </>
+ );
+}
+
+function OfferFeatures({
+ features,
+ isTeam,
+}: {
+ features: string[];
+ isTeam: boolean;
+}) {
+ return (
+ <ul className="mb-4 mt-3 flex-1 space-y-1.5 border-t border-zinc-100 pt-3">
+ {features.map((feature) => (
+ <li key={feature} className="flex items-start gap-2">
+ <span
+ className={cn(
+ "mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full",
+ isTeam ? "bg-zinc-100" : "bg-purple-50",
+ )}
+ >
+ <Icon
+ icon={Tick02Icon}
+ size={10}
+ aria-hidden
+ className={isTeam ? "text-zinc-500" : "text-purple-500"}
+ />
+ </span>
+ <Text
+ variant="small"
+ as="span"
+ tone="primary"
+ className="text-[13px] leading-[18px]"
+ >
+ {feature}
+ </Text>
+ </li>
+ ))}
+ </ul>
+ );
+}
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/helpers.ts b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/helpers.ts
new file mode 100644
index 0000000000..2a2b2a3569
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/helpers.ts
@@ -0,0 +1,111 @@
+import type { TrialOfferResponse } from "@/app/api/__generated__/models/trialOfferResponse";
+import type { Country } from "@/components/molecules/PlanCard/countries";
+import { computePlanPricing } from "@/components/molecules/PlanCard/computePricing";
+import {
+ PLAN_KEYS,
+ type PlanDef,
+ type PlanKey,
+} from "@/components/molecules/PlanCard/plans";
+
+export interface SubscriptionPlansProps {
+ plans: PlanDef[];
+ country: Country;
+ billing: "monthly" | "yearly";
+ onBillingChange: (billing: "monthly" | "yearly") => void;
+ trialOffer: TrialOfferResponse | null;
+ onStartTrial: () => void;
+ onSelectPlan: (key: PlanKey) => void;
+ isUpdatingTier: boolean;
+ selectedPlan?: string | null;
+ isStartingTrial: boolean;
+ trialError: string | null;
+}
+
+export type PlanDialog = "compare" | "trial" | null;
+
+export function formatPlanAmount(amount: number, currency: string) {
+ return new Intl.NumberFormat("en-US", {
+ style: "currency",
+ currency,
+ currencyDisplay: "symbol",
+ }).format(amount);
+}
+
+export function supportsTrialPlan(planKey: string) {
+ return planKey === PLAN_KEYS.PRO || planKey === PLAN_KEYS.MAX;
+}
+
+function getTrialPricing(offer: TrialOfferResponse) {
+ const formatter = new Intl.NumberFormat("en-US", {
+ style: "currency",
+ currency: offer.currency,
+ });
+ const decimals = formatter.resolvedOptions().maximumFractionDigits ?? 2;
+ const amount = offer.unit_amount / 10 ** decimals;
+ return { amount, formatted: formatter.format(amount) };
+}
+
+function getPaidActionPrice(
+ trial: TrialOfferResponse | null,
+ amount: number | null,
+ currency: string,
+ billing: SubscriptionPlansProps["billing"],
+) {
+ if (!trial || amount === null) return null;
+ const price = formatPlanAmount(amount, currency);
+ if (
+ trial.currency.toUpperCase() === currency.toUpperCase() &&
+ formatPlanAmount(getTrialPricing(trial).amount, currency) === price
+ ) {
+ return null;
+ }
+ return `${price} / ${billing === "yearly" ? "year" : "month"}`;
+}
+
+export function getPlanPresentation(
+ plan: PlanDef,
+ props: SubscriptionPlansProps,
+) {
+ const offer =
+ supportsTrialPlan(plan.key) && props.trialOffer?.tier === plan.key
+ ? props.trialOffer
+ : null;
+ const trial = offer?.billing_cycle === props.billing ? offer : null;
+ const pricing = computePlanPricing({
+ plan,
+ country: props.country,
+ isYearly: props.billing === "yearly",
+ });
+ const contactSales = pricing.primaryPrice === null;
+ return {
+ offer,
+ trial,
+ paidActionPrice: getPaidActionPrice(
+ trial,
+ pricing.chargedToday,
+ props.country.currencyCode,
+ props.billing,
+ ),
+ price: trial
+ ? getTrialPricing(trial).formatted
+ : contactSales
+ ? "Contact us"
+ : formatPlanAmount(
+ pricing.primaryPrice ?? 0,
+ props.country.currencyCode,
+ ),
+ unit: trial
+ ? `/ ${trial.billing_cycle === "yearly" ? "year" : "month"}`
+ : contactSales
+ ? null
+ : "/ month",
+ caption: trial
+ ? `after your ${trial.duration_days}-day trial · plus applicable tax`
+ : contactSales
+ ? null
+ : props.billing === "yearly"
+ ? "billed annually"
+ : "billed monthly",
+ action: trial ? `Start ${trial.duration_days}-day trial` : plan.cta,
+ };
+}
diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/useSubscriptionPlans.ts b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/useSubscriptionPlans.ts
new file mode 100644
index 0000000000..5747ac1b74
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/useSubscriptionPlans.ts
@@ -0,0 +1,12 @@
+import { useState } from "react";
+import type { PlanDialog } from "./helpers";
+
+export function useSubscriptionPlans() {
+ const [dialog, setDialog] = useState<PlanDialog>(null);
+
+ function setDialogOpen(open: boolean) {
+ if (!open) setDialog(null);
+ }
+
+ return { dialog, setDialog, setDialogOpen };
+}
diff --git a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCard.tsx b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCard.tsx
index 9d17e0fbc7..4673e5a1f3 100644
--- a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCard.tsx
+++ b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCard.tsx
@@ -13,6 +13,14 @@ interface Props {
}
export function TrialCard({ returnTo = "billing" }: Props) {
+ const controller = useTrialCard(returnTo);
+ return <TrialCardContent returnTo={returnTo} controller={controller} />;
+}
+
+export function TrialCardContent({
+ returnTo = "billing",
+ controller,
+}: Props & { controller: ReturnType<typeof useTrialCard> }) {
const {
userID,
trial,
@@ -24,7 +32,7 @@ export function TrialCard({ returnTo = "billing" }: Props) {
isCanceling,
startTrial,
cancelTrial,
- } = useTrialCard(returnTo);
+ } = controller;
const isBilling = returnTo === "billing";
if (isLoading)
return (