Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
improvement: billing page styling adjustments
Scott Wilson6fc48d2bca1e
diff --git a/frontend/src/pages/organization/BillingV2Page/billing-v2-format.ts b/frontend/src/pages/organization/BillingV2Page/billing-v2-format.tsindex 9e06740c1c..cb14242586 100644--- a/frontend/src/pages/organization/BillingV2Page/billing-v2-format.ts+++ b/frontend/src/pages/organization/BillingV2Page/billing-v2-format.ts@@ -85,6 +85,10 @@ export const cadencePeriod = (cadence: BillingV2Cadence | null | undefined): strexport const dimAnnualCommitted = (dim: BillingV2EntitlementDim): boolean =>dim.cadence === "annual" && dim.committed !== null;+// A ceiling to fill a usage bar against: an annual commitment or a finite limit.+export const dimHasCeiling = (dim: BillingV2EntitlementDim): boolean =>+ dimAnnualCommitted(dim) || (dim.limit !== null && dim.limit > 0);+// Per-unit monthly rate for a dimension (dollars): metered uses its per-unit rate; a monthly// per_resource (and an annual dimension's overage) uses the on-demand rate.export const dimMonthlyRate = (dim: BillingV2EntitlementDim): number => {@@ -106,8 +110,8 @@ export const usagePct = (used: number, limit: number | null): number | null => {return Math.min(100, (used / limit) * 100);};-// Segments for a dimension's usage bar. Annual committed: the bar spans the greater of committed and-// used; the committed portion is blue and any overflow orange. Monthly: a single blue used/limit fill.+// Segments for a dimension's usage bar. Annual committed: the bar spans the greater of committed+// and used, split into committed fill and on-demand overflow. Monthly: a single used/limit fill.export const dimBarSegments = (dim: BillingV2EntitlementDim): { committedPct: number; onDemandPct: number } => {diff --git a/frontend/src/pages/organization/BillingV2Page/components/ActivateView.tsx b/frontend/src/pages/organization/BillingV2Page/components/ActivateView.tsxindex c88a238786..bd167ea715 100644--- a/frontend/src/pages/organization/BillingV2Page/components/ActivateView.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/ActivateView.tsx@@ -15,7 +15,7 @@ import {} from "@app/hooks/api";import { fmtMoney } from "../billing-v2-format";-import { ProductIcon, Stepper } from "./shared";+import { CostSummary, CostSummaryRow, ProductIcon, Stepper } from "./shared";type Props = {orgId: string;@@ -105,10 +105,19 @@ export const ActivateView = ({committable.reduce((sum, dim) => sum + (commitments[dim.key] ?? 0) * dim.annual, 0): monthlyHeadline(plan);- // Re-price when the cadence or a committed quantity changes; debounced so a burst of stepper clicks- // makes one request, not one per click. Skipped entirely without a live subscription.+ // A preview is fresh only once priced for the current cadence + commitments; until then the cost+ // rows show skeletons. A new customer prices locally, so never calculates.+ const previewFresh =+ !preview.isPending &&+ Boolean(preview.data) &&+ preview.variables?.cadence === cadence &&+ JSON.stringify(preview.variables?.commitments ?? {}) === commitmentsKey;+ const isCalculating = hasActiveSubscription && !previewFresh;++ // Debounced re-price on cadence/commitment changes so a burst of stepper clicks makes one request.+ // Skipped without a live subscription or when the current combo is already priced.useEffect(() => {- if (!hasActiveSubscription) {+ if (!hasActiveSubscription || previewFresh) {return undefined;}const timeout = setTimeout(() => {@@ -138,10 +147,10 @@ export const ActivateView = ({let chargedNote = "Billed at checkout";if (hasActiveSubscription) {- chargedNote = preview.isPending ? "Calculating…" : "Prorated onto your shared billing date";+ chargedNote = isCalculating ? "Calculating…" : "Prorated onto your shared billing date";}// Without a live subscription there is no preview to wait on, so the CTA is enabled immediately.- const activateDisabled = pending || (hasActiveSubscription && !preview.data);+ const activateDisabled = pending || isCalculating;// Savings badge on the yearly option: how much cheaper the annual rate is vs paying monthly.const savingsPct = useMemo(() => {@@ -276,28 +285,21 @@ export const ActivateView = ({</div>)}- <div className="flex flex-col rounded-lg border border-border">- <div className="flex items-center justify-between border-b border-border bg-mineshaft-700/40 p-4">- <div>- <div className="text-sm text-foreground">Charged today</div>- <div className="text-xs text-muted">{chargedNote}</div>- </div>- <span className="text-lg font-semibold text-info tabular-nums">- {fmtMoney(dueToday, dueToday ? 2 : 0)}- </span>- </div>- <div className="flex items-center justify-between p-4">- <div>- <div className="text-sm text-foreground">- {cadence === "annual" ? "Annual commitment" : "Monthly total"}- </div>- {renewsOn && <div className="text-xs text-muted">Billed on {renewsOn}</div>}- </div>- <span className="text-sm font-semibold text-foreground tabular-nums">- {fmtMoney(recurring)} / {period}- </span>- </div>- </div>+ <CostSummary>+ <CostSummaryRow+ label="Charged today"+ note={chargedNote}+ value={fmtMoney(dueToday, dueToday ? 2 : 0)}+ isCalculating={isCalculating}+ valueClassName="text-base"+ />+ <CostSummaryRow+ label={cadence === "annual" ? "Annual commitment" : "Monthly total"}+ note={renewsOn ? `Billed on ${renewsOn}` : undefined}+ value={`${fmtMoney(recurring)} / ${period}`}+ isCalculating={isCalculating}+ />+ </CostSummary></div><SheetFooter className="flex-row justify-between border-t">@@ -311,7 +313,9 @@ export const ActivateView = ({isDisabled={activateDisabled}isPending={pending}>- Activate · pay {fmtMoney(dueToday, dueToday ? 2 : 0)} today+ {isCalculating+ ? "Activate"+ : `Activate · pay ${fmtMoney(dueToday, dueToday ? 2 : 0)} today`}</Button></SheetFooter></>diff --git a/frontend/src/pages/organization/BillingV2Page/components/CommitmentView.tsx b/frontend/src/pages/organization/BillingV2Page/components/CommitmentView.tsxindex 091917f010..7f98c3b73d 100644--- a/frontend/src/pages/organization/BillingV2Page/components/CommitmentView.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/CommitmentView.tsx@@ -1,8 +1,15 @@import { useEffect, useMemo, useState } from "react";-import { ArrowUpIcon, ChevronLeftIcon, Info } from "lucide-react";+import { ChevronLeftIcon, InfoIcon } from "lucide-react";import { createNotification } from "@app/components/notifications";-import { Button, SheetFooter, SheetHeader, SheetTitle } from "@app/components/v3";+import {+ Alert,+ AlertDescription,+ Button,+ SheetFooter,+ SheetHeader,+ SheetTitle+} from "@app/components/v3";import {BillingV2CatalogProduct,BillingV2CommitmentChange,@@ -12,7 +19,7 @@ import {} from "@app/hooks/api";import { dimAnnualCommitted, fmtMoney } from "../billing-v2-format";-import { ProductIcon, Stepper } from "./shared";+import { CostSummary, CostSummaryRow, ProductIcon, Stepper } from "./shared";type Props = {orgId: string;@@ -48,11 +55,19 @@ export const CommitmentView = ({ orgId, prod, entitlement, renewsOn, onBack, onD[committable, quantities]);const changesKey = JSON.stringify(changes);+ const hasChanges = changes.length > 0;++ // A preview is fresh only once priced for the current changes; stale ones render as skeletons.+ const previewFresh =+ !preview.isPending &&+ Boolean(preview.data) &&+ JSON.stringify(preview.variables?.commitmentChanges) === changesKey;+ const isCalculating = hasChanges && !previewFresh;- // Re-price whenever the set of changes changes; debounced so a burst of stepper clicks makes one- // request, not one per click. With nothing changed there is no charge to preview.+ // Debounced re-price on changes so a burst of stepper clicks makes one request. Skipped with+ // nothing changed or when the current set is already priced.useEffect(() => {- if (changes.length === 0) {+ if (changes.length === 0 || previewFresh) {return undefined;}const timeout = setTimeout(() => {@@ -62,8 +77,6 @@ export const CommitmentView = ({ orgId, prod, entitlement, renewsOn, onBack, onD// eslint-disable-next-line react-hooks/exhaustive-deps}, [orgId, changesKey]);- const hasChanges = changes.length > 0;-// Current annual commitment total (committed × annual rate) and the current monthly on-demand spend,// both computed client-side so the summary can show the before/after delta.const currentAnnual = committable.reduce(@@ -85,21 +98,10 @@ export const CommitmentView = ({ orgId, prod, entitlement, renewsOn, onBack, onDlet chargedNote = "No change yet";if (hasChanges) {- chargedNote = preview.isPending ? "Calculating…" : "Prorated for the rest of your annual term";+ chargedNote = isCalculating ? "Calculating…" : "Prorated for the rest of your annual term";}- const raiseToCoverUsage = () => {- setQuantities((prev) => {- const next = { ...prev };- committable.forEach((dim) => {- next[dim.key] = Math.max(dim.committed ?? 0, dim.used);- });- return next;- });- };- const coversUsage = committable.every((dim) => quantities[dim.key] >= dim.used);-- const canConfirm = hasChanges && Boolean(preview.data) && !preview.isPending;+ const canConfirm = hasChanges && previewFresh;const handleConfirm = async () => {try {@@ -131,7 +133,7 @@ export const CommitmentView = ({ orgId, prod, entitlement, renewsOn, onBack, onD<ProductIcon product={prod} size={40} /><div className="min-w-0 flex-1"><SheetTitle className="text-base">Change {prod.name} commitment</SheetTitle>- <p className="mt-1 text-sm text-muted">+ <p className="text-xs text-muted">Adjust the units you pre-buy for the year. Usage above your commitment is billed monthlyon-demand.</p>@@ -154,10 +156,20 @@ export const CommitmentView = ({ orgId, prod, entitlement, renewsOn, onBack, onD{fmtMoney(dim.committedRate ?? 0)} / {dim.noun} / yr committed · using{" "}{dim.used.toLocaleString()} now{onDemandQty > 0 && (- <span className="text-warning">- {" "}- · {onDemandQty.toLocaleString()} on-demand- </span>+ <>+ <span className="text-warning/90">+ {" "}+ · {onDemandQty.toLocaleString()} on-demand+ </span>{" "}+ ·{" "}+ <button+ type="button"+ className="cursor-pointer font-medium text-foreground hover:underline"+ onClick={() => setQuantities((prev) => ({ ...prev, [dim.key]: dim.used }))}+ >+ Raise to cover+ </button>+ </>)}</div></div>@@ -170,56 +182,37 @@ export const CommitmentView = ({ orgId, prod, entitlement, renewsOn, onBack, onD);})}- {!coversUsage && (- <Button variant="info" size="sm" className="self-start" onClick={raiseToCoverUsage}>- <ArrowUpIcon />- Raise commitment to cover current usage- </Button>- )}-- <div className="flex gap-3 rounded-lg border border-info/20 bg-info/5 p-4 text-xs text-accent">- <Info className="mt-0.5 size-4 shrink-0 text-info" />- <span>+ <Alert variant="info">+ <InfoIcon />+ <AlertDescription className="text-foreground">Committed units are pre-bought for the year at the annual rate. Usage above yourcommitment is billed monthly at the on-demand rate until your renewal. Raising yourcommitment is prorated for the rest of the term; lowering it takes effect at renewal.- </span>- </div>-- <div className="flex flex-col rounded-lg border border-border">- <div className="flex items-center justify-between border-b border-border bg-mineshaft-700/40 p-4">- <div>- <div className="text-sm text-foreground">Charged today</div>- <div className="text-xs text-muted">{chargedNote}</div>- </div>- <span className="text-lg font-semibold text-info tabular-nums">- {fmtMoney(chargedToday, chargedToday ? 2 : 0)}- </span>- </div>- <div className="flex items-center justify-between border-b border-border p-4">- <div>- <div className="text-sm text-foreground">New annual commitment</div>- <div className="text-xs text-muted">- For {prod.name}- {renewsOn ? `, billed on ${renewsOn}` : ""}- </div>- </div>- <span className="text-sm font-semibold text-foreground tabular-nums">- {fmtMoney(newAnnual)} / year- </span>- </div>- <div className="flex items-center justify-between p-4">- <div>- <div className="text-sm text-foreground">On-demand after change</div>- <div className="text-xs text-muted">- {onDemandDelta ?? "Billed monthly for usage above your commitment"}- </div>- </div>- <span className="text-sm font-semibold text-warning tabular-nums">- {fmtMoney(newOnDemand)} / mo- </span>- </div>- </div>+ </AlertDescription>+ </Alert>++ <CostSummary>+ <CostSummaryRow+ label="Charged today"+ note={chargedNote}+ value={fmtMoney(chargedToday, chargedToday ? 2 : 0)}+ isCalculating={isCalculating}+ valueClassName="text-base"+ />+ <CostSummaryRow+ label="New annual commitment"+ note={`For ${prod.name}${renewsOn ? `, billed on ${renewsOn}` : ""}`}+ value={`${fmtMoney(newAnnual)} / year`}+ isCalculating={isCalculating}+ />+ <CostSummaryRow+ label="On-demand after change"+ note={onDemandDelta ?? "Billed monthly for usage above your commitment"}+ value={`${fmtMoney(newOnDemand)} / mo`}+ isCalculating={isCalculating}+ valueClassName={newOnDemand > 0 ? "text-warning/90" : "text-muted"}+ />+ </CostSummary></div><SheetFooter className="flex-row justify-between border-t">diff --git a/frontend/src/pages/organization/BillingV2Page/components/Overview.tsx b/frontend/src/pages/organization/BillingV2Page/components/Overview.tsxindex 50a869a20c..18ee258f8b 100644--- a/frontend/src/pages/organization/BillingV2Page/components/Overview.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/Overview.tsx@@ -1,3 +1,4 @@+import { cn } from "@app/components/v3/utils";import { BillingV2CatalogProduct, BillingV2Overview } from "@app/hooks/api";import { BillingV2RenderState } from "../billing-v2-view-types";@@ -102,11 +103,20 @@ export const Overview = ({onManage={onUpgrade}onContact={onContact}/>- {showPayment && (- <PaymentCard overview={overview} canManage={canManageBilling} onUpdate={onUpdatePayment} />- )}{!isManaged && (- <DetailsCard overview={overview} canManage={canManageBilling} onEdit={onEditDetails} />+ // Payment (cloud-only) + details share a row, keyed off container width (sidebar resizes it).+ <div className="@container">+ <div className={cn("grid gap-4", showPayment && "@3xl:grid-cols-[2fr_3fr]")}>+ {showPayment && (+ <PaymentCard+ overview={overview}+ canManage={canManageBilling}+ onUpdate={onUpdatePayment}+ />+ )}+ <DetailsCard overview={overview} canManage={canManageBilling} onEdit={onEditDetails} />+ </div>+ </div>)}{showPayment && <InvoicesCard invoices={overview.invoices} />}</div>diff --git a/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx b/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsxindex 684a337b70..f8a7666228 100644--- a/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx@@ -1,5 +1,5 @@import { useState } from "react";-import { ArrowRight, CalendarX2Icon, Check, PlusIcon, Sparkles } from "lucide-react";+import { ArrowRight, CalendarX2Icon, Check, EditIcon, PlusIcon, Sparkles } from "lucide-react";import { createNotification } from "@app/components/notifications";import {@@ -185,12 +185,13 @@ const PlanCard = ({} else if (isCurrent && canChangeCommitment) {cta = (<Button- variant="outline"+ variant="success"size="sm"className="mt-auto self-start"onClick={onChangeCommitment}>Change commitment+ <EditIcon /></Button>);} else if (plan.selfServe && !entitled) {@@ -276,7 +277,7 @@ const CompareTable = ({compare: BillingV2CompareRow[];}) => (<div>- <div className="mb-3 text-xs font-medium tracking-wide text-muted uppercase">Compare plans</div>+ <div className="mb-3 text-xs font-medium text-label">Compare Plans</div><Table><TableHeader><TableRow>@@ -525,19 +526,11 @@ export const ProductSheet = ({{entitled ? (<>{isTrialing ? (- <Button- variant="ghost"- className="text-danger"- onClick={() => setShowCancelTrial(true)}- >+ <Button variant="danger" onClick={() => setShowCancelTrial(true)}>Cancel trial</Button>) : (- <Button- variant="ghost"- className="text-danger"- onClick={() => onRemove(prod.id)}- >+ <Button variant="danger" onClick={() => onRemove(prod.id)}>Remove product</Button>)}diff --git a/frontend/src/pages/organization/BillingV2Page/components/cards/BillingHeaderCard.tsx b/frontend/src/pages/organization/BillingV2Page/components/cards/BillingHeaderCard.tsxindex 0202c88f7b..7476018627 100644--- a/frontend/src/pages/organization/BillingV2Page/components/cards/BillingHeaderCard.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/cards/BillingHeaderCard.tsx@@ -1,7 +1,8 @@import { ReactNode } from "react";-import { Info } from "lucide-react";+import { Calendar, CreditCard, Info, ShieldAlert, ShieldCheck } from "lucide-react";-import { Badge, Card } from "@app/components/v3";+import { Badge, Card, CardAction, CardContent, CardHeader, CardTitle } from "@app/components/v3";+import { cn } from "@app/components/v3/utils";import { BillingV2CatalogProduct, BillingV2Overview } from "@app/hooks/api";import { cadenceLabel, fmtMoney, nextChargeProductLabel } from "../../billing-v2-format";@@ -21,11 +22,54 @@ const StatusBadge = ({ subState }: { subState: BillingV2RenderState }) => {return <ActiveBadge />;};-const HeaderColumn = ({ label, children }: { label: string; children: ReactNode }) => (- <div className="flex flex-1 flex-col gap-3 px-6 py-5">- <div className="text-xs font-medium tracking-wide text-muted uppercase">{label}</div>- {children}- </div>+type StatTone = "success" | "info" | "warning" | "danger" | "org";++const STAT_TONE: Record<StatTone, string> = {+ success: "border-success/15 bg-success/10 text-success",+ info: "border-info/15 bg-info/10 text-info",+ org: "border-org/15 bg-org/10 text-org",+ warning: "border-warning/15 bg-warning/10 text-warning",+ danger: "border-danger/15 bg-danger/10 text-danger"+};++const STATUS_VISUAL: Record<BillingV2RenderState, { tone: StatTone; icon: ReactNode }> = {+ active: { tone: "success", icon: <ShieldCheck /> },+ trialing: { tone: "info", icon: <ShieldCheck /> },+ "past-due": { tone: "warning", icon: <ShieldAlert /> },+ suspended: { tone: "danger", icon: <ShieldAlert /> },+ "no-subscription": { tone: "info", icon: <ShieldCheck /> },+ loading: { tone: "info", icon: <ShieldCheck /> },+ error: { tone: "danger", icon: <ShieldAlert /> }+};++type StatTileProps = {+ title: string;+ tone: StatTone;+ icon: ReactNode;+ value: ReactNode;+ footer: ReactNode;+};++const StatTile = ({ title, tone, icon, value, footer }: StatTileProps) => (+ <Card className="flex-1 gap-2 p-4 shadow-none">+ <CardHeader>+ <CardTitle className="text-xs font-medium text-muted capitalize">{title}</CardTitle>+ <CardAction>+ <div+ className={cn(+ "flex size-7 items-center justify-center rounded-md border [&>svg]:size-4",+ STAT_TONE[tone]+ )}+ >+ {icon}+ </div>+ </CardAction>+ </CardHeader>+ <CardContent className="flex flex-col gap-1.5">+ <div className="text-lg font-semibold text-foreground">{value}</div>+ <div className="flex min-h-5 items-center">{footer}</div>+ </CardContent>+ </Card>);type BillingHeaderCardProps = {@@ -33,82 +77,103 @@ type BillingHeaderCardProps = {catalog: BillingV2CatalogProduct[];};-// The three-column header: ACCOUNT (standing), NEXT CHARGE (when/how much leaves next), and WHAT YOU-// PAY (the two independent recurring clocks, never summed). An info banner explains the per-product-// cadence model below the columns.+// Header stat tiles: Account (standing), Next charge, and What you pay (two independent recurring+// clocks, never summed), with an info note on the per-product cadence model below.export const BillingHeaderCard = ({ overview, catalog }: BillingHeaderCardProps) => {const { billing } = overview;const { nextCharge } = billing;+ const status = STATUS_VISUAL[overview.subState];const productLabel = nextCharge ? nextChargeProductLabel(catalog, nextCharge.productKeys) : "";const nextChargeCadence = nextCharge ? cadenceLabel(nextCharge.cadence) : "";const nextChargeSubline = [productLabel, nextChargeCadence].filter(Boolean).join(" · ");const hasRecurring = billing.monthlyRecurring > 0 || billing.annualCommitted > 0;return (- <Card className="gap-0 p-0">- <div className="flex flex-col divide-y divide-border md:flex-row md:divide-x md:divide-y-0">- <HeaderColumn label="Account">- <div>- <StatusBadge subState={overview.subState} />- </div>- <div className="text-xs text-muted">- {billing.activeProductCount} active{" "}- {billing.activeProductCount === 1 ? "product" : "products"}- </div>- </HeaderColumn>+ <div className="flex flex-col gap-3">+ <div className="flex flex-col gap-4 lg:flex-row">+ <StatTile+ title="Account"+ tone={status.tone}+ icon={status.icon}+ value={<StatusBadge subState={overview.subState} />}+ footer={+ <span className="text-xs text-muted">+ {billing.activeProductCount} active{" "}+ {billing.activeProductCount === 1 ? "product" : "products"}+ </span>+ }+ />- <HeaderColumn label="Next charge">- {nextCharge ? (- <>- <div className="text-2xl font-semibold text-foreground">+ <StatTile+ title="Next charge"+ tone="org"+ icon={<Calendar />}+ value={+ nextCharge ? (+ <>{fmtMoney(nextCharge.amount)}{" "}- <span className="text-base text-muted">on {nextCharge.at}</span>+ <span className="text-sm font-normal text-muted">on {nextCharge.at}</span>+ </>+ ) : (+ "—"+ )+ }+ footer={+ <span className="text-xs text-muted">+ {nextCharge ? (+ <>+ {nextChargeSubline}+ {nextCharge.hasUsage && " · plus usage"}+ </>+ ) : (+ "No upcoming charge"+ )}+ </span>+ }+ />++ <StatTile+ title="What you pay"+ tone="org"+ icon={<CreditCard />}+ value={+ hasRecurring ? (+ <div className="flex flex-col gap-0.5">+ {billing.monthlyRecurring > 0 && (+ <div>+ {fmtMoney(billing.monthlyRecurring)}{" "}+ <span className="text-sm font-normal text-muted">/ mo recurring</span>+ </div>+ )}+ {billing.annualCommitted > 0 && (+ <div>+ {fmtMoney(billing.annualCommitted)}{" "}+ <span className="text-sm font-normal text-muted">/ yr committed</span>+ </div>+ )}</div>- <div className="text-xs text-muted">- {nextChargeSubline}- {nextCharge.hasUsage && " · plus usage"}+ ) : (+ "Free"+ )+ }+ footer={+ hasRecurring ? (+ <div className="flex items-center gap-1.5">+ {billing.monthlyRecurring > 0 && <Badge variant="info">Monthly</Badge>}+ {billing.annualCommitted > 0 && <Badge variant="warning">Annual</Badge>}</div>- </>- ) : (- <div className="text-sm text-muted">No upcoming charge</div>- )}- </HeaderColumn>-- <HeaderColumn label="What you pay">- {hasRecurring ? (- <div className="flex flex-col gap-1.5">- {billing.monthlyRecurring > 0 && (- <div className="flex items-center gap-2">- <span className="text-xl font-semibold text-foreground">- {fmtMoney(billing.monthlyRecurring)}- </span>- <span className="text-xs text-muted">/ mo recurring</span>- <Badge variant="info">Monthly</Badge>- </div>- )}- {billing.annualCommitted > 0 && (- <div className="flex items-center gap-2">- <span className="text-xl font-semibold text-foreground">- {fmtMoney(billing.annualCommitted)}- </span>- <span className="text-xs text-muted">/ yr committed</span>- <Badge variant="warning">Annual</Badge>- </div>- )}- </div>- ) : (- <div className="text-xl font-semibold text-foreground">Free</div>- )}- </HeaderColumn>+ ) : null+ }+ /></div>- <div className="flex items-start gap-2.5 border-t border-border px-6 py-4 text-xs text-muted">- <Info className="mt-0.5 size-4 shrink-0 text-info" />+ <div className="flex items-start gap-2 px-1 text-xs text-muted">+ <Info className="mt-[2px] size-3 shrink-0 text-muted" /><span>Each product bills on its own cadence. Monthly plans charge on their renewal day; annualplans are committed upfront, with usage above the commitment billed monthly on-demand.</span></div>- </Card>+ </div>);};diff --git a/frontend/src/pages/organization/BillingV2Page/components/cards/DetailsCard.tsx b/frontend/src/pages/organization/BillingV2Page/components/cards/DetailsCard.tsxindex 8c4481f44a..ffdf3b2a95 100644--- a/frontend/src/pages/organization/BillingV2Page/components/cards/DetailsCard.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/cards/DetailsCard.tsx@@ -54,7 +54,8 @@ export const DetailsCard = ({ overview, canManage, onEdit }: DetailsCardProps) =) : null;return (- <Card>+ // h-full so it matches the payment card's height when they share a row.+ <Card className="h-full"><CardHeader><CardTitle><Building2 className="size-4 text-accent" />diff --git a/frontend/src/pages/organization/BillingV2Page/components/cards/PaymentCard.tsx b/frontend/src/pages/organization/BillingV2Page/components/cards/PaymentCard.tsxindex 1e28ddb305..c2b3820c65 100644--- a/frontend/src/pages/organization/BillingV2Page/components/cards/PaymentCard.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/cards/PaymentCard.tsx@@ -12,7 +12,8 @@ type PaymentCardProps = {};export const PaymentCard = ({ overview, canManage, onUpdate }: PaymentCardProps) => (- <Card>+ // h-full so it matches the details card's height when they share a row.+ <Card className="h-full"><CardHeader><CardTitle><CreditCard className="size-4 text-accent" />diff --git a/frontend/src/pages/organization/BillingV2Page/components/cards/ProductsCard.tsx b/frontend/src/pages/organization/BillingV2Page/components/cards/ProductsCard.tsxindex 3f25f6ce60..6505febdd3 100644--- a/frontend/src/pages/organization/BillingV2Page/components/cards/ProductsCard.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/cards/ProductsCard.tsx@@ -1,4 +1,5 @@-import { ArrowBigUpDashIcon, Package } from "lucide-react";+import { ReactNode } from "react";+import { Package } from "lucide-react";import {Badge,@@ -14,74 +15,34 @@ import { BillingV2CatalogProduct, BillingV2Entitlement, BillingV2Overview } fromimport {byDisplayOrder,+ dimHasCeiling,fmtMoney,productAnnualCommitted,tierLabel} from "../../billing-v2-format";import { deprecationSubline } from "../deprecation/deprecation-data";-import { ActiveBadge, CadenceBadge, CardEmpty, DimensionMeter, ProductIcon } from "../shared";+import {+ ActiveBadge,+ CardEmpty,+ DimensionMeter,+ DimensionRateLegend,+ ProductIcon+} from "../shared";-type ProductRowProps = {+type ActiveProductCardProps = {prod: BillingV2CatalogProduct;entitlement?: BillingV2Entitlement;readOnly?: boolean;onManage: (id: string) => void;- onContact: (prod: BillingV2CatalogProduct) => void;};-const ProductRow = ({ prod, entitlement, readOnly, onManage, onContact }: ProductRowProps) => {- const entitled = Boolean(entitlement?.entitled);- const selfServe = prod.plans.some((plan) => plan.selfServe);- const salesLed = prod.plans.some((plan) => plan.salesLed);+// Full-width card for an active product: identity and status, price, Manage action, usage meters.+const ActiveProductCard = ({ prod, entitlement, readOnly, onManage }: ActiveProductCardProps) => {const deprecation = entitlement?.deprecation;const isProductDeprecated = deprecation?.kind === "product";const isPlanDeprecated = deprecation?.kind === "plan";- let action = null;- if (!readOnly) {- if (entitled) {- // A retiring plan nudges the customer toward the replacement; everything else opens Manage.- action = (- <Button variant="outline" size="sm" onClick={() => onManage(prod.id)}>- {isPlanDeprecated ? "Review plan" : "Manage"}- </Button>- );- } else if (selfServe) {- action = (- <Button variant="org" size="sm" onClick={() => onManage(prod.id)}>- <ArrowBigUpDashIcon />- Activate- </Button>- );- } else if (salesLed) {- action = (- <Button variant="org" size="sm" onClick={() => onContact(prod)}>- Contact sales- </Button>- );- }- }-- // Inactive product: compact row with the tagline and an activate / contact action.- if (!entitled) {- return (- <div className="flex items-center gap-4 border-t border-border py-4 first:border-t-0">- <ProductIcon product={prod} />- <div className="flex min-w-0 flex-1 flex-col gap-1">- <div className="flex flex-wrap items-center gap-2">- <span className="text-sm font-semibold text-foreground">{prod.name}</span>- {prod.addon && <Badge variant="neutral">Add-on</Badge>}- <Badge variant="neutral">Inactive</Badge>- </div>- <div className="text-xs text-muted">{prod.tagline}</div>- </div>- {action && <div className="flex shrink-0 items-center gap-1.5">{action}</div>}- </div>- );- }-- // Active product: cadence badge, renewal (or trial) line, and the price as two independent clocks- // (never summed) — the annual prepaid commitment and the monthly charge — plus one bar per dimension.+ // Two independent price clocks (never summed): the recurring charge plus any on-demand overage.const dims = entitlement?.dimensions ?? [];const onDemand = entitlement?.onDemandAmount ?? 0;const annualCommitted = productAnnualCommitted(entitlement);@@ -91,16 +52,51 @@ const ProductRow = ({ prod, entitlement, readOnly, onManage, onContact }: Producconst hasPrice = annualCommitted > 0 || monthlyRecurring > 0 || onDemand > 0;const isTrialing = Boolean(entitlement?.isTrialing);+ // The headline figure steps down a size when a second amount line shares the block.+ const priceLines = [annualCommitted > 0, monthlyRecurring > 0, onDemand > 0].filter(+ Boolean+ ).length;+ const figureClass = cn(+ "font-semibold text-foreground tabular-nums",+ priceLines > 1 ? "text-base" : "text-lg"+ );++ // Bar-bearing dims first so the block reads bars, then bare cost lines, then the shared legend.+ const sortedDims = [...dims].sort((a, b) => Number(dimHasCeiling(b)) - Number(dimHasCeiling(a)));++ // Cadence and renewal (or trial / deprecation) as one muted subline under the product name.+ let subline: ReactNode = null;+ if (deprecation) {+ subline = (+ <span className={isProductDeprecated ? "text-danger" : "text-warning"}>+ {deprecationSubline(deprecation, entitlement?.planTier)}+ </span>+ );+ } else if (isTrialing) {+ subline = entitlement?.trialEndsAt ? (+ <span>Trial ends {entitlement.trialEndsAt}</span>+ ) : (+ entitlement?.renewsOn && <span>Renews {entitlement.renewsOn}</span>+ );+ } else {+ subline = (+ <span>+ {entitlement?.cadence === "annual" ? "Yearly" : "Monthly"}+ {entitlement?.renewsOn ? ` · renews ${entitlement.renewsOn}` : ""}+ </span>+ );+ }+return (- <div className="flex flex-col gap-3 border-t border-border py-4 first:border-t-0">- <div className="flex items-center gap-4">+ <div className="flex flex-col gap-3 rounded-lg border border-border bg-container p-4">+ <div className="flex items-center gap-3">{/* A discontinued product's icon is dimmed so a glance down the list reads it as winding down. */}<div className={isProductDeprecated ? "opacity-40 grayscale" : undefined}>- <ProductIcon product={prod} />+ <ProductIcon product={prod} size={40} /></div>- <div className="flex min-w-0 flex-1 flex-col gap-1.5">+ <div className="flex min-w-0 flex-1 flex-col gap-0.5"><div className="flex flex-wrap items-center gap-2">- <span className="text-sm font-semibold text-foreground">{prod.name}</span>+ <span className="text-[15px] font-semibold text-foreground">{prod.name}</span>{/* Plan retiring: strikethrough tier chip in warning tone. Otherwise the plain tier chip. */}{entitlement?.planTier &&(isPlanDeprecated ? (@@ -108,68 +104,106 @@ const ProductRow = ({ prod, entitlement, readOnly, onManage, onContact }: Produc{tierLabel(entitlement.planTier)}</Badge>) : (- <Badge variant="neutral">{tierLabel(entitlement.planTier)}</Badge>+ <Badge variant="info">{tierLabel(entitlement.planTier)}</Badge>))}{isProductDeprecated && <Badge variant="danger">Deprecated</Badge>}{prod.addon && <Badge variant="neutral">Add-on</Badge>}{isTrialing ? <Badge variant="info">Trial</Badge> : <ActiveBadge />}</div>- <div className="flex min-w-0 flex-wrap items-center gap-2 text-xs text-muted">- {deprecation ? (- <span- className={cn("truncate", isProductDeprecated ? "text-danger" : "text-warning")}- >- {deprecationSubline(deprecation, entitlement?.planTier)}- </span>- ) : (- <>- {!isTrialing && <CadenceBadge cadence={entitlement?.cadence} />}- {isTrialing && entitlement?.trialEndsAt ? (- <span>Trial ends {entitlement.trialEndsAt}</span>- ) : (- entitlement?.renewsOn && <span>Renews {entitlement.renewsOn}</span>- )}- </>- )}- </div>+ <div className="truncate text-xs text-muted">{subline}</div></div><div className="flex shrink-0 flex-col items-end gap-0.5">{annualCommitted > 0 && (<div className="flex items-baseline gap-1">- <span className="text-sm font-semibold text-foreground tabular-nums">- {fmtMoney(annualCommitted)}- </span>- <span className="text-xs text-muted">/ yr </span>+ <span className={figureClass}>{fmtMoney(annualCommitted)}</span>+ <span className="text-xs text-accent">/ yr committed</span></div>)}{monthlyRecurring > 0 && (<div className="flex items-baseline gap-1">- <span className="text-sm font-semibold text-foreground tabular-nums">- {fmtMoney(monthlyRecurring)}- </span>- <span className="text-xs text-muted">/ mo</span>+ <span className={figureClass}>{fmtMoney(monthlyRecurring)}</span>+ <span className="text-xs text-accent">/ mo</span></div>)}{onDemand > 0 && (- <span className="text-xs font-medium text-warning">- + {fmtMoney(onDemand)} / mo on-demand+ <span className="text-xs text-accent">+ <span className="font-medium text-warning/90">+{fmtMoney(onDemand)}</span> / mo+ on-demand</span>)}{!hasPrice && <span className="text-sm text-muted">Included</span>}</div>- {action && <div className="flex shrink-0 items-center gap-1.5">{action}</div>}+ {!readOnly && (+ // A retiring plan nudges the customer toward the replacement; everything else opens Manage.+ <Button+ variant="outline"+ size="sm"+ className="shrink-0"+ onClick={() => onManage(prod.id)}+ >+ {isPlanDeprecated ? "Review plan" : "Manage"}+ </Button>+ )}</div>- {dims.length > 0 && (- <div className="flex flex-col gap-3 pl-[52px]">- {dims.map((dim) => (- <DimensionMeter key={dim.key} dim={dim} />+ {sortedDims.length > 0 && (+ <div className="flex flex-col gap-2.5">+ {sortedDims.map((dim) => (+ <DimensionMeter key={dim.key} dim={dim} hideLegend />))}+ <DimensionRateLegend dims={sortedDims} /></div>)}</div>);};+type AvailableProductTileProps = {+ prod: BillingV2CatalogProduct;+ readOnly?: boolean;+ onManage: (id: string) => void;+ onContact: (prod: BillingV2CatalogProduct) => void;+};++// Compact tile for a product the org doesn't hold yet: tagline plus an activate / contact action.+const AvailableProductTile = ({+ prod,+ readOnly,+ onManage,+ onContact+}: AvailableProductTileProps) => {+ const selfServe = prod.plans.some((plan) => plan.selfServe);+ const salesLed = prod.plans.some((plan) => plan.salesLed);++ let action = null;+ if (!readOnly) {+ if (selfServe) {+ action = (+ <Button variant="org" size="sm" onClick={() => onManage(prod.id)}>+ Activate+ </Button>+ );+ } else if (salesLed) {+ action = (+ <Button variant="outline" size="sm" onClick={() => onContact(prod)}>+ Contact sales+ </Button>+ );+ }+ }++ return (+ <div className="flex flex-col gap-3 rounded-lg border border-border bg-container p-4">+ <div className="flex flex-wrap items-center gap-2.5">+ <ProductIcon product={prod} />+ <span className="text-sm font-semibold text-foreground">{prod.name}</span>+ {prod.addon && <Badge variant="neutral">Add-on</Badge>}+ </div>+ {prod.tagline && <p className="text-sm text-muted">{prod.tagline}</p>}+ {action && <div className="mt-auto pt-1">{action}</div>}+ </div>+ );+};+type ProductsCardProps = {overview: BillingV2Overview;catalog: BillingV2CatalogProduct[];@@ -190,6 +224,9 @@ export const ProductsCard = ({const visible = [...catalog].filter((prod) => !prod.deprecated || overview.entitlements[prod.id]?.entitled).sort(byDisplayOrder);+ const active = visible.filter((prod) => overview.entitlements[prod.id]?.entitled);+ const available = visible.filter((prod) => !overview.entitlements[prod.id]?.entitled);+return (<Card><CardHeader>@@ -206,17 +243,38 @@ export const ProductsCard = ({description="Products will appear here once they're available."/>) : (- <div className="flex flex-col">- {visible.map((prod) => (- <ProductRow+ <div className="flex flex-col gap-4">+ {active.map((prod) => (+ <ActiveProductCardkey={prod.id}prod={prod}entitlement={overview.entitlements[prod.id]}readOnly={readOnly}onManage={onManage}- onContact={onContact}/>))}+ {available.length > 0 && (+ <>+ <div className="flex items-center gap-3 pt-1">+ <span className="text-sm font-medium text-muted">Available to add</span>+ <div className="h-px flex-1 bg-border" />+ </div>+ {/* Container-keyed columns: the collapsible sidebar changes the room, not the viewport. */}+ <div className="@container">+ <div className="grid gap-4 @2xl:grid-cols-2 @4xl:grid-cols-3">+ {available.map((prod) => (+ <AvailableProductTile+ key={prod.id}+ prod={prod}+ readOnly={readOnly}+ onManage={onManage}+ onContact={onContact}+ />+ ))}+ </div>+ </div>+ </>+ )}</div>)}</CardContent>diff --git a/frontend/src/pages/organization/BillingV2Page/components/deprecation/DeprecationBanners.tsx b/frontend/src/pages/organization/BillingV2Page/components/deprecation/DeprecationBanners.tsxindex 855791e618..5b35bd319d 100644--- a/frontend/src/pages/organization/BillingV2Page/components/deprecation/DeprecationBanners.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/deprecation/DeprecationBanners.tsx@@ -1,5 +1,5 @@import { useState } from "react";-import { CircleAlert, TriangleAlert } from "lucide-react";+import { TriangleAlert } from "lucide-react";import {Alert,@@ -72,7 +72,7 @@ export const DeprecationBanners = ({return (<Alert key={productId} variant={variant}>- {isProduct ? <CircleAlert /> : <TriangleAlert />}+ <TriangleAlert /><AlertTitle>{title}</AlertTitle><AlertDescription><span className="line-clamp-2">@@ -87,17 +87,17 @@ export const DeprecationBanners = ({<div className="mt-3 flex flex-wrap gap-2">{isProduct ? (catalogProduct && (- <Button variant="danger" size="sm" onClick={() => onContact(catalogProduct)}>+ <Button variant="danger" size="xs" onClick={() => onContact(catalogProduct)}>Contact support</Button>)) : (- <Button variant="outline" size="sm" onClick={() => onManage(productId)}>+ <Button variant="outline" size="xs" onClick={() => onManage(productId)}>Review plan</Button>)}{hasDetail && (- <Button variant="ghost" size="sm" onClick={() => setDetail(entry)}>+ <Button variant="ghost" size="xs" onClick={() => setDetail(entry)}>See what changes</Button>)}@@ -108,7 +108,7 @@ export const DeprecationBanners = ({})}<Dialog open={Boolean(detail)} onOpenChange={(open) => !open && setDetail(null)}>- <DialogContent className="max-w-md">+ <DialogContent className="max-w-xl">{detail && <DeprecationDetailBody entry={detail} />}</DialogContent></Dialog>diff --git a/frontend/src/pages/organization/BillingV2Page/components/deprecation/DeprecationDetailBody.tsx b/frontend/src/pages/organization/BillingV2Page/components/deprecation/DeprecationDetailBody.tsxindex 53b92e940d..ee38fb0d07 100644--- a/frontend/src/pages/organization/BillingV2Page/components/deprecation/DeprecationDetailBody.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/deprecation/DeprecationDetailBody.tsx@@ -1,18 +1,23 @@-import { CircleAlert, Clock, TriangleAlert } from "lucide-react";+import { Clock, TriangleAlert } from "lucide-react";-import { DialogHeader, DialogTitle } from "@app/components/v3";+import {+ Alert,+ AlertTitle,+ DialogDescription,+ DialogHeader,+ DialogTitle+} from "@app/components/v3";import { cn } from "@app/components/v3/utils";import { tierLabel } from "../../billing-v2-format";-import { daysLeftLabel, DeprecatedEntry, DEPRECATION_TONE } from "./deprecation-data";+import { daysLeftLabel, DeprecatedEntry } from "./deprecation-data";-// Rich "See what changes" dialog body: an icon + title/subtitle header, the sunset date as a pill with-// a day-countdown chip, then the full (untruncated) reason and next-steps sections.+// "See what changes" dialog body: sunset-date alert with countdown, full reason and next steps.export const DeprecationDetailBody = ({ entry }: { entry: DeprecatedEntry }) => {const { deprecation, name, planTier } = entry;const isProduct = deprecation.kind === "product";const urgent = deprecation.daysLeft !== null && deprecation.daysLeft <= 14;- const tone = DEPRECATION_TONE[isProduct || urgent ? "danger" : "warning"];+ const variant = isProduct || urgent ? "danger" : "warning";const label = daysLeftLabel(deprecation.daysLeft);const title = isProduct? `${name} is being discontinued`@@ -25,53 +30,46 @@ export const DeprecationDetailBody = ({ entry }: { entry: DeprecatedEntry }) =><><DialogHeader><div className="flex items-start gap-3">- <div- className={cn(- "flex size-9 shrink-0 items-center justify-center rounded-lg border [&>svg]:size-4",- tone.iconBox- )}- >- {isProduct ? <CircleAlert /> : <TriangleAlert />}+ <div className="flex size-7 shrink-0 items-center justify-center">+ <TriangleAlert className="size-6 text-muted" /></div><div className="flex min-w-0 flex-col gap-0.5"><DialogTitle>{title}</DialogTitle>- <span className="truncate text-xs text-muted">{subtitle}</span>+ <DialogDescription>{subtitle}</DialogDescription></div></div></DialogHeader><div className="flex flex-col gap-4">{deprecation.date && (- <div- className={cn(- "flex flex-wrap items-center gap-2 rounded-lg border px-3 py-2",- tone.pill- )}- >- <Clock className="size-4 text-muted" />- <span className="text-sm text-foreground">- {isProduct ? "Access ends" : "Retires"}{" "}- <span className="font-medium">{deprecation.date}</span>- </span>- {label && (- <span- className={cn("ml-auto rounded-md px-1.5 py-0.5 text-xs font-medium", tone.chip)}- >- {label}+ <Alert variant={variant}>+ <Clock />+ <AlertTitle className="flex flex-wrap items-center gap-2">+ <span>+ {isProduct ? "Access ends" : "Retires"}{" "}+ <span className="font-medium">{deprecation.date}</span></span>- )}- </div>+ {label && (+ <span+ className={cn(+ "ml-auto text-xs",+ variant === "danger" ? "text-danger" : "text-warning"+ )}+ >+ {label}+ </span>+ )}+ </AlertTitle>+ </Alert>)}{deprecation.reason && (<div className="flex flex-col gap-1">- <span className="text-[11px] font-medium tracking-wide text-muted uppercase">Why</span>+ <span className="text-xs font-medium text-label">Why</span><p className="text-sm text-foreground">{deprecation.reason}</p></div>)}{deprecation.nextSteps && (<div className="flex flex-col gap-1">- <span className="text-[11px] font-medium tracking-wide text-muted uppercase">- What to do- </span>+ <span className="text-xs font-medium text-label">What to do</span><p className="text-sm text-foreground">{deprecation.nextSteps}</p></div>)}diff --git a/frontend/src/pages/organization/BillingV2Page/components/deprecation/deprecation-data.ts b/frontend/src/pages/organization/BillingV2Page/components/deprecation/deprecation-data.tsindex 4c1818ce84..61f9f9513f 100644--- a/frontend/src/pages/organization/BillingV2Page/components/deprecation/deprecation-data.ts+++ b/frontend/src/pages/organization/BillingV2Page/components/deprecation/deprecation-data.ts@@ -11,23 +11,6 @@ export type DeprecatedEntry = {deprecation: Deprecation;};-// Tone tokens for the banner / dialog: warning for a retiring plan, danger for a discontinued product-// (a retiring plan escalates to danger inside the final window).-export const DEPRECATION_TONE = {- warning: {- container: "border-warning/30 bg-warning/[0.04]",- iconBox: "border-warning/20 bg-warning/10 text-warning",- pill: "border-warning/20 bg-warning/[0.06]",- chip: "border border-warning/30 bg-warning/10 text-warning"- },- danger: {- container: "border-danger/30 bg-danger/[0.04]",- iconBox: "border-danger/20 bg-danger/10 text-danger",- pill: "border-danger/20 bg-danger/[0.06]",- chip: "border border-danger/30 bg-danger/10 text-danger"- }-};-export const daysLeftLabel = (daysLeft: number | null): string | null => {if (daysLeft === null) {return null;diff --git a/frontend/src/pages/organization/BillingV2Page/components/shared.tsx b/frontend/src/pages/organization/BillingV2Page/components/shared.tsxindex 9646091ca2..15fe5c2272 100644--- a/frontend/src/pages/organization/BillingV2Page/components/shared.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/shared.tsx@@ -1,4 +1,4 @@-import { ReactNode } from "react";+import { Fragment, ReactNode, useState } from "react";import { Box, MinusIcon, PlusIcon } from "lucide-react";import { DynamicIcon, type IconName } from "lucide-react/dynamic";@@ -8,17 +8,21 @@ import {Empty,EmptyDescription,EmptyHeader,- EmptyTitle+ EmptyTitle,+ Item,+ ItemContent,+ ItemDescription,+ ItemGroup,+ ItemTitle,+ Skeleton} from "@app/components/v3";-import {- BillingV2CatalogProduct,- BillingV2Entitlement,- BillingV2EntitlementDim-} from "@app/hooks/api";+import { cn } from "@app/components/v3/utils";+import { BillingV2CatalogProduct, BillingV2EntitlementDim } from "@app/hooks/api";import {dimAnnualCommitted,dimBarSegments,+ dimHasCeiling,dimMonthlyRate,dimOnDemandQuantity,fmtMoney,@@ -72,26 +76,94 @@ export const CardEmpty = ({ title, description }: { title: string; description?:</Empty>);-// A YEARLY / MONTHLY cadence pill matching a product's billing cadence.-export const CadenceBadge = ({ cadence }: { cadence: BillingV2Entitlement["cadence"] }) => {- if (cadence === "annual") {- return <Badge variant="info">Yearly</Badge>;+// Checkout-style cost summary for the sheets: borderless Items joined into one bordered frame.+export const CostSummary = ({ children }: { children: ReactNode }) => (+ <ItemGroup className="gap-0 divide-y divide-border rounded-lg border border-border bg-card">+ {children}+ </ItemGroup>+);++type CostSummaryRowProps = {+ label: string;+ note?: ReactNode;+ value: string;+ // Swaps the price for a skeleton while re-pricing so a stale or zero amount never shows.+ isCalculating?: boolean;+ // Price overrides: text-base headlines "charged today"; text-warning/90 marks on-demand amounts.+ valueClassName?: string;+};++export const CostSummaryRow = ({+ label,+ note,+ value,+ isCalculating,+ valueClassName+}: CostSummaryRowProps) => (+ <Item className="p-4">+ <ItemContent>+ <ItemTitle>{label}</ItemTitle>+ {note ? <ItemDescription className="text-xs text-muted">{note}</ItemDescription> : null}+ </ItemContent>+ {isCalculating ? (+ <Skeleton className="h-5 w-20 shrink-0" />+ ) : (+ <span+ className={cn("shrink-0 text-sm font-medium text-foreground tabular-nums", valueClassName)}+ >+ {value}+ </span>+ )}+ </Item>+);++// Rate legend for annually-committed dimensions. DimensionMeter renders it per dim by default; a+// caller can hideLegend the meters and render one combined legend for the block.+export const DimensionRateLegend = ({ dims }: { dims: BillingV2EntitlementDim[] }) => {+ const entries = dims.filter(+ (dim) =>+ dimAnnualCommitted(dim) && (dim.committedRate !== undefined || dim.onDemandRate !== undefined)+ );+ if (entries.length === 0) {+ return null;}- return <Badge variant="neutral">Monthly</Badge>;+ return (+ <div className="flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted">+ {entries.map((dim) => (+ <Fragment key={dim.key}>+ {dim.committedRate !== undefined && (+ <span className="flex items-center gap-1.5">+ <span className="size-2 rounded-full bg-primary/85" />+ Committed {`${fmtMoney(dim.committedRate)} / ${dim.noun} /yr`}+ </span>+ )}+ {dim.onDemandRate !== undefined && (+ <span className="flex items-center gap-1.5">+ <span className="size-2 rounded-full bg-warning/85" />+ On-demand {`${fmtMoney(dim.onDemandRate)} / ${dim.noun} /mo`}+ </span>+ )}+ </Fragment>+ ))}+ </div>+ );+};++type DimensionMeterProps = {+ dim: BillingV2EntitlementDim;+ // Suppress the per-dimension rate legend (the caller renders a combined DimensionRateLegend).+ hideLegend?: boolean;};-// One usage line for a product dimension. An annual committed dimension shows the committed portion-// (blue) plus any on-demand overflow (amber) with a rate legend; a capped monthly/metered dimension-// shows a single "{used} / {limit} · $rate/unit/mo" fill. A dimension with no ceiling (uncapped-// monthly/metered) has nothing to track, so we drop the bar and render the cost line on its own.-export const DimensionMeter = ({ dim }: { dim: BillingV2EntitlementDim }) => {+// One usage line for a product dimension: an annual committed dimension shows committed fill plus+// on-demand overflow with a rate legend; a capped dimension a single used/limit fill; an uncapped+// one just its cost line, no bar.+export const DimensionMeter = ({ dim, hideLegend }: DimensionMeterProps) => {const committed = dimAnnualCommitted(dim);const { committedPct, onDemandPct } = dimBarSegments(dim);const onDemandQty = dimOnDemandQuantity(dim);const monthlyRate = dimMonthlyRate(dim);- // A bar only earns its place when there's a ceiling to fill against: an annual commitment or a- // finite limit. A bar that can never fill is noise, so an uncapped dimension is a cost line only.- const hasCeiling = committed || (dim.limit !== null && dim.limit > 0);+ const hasCeiling = dimHasCeiling(dim);let right: ReactNode;if (committed) {@@ -102,7 +174,7 @@ export const DimensionMeter = ({ dim }: { dim: BillingV2EntitlementDim }) => {{onDemandQty > 0 ? (<>{" · "}- <span className="font-medium text-warning">+ <span className="font-medium text-warning/90">{onDemandQty.toLocaleString()} on-demand</span></>@@ -128,35 +200,24 @@ export const DimensionMeter = ({ dim }: { dim: BillingV2EntitlementDim }) => {<span className="text-muted tabular-nums">{right}</span></div>{hasCeiling && (- <div className="flex h-1.5 w-full gap-0.5 overflow-hidden rounded-full bg-border">+ <div className="flex h-[5px] w-full gap-0.5 overflow-hidden rounded-xs bg-border">+ {/* Segments keep the soft outer corner but sit square against each other at the joint. */}<div- className="h-full rounded-full bg-primary transition-all"+ className={cn(+ "h-full rounded-xs bg-primary/85 transition-all",+ onDemandPct > 0 && "rounded-r-none"+ )}style={{ width: `${committedPct}%` }}/>{onDemandPct > 0 && (<div- className="h-full rounded-full bg-warning transition-all"+ className="h-full rounded-xs rounded-l-none bg-warning/85 transition-all"style={{ width: `${onDemandPct}%` }}/>)}</div>)}- {committed && (- <div className="flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted">- {dim.committedRate !== undefined && (- <span className="flex items-center gap-1.5">- <span className="size-2.5 rounded-sm bg-primary" />- Committed {`${fmtMoney(dim.committedRate)} / ${dim.noun} /yr`}- </span>- )}- {dim.onDemandRate !== undefined && (- <span className="flex items-center gap-1.5">- <span className="size-2.5 rounded-sm bg-warning" />- On-demand {`${fmtMoney(dim.onDemandRate)} / ${dim.noun} /mo`}- </span>- )}- </div>- )}+ {committed && !hideLegend && <DimensionRateLegend dims={[dim]} />}</div>);};@@ -164,35 +225,74 @@ export const DimensionMeter = ({ dim }: { dim: BillingV2EntitlementDim }) => {type StepperProps = {value: number;min?: number;+ max?: number;onChange: (value: number) => void;isDisabled?: boolean;};-// A small [-] [value] [+] quantity control for setting a commitment count.-export const Stepper = ({ value, min = 0, onChange, isDisabled }: StepperProps) => (- <div className="flex items-center overflow-hidden rounded-md border border-border">- <Button- variant="ghost"- size="sm"- className="rounded-none px-3"- isDisabled={isDisabled || value <= min}- onClick={() => onChange(Math.max(min, value - 1))}- aria-label="Decrease"- >- <MinusIcon className="size-4" />- </Button>- <span className="min-w-12 border-x border-border py-1.5 text-center text-sm font-medium text-foreground tabular-nums">- {value.toLocaleString()}- </span>- <Button- variant="ghost"- size="sm"- className="rounded-none px-3"- isDisabled={isDisabled}- onClick={() => onChange(value + 1)}- aria-label="Increase"- >- <PlusIcon className="size-4" />- </Button>- </div>-);+// A [-] [value] [+] quantity control. Values can be typed too: digits commit live while focused,+// blur/Enter clamps to [min, max], an empty draft reverts, and typing past max snaps down.+export const Stepper = ({ value, min = 0, max = 9999, onChange, isDisabled }: StepperProps) => {+ // Raw digits while typing; null when idle (the field shows the committed value).+ const [draft, setDraft] = useState<string | null>(null);++ const clamp = (n: number) => Math.min(max, Math.max(min, n));++ const commitDraft = () => {+ if (draft) {+ onChange(clamp(parseInt(draft, 10)));+ }+ setDraft(null);+ };++ return (+ <div className="flex items-center overflow-hidden rounded-md border border-border">+ <Button+ variant="ghost"+ size="sm"+ className="rounded-none px-3"+ isDisabled={isDisabled || value <= min}+ onClick={() => onChange(clamp(value - 1))}+ aria-label="Decrease"+ >+ <MinusIcon className="size-4" />+ </Button>+ <input+ type="text"+ inputMode="numeric"+ value={draft ?? value.toLocaleString()}+ onFocus={(e) => {+ setDraft(String(value));+ e.currentTarget.select();+ }}+ onChange={(e) => {+ const digits = e.target.value.replace(/\D/g, "");+ const capped = digits && parseInt(digits, 10) > max ? String(max) : digits;+ setDraft(capped);+ if (capped) {+ onChange(clamp(parseInt(capped, 10)));+ }+ }}+ onBlur={commitDraft}+ onKeyDown={(e) => {+ if (e.key === "Enter") {+ e.currentTarget.blur();+ }+ }}+ disabled={isDisabled}+ aria-label="Quantity"+ className="w-14 border-x border-border bg-transparent py-1.5 text-center text-sm font-medium text-foreground tabular-nums outline-none focus:bg-container disabled:cursor-not-allowed disabled:opacity-50"+ />+ <Button+ variant="ghost"+ size="sm"+ className="rounded-none px-3"+ isDisabled={isDisabled || value >= max}+ onClick={() => onChange(clamp(value + 1))}+ aria-label="Increase"+ >+ <PlusIcon className="size-4" />+ </Button>+ </div>+ );+};