import { useTranslation } from 'react-i18next'; import { cn } from '@/lib/utils'; import { formatBytes } from '../lib/format'; import type { MediaStorageDto } from '../services/types'; /** Used space against the limit, with a warning at 80 percent and a clear message at the limit (colour plus text). */ export function StorageMeter({ storage }: { storage: MediaStorageDto }) { const { t, i18n } = useTranslation(); const hasLimit = storage.limitBytes > 0; const percent = hasLimit ? Math.min(100, Math.round((storage.usedBytes / storage.limitBytes) * 100)) : 0; const used = formatBytes(storage.usedBytes, i18n.language); return (

{t('media.storage.title')}

{hasLimit ? t('media.storage.usedOf', { used, limit: formatBytes(storage.limitBytes, i18n.language), percent }) : t('media.storage.used', { used })}

{hasLimit && (
)} {storage.level !== 'ok' && (

{storage.level === 'full' ? t('media.storage.full') : t('media.storage.warning', { percent: storage.warningPercent })}

)}
); }