Skip to content

Open source CapCut alternative.

TypeScript

feat(site): price Pro in the out-of-credits message

David Le0c5a5ab9a9f3
diff --git a/site/src/cut/components/OfferDialog.tsx b/site/src/cut/components/OfferDialog.tsx
index ba6117bb..26604248 100644
--- a/site/src/cut/components/OfferDialog.tsx
+++ b/site/src/cut/components/OfferDialog.tsx
@@ -152,7 +152,8 @@ export function OfferDialog({
closesAt?: string | null;
title: React.ReactNode;
body: React.ReactNode;
- // The fine print under the message, on its own line.
+ // The fine print under the message, on its own line. Null holds the line
+ // empty while the terms load; left out, the card has no such line.
terms?: React.ReactNode;
// The one thing to do, full width.
cta: React.ReactNode;
@@ -189,7 +190,9 @@ export function OfferDialog({
<DialogDescription className="min-h-12 text-base leading-relaxed text-muted-foreground">
{body}
</DialogDescription>
- <p className="min-h-[1lh] text-base leading-relaxed text-muted-foreground">{terms}</p>
+ {terms === undefined ? null : (
+ <p className="min-h-[1lh] text-base leading-relaxed text-muted-foreground">{terms}</p>
+ )}
</DialogHeader>
{error ? <p className="text-sm text-destructive">{error}</p> : null}
{/* The buttons keep the 21rem column of the narrower card. */}
diff --git a/site/src/cut/components/UpgradeDialog.tsx b/site/src/cut/components/UpgradeDialog.tsx
index d9805bba..ad2d7e3c 100644
--- a/site/src/cut/components/UpgradeDialog.tsx
+++ b/site/src/cut/components/UpgradeDialog.tsx
@@ -17,7 +17,7 @@ import { onUpgrade, openUpgrade, type UpgradeReason } from "@/cut/lib/upgrade";
import { track } from "@/lib/analytics";
import { creditCountLabel, creditsPerDollar } from "@/lib/credits/format-credits";
import { useAccountConfig } from "@/queries/accountConfig";
-import { useIntroOffer, useProSubscription } from "@/queries/billing";
+import { useIntroOffer, useProSubscription, type IntroOffer } from "@/queries/billing";
export function UpgradeDialog() {
const [reason, setReason] = useState<UpgradeReason | null>(null);
@@ -122,7 +122,12 @@ function OpenDialog({
const wall =
reason === "projects"
? { icon: FolderPlus, title: "Upgrade to make more projects", body: projectsBody(projectLimit) }
- : { icon: Zap, title: "You're out of credits", body: `Pro comes with ${credits} every month and 100 GB of cloud storage.` };
+ : {
+ icon: Zap,
+ title: "You're out of credits",
+ // An open offer prices Pro on its terms line.
+ body: `Upgrade to Pro and get ${credits} every month and 100 GB of cloud storage${offer ? "" : ` for ${CUT_PRO.price}`}.`,
+ };
return (
<OfferDialog
@@ -132,7 +137,7 @@ function OpenDialog({
closesAt={offer?.endsAt}
title={wall.title}
body={wall.body}
- terms={offer ? introTerms(offer) : `Pro is ${CUT_PRO.price}.`}
+ terms={wallTerms(reason, offer)}
cta={
<OfferButton disabled={upgrade.isPending} onClick={upgrade.start}>
{upgrade.isPending && <Loader2 className="animate-spin" data-icon="inline-start" />}
@@ -144,6 +149,18 @@ function OpenDialog({
);
}
+/** The terms line: an open offer's terms, else the price on the projects
+ * wall. The credits wall names the price in its message, so it has none. */
+function wallTerms(reason: UpgradeReason, offer: IntroOffer | null): string | undefined {
+ if (offer) {
+ return introTerms(offer);
+ }
+ if (reason === "projects") {
+ return `Pro is ${CUT_PRO.price}.`;
+ }
+ return undefined;
+}
+
/** What the free plan holds, as the projects wall says it. */
function projectsBody(limit: number | null): string {
if (!limit) {