/** * Generic quota card component. */ import { useTranslation } from 'react-i18next'; import type { ReactElement, ReactNode } from 'react'; import type { TFunction } from 'i18next'; import type { AuthFileItem, ResolvedTheme, ThemeColors } from '@/types'; import { TYPE_COLORS } from '@/utils/quota'; import styles from '@/pages/QuotaPage.module.scss'; type QuotaStatus = 'idle' | 'loading' | 'success' | 'error'; export interface QuotaStatusState { status: QuotaStatus; error?: string; errorStatus?: number; } export interface QuotaProgressBarProps { percent: number | null; highThreshold: number; mediumThreshold: number; } export function QuotaProgressBar({ percent, highThreshold, mediumThreshold }: QuotaProgressBarProps) { const clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value)); const normalized = percent === null ? null : clamp(percent, 0, 100); const fillClass = normalized === null ? styles.quotaBarFillMedium : normalized >= highThreshold ? styles.quotaBarFillHigh : normalized >= mediumThreshold ? styles.quotaBarFillMedium : styles.quotaBarFillLow; const widthPercent = Math.round(normalized ?? 0); return (