import Block from "components/services/widget/block";
import Container from "components/services/widget/container";
import useWidgetAPI from "utils/proxy/use-widget-api";
export default function Component({ service }) {
const { widget } = service;
const { data: collectionsStatsData, error: collectionsStatsError } = useWidgetAPI(widget, "collections");
const { data: tagsStatsData, error: tagsStatsError } = useWidgetAPI(widget, "tags");
// Some APIs return raw arrays, others wrap the payload (e.g. { response: [...] }).
const collections = collectionsStatsData?.response ?? collectionsStatsData;
const tags = tagsStatsData?.response ?? tagsStatsData?.data?.tags ?? tagsStatsData;
const totalLinks = Array.isArray(collections)
? collections.reduce((sum, collection) => sum + (collection._count?.links || 0), 0)
: null;
const collectionsTotal = Array.isArray(collections) ? collections.length : null;
const tagsTotal = Array.isArray(tags) ? tags.length : null;
if (collectionsStatsError || tagsStatsError) {
return ;
}
if (!tagsStatsData || !collectionsStatsData) {
return (
);
}
return (
);
}