mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-29 02:39:13 +00:00
fix(plans): word flat subscriptions past their price as API value (#1723)
A preset subscription plan (SuperGrok, Cursor Pro, Google AI) past its price showed "$X over" in red and "On pace to exceed", but a flat subscription is not billed overage. Those cards now read "13.6x your plan's price in API value" with a neutral bar and projection; custom plans keep the cap wording.
This commit is contained in:
parent
389c14ce5e
commit
ddacfcbf15
3 changed files with 50 additions and 6 deletions
|
|
@ -42,12 +42,14 @@ export const plans: SectionCatalog = {
|
|||
'plans.date.unknown': 'unknown',
|
||||
'plans.card.spentPercent': '{spent} · {percent}',
|
||||
'plans.card.spentPercentOver': '{spent} · {percent} · {overage} over',
|
||||
'plans.card.spentValueMultiple': "{spent} · {multiple}x your plan's price in API value",
|
||||
'plans.card.spentThisCycle': '{spent} this cycle',
|
||||
'plans.card.budgetDetail': '{budget} / month budget · API-equivalent, not a live provider window · {provider}',
|
||||
'plans.card.noPlanDetail': '{provider} · pay as you go, no plan',
|
||||
'plans.pace.exceed': 'On pace to exceed; projected {projected} by {date}',
|
||||
'plans.pace.near': '{percent} of budget used; projected {projected} by {date}',
|
||||
'plans.pace.onTrack': 'On track',
|
||||
'plans.pace.value': 'Projected {projected} in API value by {date}',
|
||||
},
|
||||
fr: {
|
||||
'plans.title': 'Forfaits',
|
||||
|
|
@ -90,12 +92,14 @@ export const plans: SectionCatalog = {
|
|||
'plans.date.unknown': 'inconnu',
|
||||
'plans.card.spentPercent': '{spent} · {percent}',
|
||||
'plans.card.spentPercentOver': '{spent} · {percent} · {overage} de dépassement',
|
||||
'plans.card.spentValueMultiple': '{spent} · {multiple}x le prix de votre forfait en valeur API',
|
||||
'plans.card.spentThisCycle': '{spent} sur ce cycle',
|
||||
'plans.card.budgetDetail': '{budget} / budget mensuel · équivalent API, pas une fenêtre fournisseur en direct · {provider}',
|
||||
'plans.card.noPlanDetail': "{provider} · paiement à l'usage, sans forfait",
|
||||
'plans.pace.exceed': 'En voie de dépassement ; projection de {projected} au {date}',
|
||||
'plans.pace.near': '{percent} du budget utilisé ; projection de {projected} au {date}',
|
||||
'plans.pace.onTrack': 'Sur la bonne voie',
|
||||
'plans.pace.value': 'Projection de {projected} en valeur API au {date}',
|
||||
},
|
||||
ja: {
|
||||
'plans.title': 'プラン',
|
||||
|
|
@ -138,12 +142,14 @@ export const plans: SectionCatalog = {
|
|||
'plans.date.unknown': '不明',
|
||||
'plans.card.spentPercent': '{spent} · {percent}',
|
||||
'plans.card.spentPercentOver': '{spent} · {percent} · {overage} 超過',
|
||||
'plans.card.spentValueMultiple': '{spent} · プラン料金の{multiple}倍のAPI相当額',
|
||||
'plans.card.spentThisCycle': '今サイクルで{spent}',
|
||||
'plans.card.budgetDetail': '{budget} / 月間予算 · API相当、実際のプロバイダーウィンドウではありません · {provider}',
|
||||
'plans.card.noPlanDetail': '{provider} · 従量課金、プランなし',
|
||||
'plans.pace.exceed': '超過ペース:{date}までに{projected}の見込み',
|
||||
'plans.pace.near': '予算の{percent}を使用済み:{date}までに{projected}の見込み',
|
||||
'plans.pace.onTrack': '順調',
|
||||
'plans.pace.value': '{date}までにAPI相当額{projected}の見込み',
|
||||
},
|
||||
ko: {
|
||||
'plans.title': '요금제',
|
||||
|
|
@ -186,12 +192,14 @@ export const plans: SectionCatalog = {
|
|||
'plans.date.unknown': '알 수 없음',
|
||||
'plans.card.spentPercent': '{spent} · {percent}',
|
||||
'plans.card.spentPercentOver': '{spent} · {percent} · {overage} 초과',
|
||||
'plans.card.spentValueMultiple': '{spent} · 요금제 가격의 {multiple}배 API 환산 가치',
|
||||
'plans.card.spentThisCycle': '이번 주기 {spent}',
|
||||
'plans.card.budgetDetail': '{budget} / 월 예산 · API 환산, 실제 제공자 윈도우 아님 · {provider}',
|
||||
'plans.card.noPlanDetail': '{provider} · 종량제, 요금제 없음',
|
||||
'plans.pace.exceed': '초과 예상; {date}까지 {projected} 예상',
|
||||
'plans.pace.near': '예산의 {percent} 사용됨; {date}까지 {projected} 예상',
|
||||
'plans.pace.onTrack': '정상 진행',
|
||||
'plans.pace.value': '{date}까지 API 환산 {projected} 예상',
|
||||
},
|
||||
zhCN: {
|
||||
'plans.title': '套餐',
|
||||
|
|
@ -234,12 +242,14 @@ export const plans: SectionCatalog = {
|
|||
'plans.date.unknown': '未知',
|
||||
'plans.card.spentPercent': '{spent} · {percent}',
|
||||
'plans.card.spentPercentOver': '{spent} · {percent} · 超出 {overage}',
|
||||
'plans.card.spentValueMultiple': '{spent} · 相当于套餐价格 {multiple} 倍的 API 用量',
|
||||
'plans.card.spentThisCycle': '本周期 {spent}',
|
||||
'plans.card.budgetDetail': '{budget} / 每月预算 · 相当于 API 用量,并非实时提供商窗口 · {provider}',
|
||||
'plans.card.noPlanDetail': '{provider} · 按量付费,无套餐',
|
||||
'plans.pace.exceed': '预计将超支;预计到 {date} 为 {projected}',
|
||||
'plans.pace.near': '已使用预算的 {percent};预计到 {date} 为 {projected}',
|
||||
'plans.pace.onTrack': '进度正常',
|
||||
'plans.pace.value': '预计到 {date} API 用量价值 {projected}',
|
||||
},
|
||||
zhTW: {
|
||||
'plans.title': '方案',
|
||||
|
|
@ -282,11 +292,13 @@ export const plans: SectionCatalog = {
|
|||
'plans.date.unknown': '未知',
|
||||
'plans.card.spentPercent': '{spent} · {percent}',
|
||||
'plans.card.spentPercentOver': '{spent} · {percent} · 超出 {overage}',
|
||||
'plans.card.spentValueMultiple': '{spent} · 相當於方案價格 {multiple} 倍的 API 用量',
|
||||
'plans.card.spentThisCycle': '本週期 {spent}',
|
||||
'plans.card.budgetDetail': '{budget} / 每月預算 · 相當於 API 用量,並非即時供應商視窗 · {provider}',
|
||||
'plans.card.noPlanDetail': '{provider} · 按量付費,無方案',
|
||||
'plans.pace.exceed': '預計將超支;預計到 {date} 為 {projected}',
|
||||
'plans.pace.near': '已使用預算的 {percent};預計到 {date} 為 {projected}',
|
||||
'plans.pace.onTrack': '進度正常',
|
||||
'plans.pace.value': '預計到 {date} API 用量價值 {projected}',
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,17 +130,17 @@ describe('Plans', () => {
|
|||
expect(screen.queryByText('API usage')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps manual budget overage and clamped-track behavior', async () => {
|
||||
it('keeps custom budget overage and clamped-track behavior', async () => {
|
||||
getPlans.mockResolvedValue({
|
||||
...baseStatus,
|
||||
plans: {
|
||||
grok: { ...claudePlan, id: 'supergrok', provider: 'grok' },
|
||||
grok: { ...claudePlan, id: 'custom', provider: 'grok' },
|
||||
},
|
||||
})
|
||||
|
||||
const { container } = render(<Plans period="30days" />)
|
||||
|
||||
expect(await screen.findByText('SuperGrok')).toBeInTheDocument()
|
||||
expect(await screen.findByText('Custom plan')).toBeInTheDocument()
|
||||
expect(screen.getByText('$230.00 · 115% · $30.00 over')).toBeInTheDocument()
|
||||
const fill = container.querySelector('[data-testid="plan-track-grok"] i')
|
||||
expect(fill).toHaveStyle({ width: '100%' })
|
||||
|
|
@ -148,12 +148,33 @@ describe('Plans', () => {
|
|||
expect(screen.getByText('On pace to exceed; projected $254.00 by Jul 14')).toHaveClass('pace', 'hot')
|
||||
})
|
||||
|
||||
it('words a flat subscription past its price as API value, never as overage', async () => {
|
||||
getPlans.mockResolvedValue({
|
||||
...baseStatus,
|
||||
plans: {
|
||||
grok: { ...claudePlan, id: 'supergrok', provider: 'grok', budget: 30, spent: 408, percentUsed: 1360, projectedMonthEnd: 450 },
|
||||
},
|
||||
})
|
||||
|
||||
const { container } = render(<Plans period="30days" />)
|
||||
|
||||
expect(await screen.findByText('SuperGrok')).toBeInTheDocument()
|
||||
expect(screen.getByText("$408.00 · 13.6x your plan's price in API value")).toBeInTheDocument()
|
||||
const fill = container.querySelector('[data-testid="plan-track-grok"] i')
|
||||
expect(fill).toHaveStyle({ width: '100%' })
|
||||
expect(fill).not.toHaveClass('over')
|
||||
const pace = screen.getByText('Projected $450.00 in API value by Jul 14')
|
||||
expect(pace).toHaveClass('pace')
|
||||
expect(pace).not.toHaveClass('hot')
|
||||
expect(container.querySelector('.plan-card')).not.toHaveTextContent(/over|exceed/)
|
||||
})
|
||||
|
||||
it('renders near status as an amber non-exceeding projection when below budget', async () => {
|
||||
getPlans.mockResolvedValue({
|
||||
...baseStatus,
|
||||
plans: {
|
||||
grok: {
|
||||
id: 'supergrok-heavy',
|
||||
id: 'custom',
|
||||
provider: 'grok',
|
||||
budget: 300,
|
||||
spent: 255,
|
||||
|
|
|
|||
|
|
@ -350,15 +350,23 @@ function QuotaMeter({ window }: { window: QuotaWindow }) {
|
|||
)
|
||||
}
|
||||
|
||||
// Preset plans are flat subscriptions: usage past the price is API value
|
||||
// received, not a bill. Only a custom plan is a cap the user set.
|
||||
function isSubscription(plan: JsonPlanSummary): boolean {
|
||||
return plan.id !== 'custom'
|
||||
}
|
||||
|
||||
function PlanPanel({ plan }: { plan: JsonPlanSummary }) {
|
||||
const hasBudget = plan.budget > 0
|
||||
const displayPercent = Math.min(100, Math.max(0, plan.percentUsed))
|
||||
const over = plan.status === 'over' || plan.percentUsed > 100
|
||||
const trackClass = hasBudget ? (over ? 'over' : undefined) : 'mut'
|
||||
const trackClass = hasBudget ? (over && !isSubscription(plan) ? 'over' : undefined) : 'mut'
|
||||
const overage = Math.max(0, plan.spent - plan.budget)
|
||||
const right = hasBudget
|
||||
? overage > 0
|
||||
? t('plans.card.spentPercentOver', { spent: formatConverted(plan.spent), percent: fmtPct(plan.percentUsed), overage: formatConverted(overage) })
|
||||
? isSubscription(plan)
|
||||
? t('plans.card.spentValueMultiple', { spent: formatConverted(plan.spent), multiple: (plan.percentUsed / 100).toLocaleString(localeTag(), { minimumFractionDigits: 1, maximumFractionDigits: 1 }) })
|
||||
: t('plans.card.spentPercentOver', { spent: formatConverted(plan.spent), percent: fmtPct(plan.percentUsed), overage: formatConverted(overage) })
|
||||
: t('plans.card.spentPercent', { spent: formatConverted(plan.spent), percent: fmtPct(plan.percentUsed) })
|
||||
: t('plans.card.spentThisCycle', { spent: formatConverted(plan.spent) })
|
||||
const detail = hasBudget
|
||||
|
|
@ -383,6 +391,9 @@ function PlanPanel({ plan }: { plan: JsonPlanSummary }) {
|
|||
function PaceLine({ plan }: { plan: JsonPlanSummary }) {
|
||||
const end = cycleEndDate(plan)
|
||||
const endLabel = end ? formatShortDate(end) : t('plans.date.unknown')
|
||||
if (isSubscription(plan) && (plan.status !== 'under' || plan.projectedMonthEnd > plan.budget)) {
|
||||
return <div className="pace">{t('plans.pace.value', { projected: formatConverted(plan.projectedMonthEnd), date: endLabel })}</div>
|
||||
}
|
||||
if (plan.status === 'over' || plan.projectedMonthEnd > plan.budget) {
|
||||
return (
|
||||
<div className="pace hot">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue