2024-09-20 19:40:44 +02:00

45 lines
1.0 KiB
TypeScript

import { useQuery } from "@tanstack/react-query";
import Loader from "../../assets/loader.svg";
import { CodexSdk } from "../../sdk/codex";
import { SpaceAllocation } from "@codex-storage/marketplace-ui-components";
export function NodeSpaceAllocation() {
const { data: space, isPending } = useQuery({
queryFn: () => CodexSdk.data.space(),
queryKey: ["space"],
refetchOnMount: true,
});
if (isPending || !space) {
return <img src={Loader} width={24} height={24} alt="Loader" />;
}
if (space.error) {
return "";
}
const {
quotaMaxBytes = 0,
quotaReservedBytes = 0,
quotaUsedBytes = 0,
} = space.data;
return (
<SpaceAllocation
data={[
{
title: "Maximum storage space used by the node",
size: quotaMaxBytes,
},
{
title: "Amount of storage space currently in use",
size: quotaUsedBytes,
},
{
title: "Amount of storage space reserved",
size: quotaReservedBytes,
},
]}></SpaceAllocation>
);
}