({ credits })
| 219 | } |
| 220 | |
| 221 | const CreditsOrSubscriptionIndicator: React.FC<{ credits: number }> = ({ credits }) => { |
| 222 | const theme = useTheme() |
| 223 | const { data: subscriptionData } = useSubscriptionQuery({ |
| 224 | refetchInterval: false, |
| 225 | refetchOnActivity: false, |
| 226 | pauseWhenIdle: false, |
| 227 | }) |
| 228 | |
| 229 | const blockPercentRemaining = useMemo( |
| 230 | () => getBlockPercentRemaining(subscriptionData), |
| 231 | [subscriptionData], |
| 232 | ) |
| 233 | |
| 234 | const showSubscriptionIndicator = isCoveredBySubscription(subscriptionData) |
| 235 | |
| 236 | if (showSubscriptionIndicator) { |
| 237 | const label = (blockPercentRemaining ?? 0) < 20 |
| 238 | ? `✓ ${SUBSCRIPTION_DISPLAY_NAME} (${blockPercentRemaining}% left)` |
| 239 | : `✓ ${SUBSCRIPTION_DISPLAY_NAME}` |
| 240 | return ( |
| 241 | <text |
| 242 | attributes={TextAttributes.DIM} |
| 243 | style={{ wrapMode: 'none', fg: theme.success, marginTop: 0, marginBottom: 0 }} |
| 244 | > |
| 245 | {label} |
| 246 | </text> |
| 247 | ) |
| 248 | } |
| 249 | |
| 250 | return ( |
| 251 | <text |
| 252 | attributes={TextAttributes.DIM} |
| 253 | style={{ wrapMode: 'none', fg: theme.secondary, marginTop: 0, marginBottom: 0 }} |
| 254 | > |
| 255 | {pluralize(credits, 'credit')} |
| 256 | </text> |
| 257 | ) |
| 258 | } |
nothing calls this directly
no test coverage detected