Open source CapCut alternative.
TypeScript
fix(site): a claim link opens one offer card that holds its size
David Led81af545399d
diff --git a/site/src/cut/components/ClaimCreditsDialog.tsx b/site/src/cut/components/ClaimCreditsDialog.tsxindex 46d8909e..c04bbb80 100644--- a/site/src/cut/components/ClaimCreditsDialog.tsx+++ b/site/src/cut/components/ClaimCreditsDialog.tsx@@ -67,24 +67,19 @@ function OpenDialog({ token, onClose }: { token: string; onClose: () => void })});checkout.mutate({ offerToken: token }, { onSuccess: (result) => window.location.assign(result.url) });};- // The card opens at once, checking the link, at the size it keeps: the- // body reserves two lines and every state ends in one button.+ // The card opens once the link is checked, as the offer it holds: its+ // banner, title and button are the offer's from the first paint. The body+ // reserves two lines and every state ends in one button, so the card keeps+ // its size as the offer is claimed.+ if (offer.isPending) return null;const done = claim.data ?? (offer.data?.claimed ? { expiresAt: offer.data.expiresAt } : null);- let title: React.ReactNode = "Claim your credits";+ let title: React.ReactNode;let body: React.ReactNode;let terms: React.ReactNode = null;let cta: React.ReactNode;let secondary: React.ReactNode = <OfferDismiss onClick={onClose}>Not now</OfferDismiss>;- if (offer.isPending) {- body = (- <span className="flex items-center gap-2">- <Loader2 className="size-4 shrink-0 animate-spin" />- Checking your offer…- </span>- );- cta = <OfferButton disabled>Claim</OfferButton>;- } else if (offer.isError) {+ if (offer.isError) {const status = offer.error instanceof ApiError ? offer.error.status : null;title =status === 410 ? "This offer has expired" : status === 409 ? "You already have Pro" : "This link is no longer valid";diff --git a/site/src/cut/components/OfferDialog.tsx b/site/src/cut/components/OfferDialog.tsxindex 42f8c4c4..98d32e17 100644--- a/site/src/cut/components/OfferDialog.tsx+++ b/site/src/cut/components/OfferDialog.tsx@@ -3,7 +3,8 @@// The face of a credit offer, whichever way it reached the person: a picture// across the top, a title, a line of body, and one full-width button. The// email's claim link and the offer in the top bar both open this, so an-// offer looks the same from anywhere.+// offer looks the same from anywhere. Every slot keeps its height whether+// or not it has words, so the card stands still as the offer is taken up.import Image from "next/image";import { useEffect, useState } from "react";import { CUT_PRO } from "@/app/cut/_components/landing/cutPricingPlans";@@ -139,12 +140,12 @@ export function OfferDialog({<DialogDescription className="min-h-12 text-base leading-relaxed text-muted-foreground">{body}</DialogDescription>- {terms ? <p className="text-base leading-relaxed text-muted-foreground">{terms}</p> : 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}<div className="mt-5 flex flex-col gap-2">{cta}- {secondary}+ <div className="min-h-8">{secondary}</div></div></div></DialogContent>