import React from 'react';
import { useCacheManagement } from '../hooks/useCacheManagement';
import './CacheManagementUI.css';
export const CacheManagementUI: React.FC = () => {
const {
status,
isLoading,
error,
isClearing,
clearCache,
refreshStatus,
formatBytes
} = useCacheManagement();
if (isLoading) {
return (
Loading cache information...
);
}
if (error) {
return (
⚠️
Cache Error: {error}
);
}
if (!status) {
return (
Cache information unavailable
);
}
const storagePercentage = status.deviceType.capabilities.maxStorage > 0
? (status.totalSize / status.deviceType.capabilities.maxStorage) * 100
: 0;
return (
Cached Songs
{status.songCount.toLocaleString()}
Storage Used
{formatBytes(status.totalSize)}
Available Space
{formatBytes(status.availableSpace)}
Device Type
{status.deviceType.type.replace('-', ' ')}
{status.deviceType.model && (
({status.deviceType.model})
)}
0
{formatBytes(status.deviceType.capabilities.maxStorage)}
Cache Strategy
{status.cacheStrategy}
Compression Ratio
{(status.compressionRatio * 100).toFixed(1)}%
(Space saved: {((1 - status.compressionRatio) * 100).toFixed(1)}%)
Storage Shards
{status.shards.length} shard{status.shards.length !== 1 ? 's' : ''}
{status.shards.length > 0 && (
{status.shards.slice(0, 3).map((shard, index) => (
Shard {index + 1}
{shard.songCount} songs • {formatBytes(shard.size)}
))}
{status.shards.length > 3 && (
+{status.shards.length - 3} more shard{status.shards.length - 3 !== 1 ? 's' : ''}
)}
)}
{status.songCount > 0 && (
)}
{status.songCount === 0 && (
📱
No cached songs
Start playing music to automatically cache songs for offline playback.
)}
);
};