diff --git a/hosted/src/App.test.tsx b/hosted/src/App.test.tsx index 1e189378d..6181a4b31 100644 --- a/hosted/src/App.test.tsx +++ b/hosted/src/App.test.tsx @@ -306,6 +306,15 @@ describe("an account with no plan", () => { expect(buyButton("Founding")).toBeNull(); }); + it("tells a lapsed founder why a card's checkout is at the list price", async () => { + vi.mocked(api.getHostedVoice).mockResolvedValue({ entitled: false, on: false }); + vi.mocked(api.getBilling).mockResolvedValue({ ...NO_PLAN, founding: null, foundingLapsed: true }); + await mount(ENROLLMENT); + await act(async () => buyButton("Hosted monthly")!.click()); + expect(container.querySelector('input[name="plan"]')).toBeNull(); + expect(text()).toContain("subscribing again is at the list price"); + }); + it("offers founding at the server's open cohort, the price checkout charges", async () => { vi.mocked(api.getHostedVoice).mockResolvedValue({ entitled: false, on: false }); vi.mocked(api.getBilling).mockResolvedValue({ ...NO_PLAN, founding: { cohort: 1, seatsLeft: 3 } }); @@ -318,7 +327,9 @@ describe("an account with no plan", () => { vi.mocked(api.getBilling).mockResolvedValue(NO_PLAN); await mount(ENROLLMENT); await act(async () => buyButton("Hosted monthly")!.click()); - expect(container.querySelector('input[value="monthly"]')!.checked).toBe(true); + // The card chose: checkout names that plan alone, with no others to pick. + expect(container.querySelector('input[name="plan"]')).toBeNull(); + expect(text()).toContain("Hosted monthly$10/month"); await tick("agree-terms"); await tick("agree-renewal"); await click("Continue to payment"); diff --git a/hosted/src/Checkout.tsx b/hosted/src/Checkout.tsx index 51d838276..ff4428c64 100644 --- a/hosted/src/Checkout.tsx +++ b/hosted/src/Checkout.tsx @@ -33,6 +33,29 @@ function Terms({ offer }: { offer: Tier }) { ); } +/** A plan's name and price, and the line under it. */ +function OfferLine({ offer, billing }: { offer: Tier; billing: BillingSummary }) { + return ( + + + {offer.name} + + {offer.listPrice && ${offer.listPrice}} + {perInterval(offer.price, planInterval(offer.id))} + + + {offer.id === "founding" && billing.founding && ( + + Locked while you stay subscribed. {billing.founding.seatsLeft} left at this price. + + )} + {offer.id === "yearly" && ( + Two months free against monthly. + )} + + ); +} + /** * The plans on sale, what each commits the buyer to, and the purchase action * behind affirmative agreement to the current terms and to automatic renewal. @@ -40,12 +63,15 @@ function Terms({ offer }: { offer: Tier }) { export function Checkout({ billing, plan, + picked = false, busy, onPurchase, }: { billing: BillingSummary; /** The plan the link named, chosen first when on sale. */ plan: Plan | null; + /** Chosen already, on a plan card: shown alone while on sale, the others a step back. */ + picked?: boolean; busy: string; /** With the price shown beside the renewal the buyer agreed to. */ onPurchase: (plan: Plan, price: number) => void; @@ -57,56 +83,53 @@ export function Checkout({ const [terms, setTerms] = useState(false); const [renewal, setRenewal] = useState(false); const offer = offers.find((each) => each.id === chosen)!; + // Sold out since its card was clicked, the plan offers the rest to choose from. + const alone = picked && offer.id === plan; function submit(event: FormEvent) { event.preventDefault(); if (terms && renewal && !busy) onPurchase(chosen, offer.price); } return (
-
- Choose a plan - {billing.foundingLapsed && ( -

Your founding price ended with your earlier subscription, so subscribing again is at the list price.

- )} - {offers.map((each) => ( - - ))} -
+ {alone ? ( + <> + {billing.foundingLapsed && ( +

Your founding price ended with your earlier subscription, so subscribing again is at the list price.

+ )} +
+ +
+ + ) : ( +
+ Choose a plan + {billing.foundingLapsed && ( +

Your founding price ended with your earlier subscription, so subscribing again is at the list price.

+ )} + {offers.map((each) => ( + + ))} +
+ )}