import { useState, type ReactNode } from "react"; import { openUrl } from "@tauri-apps/plugin-opener"; import { useDashboard, type DashboardRange } from "../../hooks/useDashboard"; import { useTranslation } from "../../i18n"; import { fmtInt, fmtPct, fmtTime, fmtTokens, fmtUsd } from "../../lib/dashboard-format"; import { DailyBars } from "./DailyBars"; import { Heatmap } from "./Heatmap"; import { TrendLineChart } from "./TrendLineChart"; const RANGES: DashboardRange[] = ["today", "7d", "30d", "all"]; function Card({ title, subtitle, children, className, }: { title: string; subtitle?: string; children: ReactNode; className?: string; }) { return (
| {t("colModel")} | {t("requests")} | {t("colTokens")} | {t("colCacheHit")} | {t("cost")} |
|---|---|---|---|---|
|
{m.modelDisplay || m.model}
{m.costEstimated && (
({t("estimate")})
)}
|
{fmtInt(m.requests)} | {fmtTokens(m.totalTokens)} | {fmtPct(m.cacheHitRate)} | {fmtUsd(m.costUsd)} |
| {t("colTime")} | {t("colModel")} | {t("colInput")} | {t("colOutput")} | {t("colCacheRead")} | {t("cost")} |
|---|---|---|---|---|---|
| {fmtTime(r.time)} | {r.modelDisplay || r.model} | {fmtTokens(r.inputOther)} | {fmtTokens(r.output)} | {fmtTokens(r.inputCacheRead)} | {fmtUsd(r.costUsd)} |