diff --git a/packages/stage-pages/src/pages/settings/flux.vue b/packages/stage-pages/src/pages/settings/flux.vue index d829337c0..180e4b740 100644 --- a/packages/stage-pages/src/pages/settings/flux.vue +++ b/packages/stage-pages/src/pages/settings/flux.vue @@ -17,15 +17,28 @@ const loadingAmount = ref(null) const message = ref<{ type: 'success' | 'error', text: string } | null>(null) const packages = ref<{ amount: number, label: string, price: string }[]>([]) +// NOTICE: Manual interface instead of hono InferResponseType because hono client +// type instantiation hits TS recursion limits ("excessively deep and possibly infinite"). +// Keep in sync with the route response shape in apps/server/src/routes/flux.ts interface AuditRecord { id: string - type: 'consumption' | 'addition' | 'initial' + type: string amount: number description: string - metadata: { promptTokens?: number, completionTokens?: number } | null + metadata: Record | null createdAt: string } +/** Display amount with sign: debit is negative, credit/initial are positive */ +function displayAmount(record: AuditRecord): string { + const signed = record.type === 'debit' ? -record.amount : record.amount + return signed >= 0 ? `+${signed}` : String(signed) +} + +function isPositive(record: AuditRecord): boolean { + return record.type !== 'debit' +} + const auditRecords = ref([]) const auditLoading = ref(false) const auditHasMore = ref(false) @@ -204,13 +217,13 @@ async function handleBuy(amount: number) { - {{ record.type === 'consumption' + {{ record.type === 'debit' ? t('settings.pages.flux.audit.typeConsumption') - : record.type === 'addition' + : record.type === 'credit' ? t('settings.pages.flux.audit.typeAddition') : t('settings.pages.flux.audit.typeInitial') }} @@ -225,8 +238,8 @@ async function handleBuy(amount: number) { - - {{ record.amount >= 0 ? `+${record.amount}` : record.amount }} + + {{ displayAmount(record) }} @@ -244,18 +257,18 @@ async function handleBuy(amount: number) {
- {{ record.type === 'consumption' + {{ record.type === 'debit' ? t('settings.pages.flux.audit.typeConsumption') - : record.type === 'addition' + : record.type === 'credit' ? t('settings.pages.flux.audit.typeAddition') : t('settings.pages.flux.audit.typeInitial') }} - - {{ record.amount >= 0 ? `+${record.amount}` : record.amount }} + + {{ displayAmount(record) }}