"use client"; import { useTranslation } from "@/lib/i18n/client"; import { useQuery } from "@tanstack/react-query"; import { Database, HardDrive } from "lucide-react"; import { useTRPC } from "@karakeep/shared-react/trpc"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "../ui/card"; import { Progress } from "../ui/progress"; function formatBytes(bytes: number): string { if (bytes === 0) return "0 B"; const k = 1024; const sizes = ["B", "KB", "MB", "GB"]; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + " " + sizes[i]; } function formatNumber(num: number): string { if (num >= 1000000) { return (num / 1000000).toFixed(1) + "M"; } if (num >= 1000) { return (num / 1000).toFixed(1) + "K"; } return num.toString(); } interface QuotaProgressItemProps { title: string; icon: React.ReactNode; used: number; quota: number | null; unlimited: boolean; formatter: (value: number) => string; description: string; } function QuotaProgressItem({ title, icon, used, quota, unlimited, formatter, description, }: QuotaProgressItemProps) { const { t } = useTranslation(); const percentage = unlimited || !quota ? 0 : Math.min((used / quota) * 100, 100); const isNearLimit = percentage > 80; const isAtLimit = percentage >= 100; return (