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.
refactor(frontend): match the trial card to the plan cards and billing cards (#14637)
Ubbe3bea36ed45f9
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.tsxindex edb2972eed..e0cc16001a 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@@ -45,7 +45,7 @@ export function SubscriptionStep() {</Text></div>- <div className="w-full max-w-2xl">+ <div className="w-full max-w-3xl"><TrialCard returnTo="onboarding" /></div><div className="inline-flex rounded-full border border-[#d8d8d8] bg-zinc-100 p-[3px]">diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/billing/__tests__/trial-plan-visibility.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/billing/__tests__/trial-plan-visibility.test.tsxindex 469e2e3dcb..17fb4589a6 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/billing/__tests__/trial-plan-visibility.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/billing/__tests__/trial-plan-visibility.test.tsx@@ -37,7 +37,7 @@ it.each(["past_due", "unpaid", "incomplete_expired", "trialing", "canceled"])(},);-it("keeps the regular plan card hidden during an active trial", async () => {+it("shows the trial as the current plan during an active trial", async () => {server.use(getGetTrialsGetTrialStatusMockHandler200(trialResponse()),http.get("*/api/credits/subscription", () =>@@ -51,6 +51,6 @@ it("keeps the regular plan card hidden during an active trial", async () => {);render(<SettingsBillingPage />);await screen.findByRole("button", { name: "Cancel trial" });- expect(screen.queryByText("Your plan")).toBeNull();+ expect(screen.getByText("Your plan")).toBeDefined();expect(screen.queryByRole("button", { name: "Get Pro" })).toBeNull();});diff --git a/autogpt_platform/frontend/src/components/organisms/TrialCard/CancelTrialDialog.tsx b/autogpt_platform/frontend/src/components/organisms/TrialCard/CancelTrialDialog.tsxindex 53b4bbcfc5..7533e52d68 100644--- a/autogpt_platform/frontend/src/components/organisms/TrialCard/CancelTrialDialog.tsx+++ b/autogpt_platform/frontend/src/components/organisms/TrialCard/CancelTrialDialog.tsx@@ -23,7 +23,12 @@ export function CancelTrialDialog({ isCanceling, onCancel }: Props) {controlled={{ isOpen, set: setIsOpen }}><Dialog.Trigger>- <Button variant="outline" loading={isCanceling} disabled={isCanceling}>+ <Button+ variant="outline"+ size="small"+ loading={isCanceling}+ disabled={isCanceling}+ >Cancel trial</Button></Dialog.Trigger>diff --git a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCard.tsx b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCard.tsxindex 56ce8e332e..9d17e0fbc7 100644--- a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCard.tsx+++ b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCard.tsx@@ -1,7 +1,9 @@"use client";import { Skeleton } from "@/components/atoms/Skeleton/Skeleton";+import { Text } from "@/components/atoms/Text/Text";import { ErrorCard } from "@/components/molecules/ErrorCard/ErrorCard";+import { cn } from "@/lib/utils";import { TrialOffer } from "./TrialOffer";import { TrialStatus } from "./TrialStatus";import { useTrialCard } from "./useTrialCard";@@ -23,7 +25,16 @@ export function TrialCard({ returnTo = "billing" }: Props) {startTrial,cancelTrial,} = useTrialCard(returnTo);- if (isLoading) return <Skeleton className="h-36 w-full rounded-2xl" />;+ const isBilling = returnTo === "billing";+ if (isLoading)+ return (+ <Skeleton+ className={cn(+ "w-full",+ isBilling ? "h-28 rounded-[18px]" : "h-36 rounded-2xl",+ )}+ />+ );if (queryError)return <ErrorCard context="trial information" onRetry={retry} />;if (@@ -32,11 +43,8 @@ export function TrialCard({ returnTo = "billing" }: Props) {(!trial.eligible && trial.status === "checkout_pending"))return null;- return (- <section- aria-label="AutoGPT trial"- className="w-full rounded-2xl border border-border bg-background p-6 text-textBlack"- >+ const body = (+ <>{trial.eligible ? (<TrialOffertrial={trial}@@ -56,6 +64,36 @@ export function TrialCard({ returnTo = "billing" }: Props) {{error}</p>) : null}+ </>+ );+ if (isBilling)+ return (+ <section+ aria-label="AutoGPT trial"+ className="flex w-full flex-col gap-2"+ >+ <div className="flex items-center gap-2 px-4">+ <Text variant="body-medium" as="span" className="text-textBlack">+ {trial.eligible ? "Free trial" : "Your plan"}+ </Text>+ </div>+ <div className="rounded-[18px] border border-zinc-200 bg-white p-5 shadow-[0_1px_2px_rgba(15,15,20,0.04)]">+ {body}+ </div>+ </section>+ );+ return (+ <section+ aria-label="AutoGPT trial"+ className="w-full rounded-2xl bg-gradient-to-br from-zinc-300 via-zinc-400 to-zinc-500 p-px"+ >+ <div className="relative overflow-hidden rounded-[15px] bg-white p-5 md:p-6">+ <div+ aria-hidden+ className="pointer-events-none absolute inset-0 bg-[radial-gradient(120%_60%_at_0%_0%,rgba(168,85,247,0.10),transparent_60%),radial-gradient(120%_60%_at_100%_100%,rgba(99,102,241,0.06),transparent_60%)]"+ />+ <div className="relative">{body}</div>+ </div></section>);}diff --git a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialOffer.tsx b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialOffer.tsxindex b67c1219f1..dfbedeeddb 100644--- a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialOffer.tsx+++ b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialOffer.tsx@@ -2,6 +2,7 @@ import type { TrialStatusResponse } from "@/app/api/__generated__/models/trialStimport { Button } from "@/components/atoms/Button/Button";import { Text } from "@/components/atoms/Text/Text";import { formatTrialPrice, trialPlanLabels } from "./helpers";+import { TrialTitle } from "./TrialTitle/TrialTitle";interface Props {trial: TrialStatusResponse;@@ -13,24 +14,34 @@ export function TrialOffer({ trial, isStarting, onStart }: Props) {const offer = trial.offer;if (!offer) return null;return (- <div className="flex flex-col gap-3">- <Text variant="h4">- Try AutoGPT {trialPlanLabels[offer.tier]} for {offer.duration_days} days- </Text>- <Text variant="body" unmask={false}>- Card required. No subscription charge today. Then{" "}- {formatTrialPrice(offer)}, plus applicable tax, unless you cancel before- the trial ends.- </Text>- <Text variant="small">- Trial usage is limited. Canceling ends trial access immediately. You can- manage your plan in billing.- </Text>+ <div className="flex flex-col gap-4 md:flex-row md:items-center md:justify-between md:gap-8">+ <div className="flex min-w-0 flex-col gap-2">+ <div className="flex flex-wrap items-center gap-2">+ <TrialTitle>+ Try AutoGPT {trialPlanLabels[offer.tier]} for {offer.duration_days}{" "}+ days+ </TrialTitle>+ <span className="inline-flex items-center rounded-full bg-purple-100 px-2 py-0.5 text-[10px] font-medium text-purple-700">+ No charge today+ </span>+ </div>+ <Text variant="body" unmask={false} className="!text-zinc-800">+ Card required. No subscription charge today. Then{" "}+ {formatTrialPrice(offer)}, plus applicable tax, unless you cancel+ before the trial ends.+ </Text>+ <Text variant="small" className="!text-zinc-500">+ Trial usage is limited. Canceling ends trial access immediately. You+ can manage your plan in billing.+ </Text>+ </div><Buttonvariant="primary"+ size="large"onClick={onStart}loading={isStarting}disabled={isStarting}+ className="w-full shrink-0 md:w-auto md:min-w-[11rem]">Start {offer.duration_days}-day trial</Button>diff --git a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialRejection.tsx b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialRejection.tsxindex 710152b237..48f65ec983 100644--- a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialRejection.tsx+++ b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialRejection.tsx@@ -1,6 +1,7 @@import type { TrialRejectionReason } from "@/app/api/__generated__/models/trialRejectionReason";import { Text } from "@/components/atoms/Text/Text";import { Button } from "@/components/atoms/Button/Button";+import { TrialTitle } from "./TrialTitle/TrialTitle";interface Props {reason: TrialRejectionReason;@@ -10,17 +11,17 @@ export function TrialRejection({ reason }: Props) {const alreadyUsed = reason === "intro_offer_already_used";return (<div role="status" className="flex flex-col gap-3">- <Text variant="h4">+ <TrialTitle>{alreadyUsed? "This introductory offer has already been used": "We couldn’t verify your card for this trial"}- </Text>- <Text variant="body">+ </TrialTitle>+ <Text variant="body" className="!text-zinc-800">{alreadyUsed? "This card or account has already redeemed an introductory offer. Each card and account can use one introductory offer.": "Your card could not be verified for trial eligibility, so this trial was not activated."}</Text>- <Text variant="body">+ <Text variant="body" className="!text-zinc-800">This trial will not convert to a paid subscription. You can choose apaid plan below. If you think this is a mistake, contact support.</Text>diff --git a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialStatus.tsx b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialStatus.tsxindex bdd894dd4e..11c3725e4b 100644--- a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialStatus.tsx+++ b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialStatus.tsx@@ -3,6 +3,7 @@ import { Text } from "@/components/atoms/Text/Text";import { CancelTrialDialog } from "./CancelTrialDialog";import { formatTrialEnd, formatTrialPrice } from "./helpers";import { TrialRejection } from "./TrialRejection";+import { TrialTitle } from "./TrialTitle/TrialTitle";interface Props {trial: TrialStatusResponse;@@ -17,10 +18,10 @@ export function TrialStatus({ trial, isCanceling, onCancel }: Props) {const end = formatTrialEnd(trial.ends_at);return (<div className="flex flex-col gap-3">- <Text variant="h4">+ <TrialTitle>{trial.active ? "Your trial" : "Your trial has ended"}- </Text>- <Text variant="body" unmask={false}>+ </TrialTitle>+ <Text variant="body" unmask={false} className="!text-zinc-800">{trial.status === "canceled"? "Cancellation confirmed. Trial access has ended and your trial will not convert to a paid plan.": trial.cancel_at_period_end@@ -30,10 +31,14 @@ export function TrialStatus({ trial, isCanceling, onCancel }: Props) {: "Paid access requires a successful payment. Review your payment method and plan below."}</Text>{trial.active ? (- <Text variant="small">Canceling ends trial access immediately.</Text>+ <Text variant="small" className="!text-zinc-500">+ Canceling ends trial access immediately.+ </Text>) : null}{trial.active && !trial.cancel_at_period_end ? (- <CancelTrialDialog isCanceling={isCanceling} onCancel={onCancel} />+ <div className="mt-1">+ <CancelTrialDialog isCanceling={isCanceling} onCancel={onCancel} />+ </div>) : null}</div>);diff --git a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialTitle/TrialTitle.tsx b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialTitle/TrialTitle.tsxnew file mode 100644index 0000000000..a3ba102a75--- /dev/null+++ b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialTitle/TrialTitle.tsx@@ -0,0 +1,17 @@+import { Text } from "@/components/atoms/Text/Text";++interface Props {+ children: React.ReactNode;+}++export function TrialTitle({ children }: Props) {+ return (+ <Text+ variant="h5"+ as="h2"+ className="font-poppins !text-[17px] !font-semibold !text-zinc-800"+ >+ {children}+ </Text>+ );+}