mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-27 22:41:16 -07:00
Lint / Linting Checks (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Docker CI / Docker Build & Push (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Release Drafter / Auto Label PR (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com> Signed-off-by: dependabot[bot] <support@github.com>
36 lines
1.1 KiB
React
36 lines
1.1 KiB
React
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: spaceData, error: spaceError } = useWidgetAPI(widget, "space");
|
|
const { data: keywordData, error: keywordError } = useWidgetAPI(widget, "keyword");
|
|
|
|
if (spaceError || keywordError) {
|
|
const finalError = spaceError ?? keywordError;
|
|
return <Container service={service} error={finalError} />;
|
|
}
|
|
|
|
if (!spaceData || !keywordData) {
|
|
return (
|
|
<Container service={service}>
|
|
<Block label="tandoor.users" />
|
|
<Block label="tandoor.recipes" />
|
|
<Block label="tandoor.keywords" />
|
|
</Container>
|
|
);
|
|
}
|
|
|
|
const space = spaceData.results ? spaceData.results[0] : spaceData[0];
|
|
|
|
return (
|
|
<Container service={service}>
|
|
<Block label="tandoor.users" value={space?.user_count} />
|
|
<Block label="tandoor.recipes" value={space?.recipe_count} />
|
|
<Block label="tandoor.keywords" value={keywordData.count} />
|
|
</Container>
|
|
);
|
|
}
|