diff --git a/src/pages/buckets/components/bucket-card.tsx b/src/pages/buckets/components/bucket-card.tsx index 6f5eee4..c27a2e6 100644 --- a/src/pages/buckets/components/bucket-card.tsx +++ b/src/pages/buckets/components/bucket-card.tsx @@ -2,12 +2,19 @@ import { Bucket } from "../types"; import { ArchiveIcon, ChartPie, ChartScatter } from "lucide-react"; import { readableBytes } from "@/lib/utils"; import Button from "@/components/ui/button"; +import { useBucketDetails } from "../hooks"; type Props = { data: Bucket & { aliases: string[] }; }; const BucketCard = ({ data }: Props) => { + const { data: bucketDetails } = useBucketDetails(data.id); + + // Use detailed data if available, otherwise fall back to basic data + const bytes = bucketDetails?.bytes ?? data.bytes; + const objects = bucketDetails?.objects ?? data.objects; + return (
@@ -25,7 +32,7 @@ const BucketCard = ({ data }: Props) => { Usage

- {readableBytes(data.bytes)} + {bytes != null ? readableBytes(bytes) : "n/a"}

@@ -34,7 +41,9 @@ const BucketCard = ({ data }: Props) => { Objects

-

{data.objects}

+

+ {objects != null ? objects.toLocaleString() : "n/a"} +

diff --git a/src/pages/buckets/hooks.ts b/src/pages/buckets/hooks.ts index 388a9b1..958f4af 100644 --- a/src/pages/buckets/hooks.ts +++ b/src/pages/buckets/hooks.ts @@ -4,7 +4,7 @@ import { UseMutationOptions, useQuery, } from "@tanstack/react-query"; -import { GetBucketRes } from "./types"; +import { GetBucketRes, Bucket } from "./types"; import { CreateBucketSchema } from "./schema"; export const useBuckets = () => { @@ -14,6 +14,14 @@ export const useBuckets = () => { }); }; +export const useBucketDetails = (id?: string | null) => { + return useQuery({ + queryKey: ["bucket-details", id], + queryFn: () => api.get("/v2/GetBucketInfo", { params: { id } }), + enabled: !!id, + }); +}; + export const useCreateBucket = ( options?: UseMutationOptions ) => { diff --git a/src/pages/buckets/manage/overview/overview-tab.tsx b/src/pages/buckets/manage/overview/overview-tab.tsx index 05b89a3..330e70c 100644 --- a/src/pages/buckets/manage/overview/overview-tab.tsx +++ b/src/pages/buckets/manage/overview/overview-tab.tsx @@ -28,7 +28,7 @@ const OverviewTab = () => {

Storage

- {readableBytes(data?.bytes)} + {data?.bytes != null ? readableBytes(data.bytes) : "n/a"}

@@ -37,7 +37,9 @@ const OverviewTab = () => {

Objects

-

{data?.objects}

+

+ {data?.objects != null ? data.objects.toLocaleString() : "n/a"} +