import { useTranslation } from 'react-i18next'; import { Card } from '@/components/ui/Card'; import { formatTokensInMillions, formatUsd } from '@/utils/usage'; import styles from '@/pages/UsagePage.module.scss'; export interface ModelStat { model: string; requests: number; tokens: number; cost: number; } export interface ModelStatsCardProps { modelStats: ModelStat[]; loading: boolean; hasPrices: boolean; } export function ModelStatsCard({ modelStats, loading, hasPrices }: ModelStatsCardProps) { const { t } = useTranslation(); return ( {loading ? (
{t('common.loading')}
) : modelStats.length > 0 ? (
{hasPrices && } {modelStats.map((stat) => ( {hasPrices && } ))}
{t('usage_stats.model_name')} {t('usage_stats.requests_count')} {t('usage_stats.tokens_count')}{t('usage_stats.total_cost')}
{stat.model} {stat.requests.toLocaleString()} {formatTokensInMillions(stat.tokens)}{stat.cost > 0 ? formatUsd(stat.cost) : '--'}
) : (
{t('usage_stats.no_data')}
)}
); }