mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-03 12:46:49 +02:00
Add Print Time of Day, Color Distribution, and Records widgets to the Stats page. Extract shared MetricToggle component for consistent weight/prints/time toggles. Add date range filtering to archives and stats API endpoints. Reorganize widgets into parent cards (Printer Stats and Filament Trends) and fix Dashboard layout persistence for new widgets.
12 lines
355 B
TypeScript
12 lines
355 B
TypeScript
export function formatWeight(grams: number): string {
|
|
if (grams >= 1_000_000) {
|
|
const tonnes = grams / 1_000_000;
|
|
return `${tonnes % 1 === 0 ? tonnes.toFixed(0) : tonnes.toFixed(1)}t`;
|
|
}
|
|
if (grams >= 1000) {
|
|
const kg = grams / 1000;
|
|
return `${kg % 1 === 0 ? kg.toFixed(0) : kg.toFixed(1)}kg`;
|
|
}
|
|
return `${Math.round(grams)}g`;
|
|
}
|