Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions src/app/settings/sections/billing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ function PlanRow({
<>
{description ? <br /> : null}
{plan === 'free'
? `${current.credits.toLocaleString()} credits a month, good for about ${current.searches.toLocaleString()} web searches; cloud models need a paid plan.`
: `${current.credits.toLocaleString()} credits a month, shared by cloud models and web searches.`}
? 'Cloud models need a paid plan.'
: `${current.credits.toLocaleString()} credits a month for cloud models.`}
</>
)}
</>
Expand All @@ -168,15 +168,13 @@ function PlanRow({
);
}

/** What a plan buys, as lines on its card: only what the API meters. One
* pool pays for cloud models and web searches alike, so the searches line
* says what the credits would stretch to, not a second allowance. */
/** What a plan buys, as lines on its card: cloud models and the monthly
* credits that pay for them. */
const planPerks = (p: PlanInfo, below: PlanInfo | null): string[] => {
const perks: string[] = [];
if (below && below.id !== 'free') perks.push(`Everything in ${below.name}`);
perks.push(`${p.credits.toLocaleString()} credits a month`);
perks.push('Cloud models, charged by what each call reads and writes');
perks.push(`Web searches from the same credits, up to ${p.searches.toLocaleString()} a month`);
return perks;
};

Expand Down Expand Up @@ -364,15 +362,11 @@ export default function BillingSection() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [user]);

// A user is Pro if the subscription endpoint reports premium/active OR the
// account itself is flagged paid/premium (premium granted outside Stripe has
// no subscription object, so /payments/subscription 404s).
const hasActiveSubscription = subscription?.status === 'active' || subscription?.status === 'will_cancel';
// Billing reflects what the account pays for, not its entitlements: an
// admin or hand-granted premium account with no subscription shows Free.
const isPro = hasActiveSubscription || !!subscription?.is_premium || (user?.billing_plan ?? 'free') !== 'free';
// Which plan, as the API names it: free, paid (Pro), plus or admin.
const plan: string = subscription?.plan ?? user?.billing_plan ?? (isPro ? 'paid' : 'free');
// Which plan the account pays for, as the API names it: free, paid (Pro),
// plus or max. Everything below follows it, so a stale subscription status
// can never put an "Active" chip next to Free.
const plan: string = subscription?.plan ?? user?.billing_plan ?? 'free';
const isPro = plan !== 'free';
const willCancel = subscription?.status === 'will_cancel';
// current_period_end is an ISO date-time string from the API.
const periodEnd = subscription?.current_period_end
Expand Down Expand Up @@ -450,7 +444,7 @@ export default function BillingSection() {
plans={plans}
description={
<>
Need more credits, more searches, or email support?{' '}
Want cloud models, more credits, or email support?{' '}
<a
href={PRICING_URL}
target="_blank"
Expand Down
23 changes: 0 additions & 23 deletions src/app/settings/sections/websearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,29 +191,6 @@ export default function WebSearchSection({ user }: { user: any }) {
</Row>
)}

{/* Only on the plans that have somewhere to go. Shown before the
limit is hit as well as after — finding out at zero is too late
to be useful. The allowances themselves are on the billing page,
read from the API, so no number is kept here. */}
{(quota?.plan === 'free' || quota?.plan === 'paid' || quota?.plan === 'plus') && (
<Row
label="Need more searches?"
description={
quota.plan === 'free'
? 'Pro brings more monthly credits, and Plus and Max more still.'
: quota.plan === 'paid'
? 'Plus brings more monthly credits, and Max the most.'
: 'Max brings the most monthly credits.'
}
>
<a
href="/settings/billing"
className="inline-flex items-center justify-center px-4 py-2.5 rounded-lg text-sm font-medium transition-colors border border-accent-border hover:bg-accent-soft text-accent-text whitespace-nowrap"
>
{quota.plan === 'free' ? 'See plans' : quota.plan === 'paid' ? 'Upgrade to Plus' : 'Upgrade to Max'}
</a>
</Row>
)}
</>
)}

Expand Down
Loading