(balance: number | null)
| 17 | * This is the single source of truth for credit tier classification. |
| 18 | */ |
| 19 | export function getThresholdInfo(balance: number | null): ThresholdInfo { |
| 20 | if (balance === null) { |
| 21 | return { |
| 22 | tier: 'medium', |
| 23 | colorLevel: 'warning', |
| 24 | threshold: MEDIUM_CREDITS_THRESHOLD, |
| 25 | } |
| 26 | } |
| 27 | if (balance >= HIGH_CREDITS_THRESHOLD) { |
| 28 | return { |
| 29 | tier: 'high', |
| 30 | colorLevel: 'success', |
| 31 | threshold: HIGH_CREDITS_THRESHOLD, |
| 32 | } |
| 33 | } |
| 34 | if (balance >= MEDIUM_CREDITS_THRESHOLD) { |
| 35 | return { |
| 36 | tier: 'medium', |
| 37 | colorLevel: 'warning', |
| 38 | threshold: MEDIUM_CREDITS_THRESHOLD, |
| 39 | } |
| 40 | } |
| 41 | if (balance >= LOW_CREDITS_THRESHOLD) { |
| 42 | return { |
| 43 | tier: 'low', |
| 44 | colorLevel: 'warning', |
| 45 | threshold: LOW_CREDITS_THRESHOLD, |
| 46 | } |
| 47 | } |
| 48 | return { tier: 'out', colorLevel: 'error', threshold: 0 } |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Determines the appropriate color level for the usage banner based on credit balance. |
no outgoing calls
no test coverage detected