AI nonsense
This commit is contained in:
parent
2645e78fa7
commit
347301830a
@ -7,21 +7,19 @@ import useWidgetAPI from "utils/proxy/use-widget-api";
|
|||||||
export default function Component({ service }) {
|
export default function Component({ service }) {
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
|
|
||||||
// State to hold Stats
|
|
||||||
const [stats, setStats] = useState({
|
const [stats, setStats] = useState({
|
||||||
totalLinks: null,
|
totalLinks: null,
|
||||||
collections: { total: null },
|
collections: { total: null },
|
||||||
tags: { total: null },
|
tags: { total: null },
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data: collectionsStatsData, error: collectionsStatsError } = useWidgetAPI(widget, "collections"); // Fetch Collection Stats
|
const { data: collectionsStatsData, error: collectionsStatsError } = useWidgetAPI(widget, "collections");
|
||||||
const { data: tagsStatsData, error: tagsStatsError } = useWidgetAPI(widget, "tags"); // Fetch Tag Stats
|
const { data: tagsStatsData, error: tagsStatsError } = useWidgetAPI(widget, "tags");
|
||||||
|
|
||||||
// Effect to update Stats when collectionsStatsData or tagsStatsData changes
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (collectionsStatsData?.response && tagsStatsData?.response) {
|
if (collectionsStatsData?.response && tagsStatsData?.response) {
|
||||||
/* eslint-disable no-underscore-dangle */
|
|
||||||
setStats({
|
setStats({
|
||||||
|
// eslint-disable-next-line no-underscore-dangle
|
||||||
totalLinks: collectionsStatsData.response.reduce((sum, collection) => sum + (collection._count?.links || 0), 0),
|
totalLinks: collectionsStatsData.response.reduce((sum, collection) => sum + (collection._count?.links || 0), 0),
|
||||||
collections: {
|
collections: {
|
||||||
total: collectionsStatsData.response.length,
|
total: collectionsStatsData.response.length,
|
||||||
@ -30,7 +28,6 @@ export default function Component({ service }) {
|
|||||||
total: tagsStatsData.response.length,
|
total: tagsStatsData.response.length,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
/* eslint-enable no-underscore-dangle */
|
|
||||||
}
|
}
|
||||||
}, [collectionsStatsData, tagsStatsData]);
|
}, [collectionsStatsData, tagsStatsData]);
|
||||||
|
|
||||||
@ -38,7 +35,6 @@ export default function Component({ service }) {
|
|||||||
return <Container service={service} error={collectionsStatsError || tagsStatsError} />;
|
return <Container service={service} error={collectionsStatsError || tagsStatsError} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render when data is available
|
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="linkwarden.links" value={stats.totalLinks} />
|
<Block label="linkwarden.links" value={stats.totalLinks} />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user