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