"use client"; import { HardDrive, Unplug } from "lucide-react"; import * as React from "react"; import { Label, Pie, PieChart } from "recharts"; import { ByteSize } from "~/components/bytes-size"; import { Card, CardContent, CardHeader, CardTitle } from "~/components/ui/card"; import { ChartContainer, ChartTooltip, ChartTooltipContent, type ChartConfig } from "~/components/ui/chart"; import type { StatFs } from "~/lib/types"; type Props = { statfs: StatFs; }; export function StorageChart({ statfs }: Props) { const chartData = React.useMemo( () => [ { name: "Used", value: statfs.used, fill: "blue", }, { name: "Free", value: statfs.free, fill: "lightgray", }, ], [statfs], ); const chartConfig = { value: { label: "Storage", }, used: { label: "Used", color: "hsl(var(--destructive))", }, free: { label: "Free", color: "hsl(var(--primary))", }, } satisfies ChartConfig; const usagePercentage = React.useMemo(() => { return Math.round((statfs.used / statfs.total) * 100); }, [statfs]); const isEmpty = !statfs.total; if (isEmpty) { return ( Storage Usage No storage data available. Mount the volume to see usage statistics. ); } return ( Storage Usage [, name]} /> } /> { if (viewBox && "cx" in viewBox && "cy" in viewBox) { return ( {usagePercentage}% Used ); } }} /> ); }
No storage data available. Mount the volume to see usage statistics.