import * as React from "react"; import fileSize from "pretty-bytes"; import { Link } from "gatsby"; import { GraphBar } from "./GraphBar"; import { UsageGraph } from "./UsageGraph"; // TODO: get real data const useUsageData = () => ({ files: { used: 19_521, limit: 20_000, }, storage: { used: 23_000_000_000, limit: 1_000_000_000_000, }, }); const size = (bytes) => { const text = fileSize(bytes, { maximumFractionDigits: 1 }); const [value, unit] = text.split(" "); return { text, value, unit, }; }; export default function CurrentUsage() { const { files, storage } = useUsageData(); const storageUsage = size(storage.used); const storageLimit = size(storage.limit); const filesUsedLabel = React.useMemo(() => ({ value: files.used, unit: "files" }), [files.used]); return ( <>

{storageUsage.text} of {storageLimit.text}

{files.used} of {files.limit} files

Storage {storageLimit.text}
Files UPGRADE {" "} {/* TODO: proper URL */} {files.limit}
); }