2024-08-22 17:41:44 +02:00
|
|
|
import { useQuery } from "@tanstack/react-query";
|
|
|
|
|
import Loader from "../../assets/loader.svg";
|
|
|
|
|
import { CodexSdk } from "../../sdk/codex";
|
2024-08-30 17:26:27 +02:00
|
|
|
import { SpaceAllocation } from "@codex-storage/marketplace-ui-components";
|
2024-08-22 17:41:44 +02:00
|
|
|
|
|
|
|
|
export function NodeSpaceAllocation() {
|
|
|
|
|
const { data: space, isPending } = useQuery({
|
2024-09-13 22:40:31 +02:00
|
|
|
queryFn: () => CodexSdk.data.space(),
|
2024-08-22 17:41:44 +02:00
|
|
|
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>
|
|
|
|
|
);
|
|
|
|
|
}
|