import { useState } from "react"; import { useI18n } from "../../i18n/I18nContext"; import { METER_META, type UsageMeter } from "../../lib/usageMeter"; export type MeterBarRow = { meter: UsageMeter; /** 已用點數(platform only) */ credits: number; /** 平台呼叫次數(不含 byok) */ count: number; /** 分項點數硬上限(與 PLANS.soft_caps 同步,單位=點) */ soft_cap: number; }; type Props = { rows: MeterBarRow[]; unlimited?: boolean; }; /** * 分項:數字 = 已用點 / 上限點(與方案 monthly_credits 同一單位)。 * 超過/達上限標紅;hover 顯示平台呼叫次數。 */ export function UsageMeterBars({ rows, unlimited = false }: Props) { const { t } = useI18n(); const [active, setActive] = useState(null); const ordered = rows .slice() .sort((a, b) => METER_META[a.meter].order - METER_META[b.meter].order); return ( ); }