Sessions and Devices no longer live behind a Tabs switcher on the stats page - both sections render directly, one after the other. Also drops the "Duration per device" list from the sessions summary cards since DeviceUsageTable already shows per-device active time in more detail. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzyfRyA7h5rs5SCAahLAWd
50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||
|
||
export interface SessionsSummary {
|
||
count: number;
|
||
totalDurationMs: number;
|
||
avgDurationMs: number;
|
||
totalReplays: number;
|
||
}
|
||
|
||
function formatHours(ms: number): string {
|
||
return `${(ms / 3_600_000).toFixed(1)}h`;
|
||
}
|
||
|
||
function formatReplays(count: number): string {
|
||
return count === 0 ? "-" : `${count}×`;
|
||
}
|
||
|
||
export function SessionsSummaryCards({ summary }: { summary: SessionsSummary }) {
|
||
return (
|
||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||
<Card className="bp-glass">
|
||
<CardHeader>
|
||
<CardTitle className="text-sm text-muted-foreground">Completed sessions</CardTitle>
|
||
</CardHeader>
|
||
<CardContent className="bp-readout text-3xl">{summary.count}</CardContent>
|
||
</Card>
|
||
<Card className="bp-glass">
|
||
<CardHeader>
|
||
<CardTitle className="text-sm text-muted-foreground">Total time</CardTitle>
|
||
</CardHeader>
|
||
<CardContent className="bp-readout text-3xl">{formatHours(summary.totalDurationMs)}</CardContent>
|
||
</Card>
|
||
<Card className="bp-glass">
|
||
<CardHeader>
|
||
<CardTitle className="text-sm text-muted-foreground">Avg session length</CardTitle>
|
||
</CardHeader>
|
||
<CardContent className="bp-readout text-3xl">
|
||
{Math.round(summary.avgDurationMs / 60_000)}m
|
||
</CardContent>
|
||
</Card>
|
||
<Card className="bp-glass">
|
||
<CardHeader>
|
||
<CardTitle className="text-sm text-muted-foreground">Replays</CardTitle>
|
||
</CardHeader>
|
||
<CardContent className="bp-readout text-3xl">{formatReplays(summary.totalReplays)}</CardContent>
|
||
</Card>
|
||
</div>
|
||
);
|
||
}
|