mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-24 05:48:08 +08:00
Feature: add gitea widget (#2968)
This commit is contained in:
32
src/widgets/gitea/component.jsx
Normal file
32
src/widgets/gitea/component.jsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { widget } = service;
|
||||
|
||||
const { data: giteaNotifications, error: giteaNotificationsError } = useWidgetAPI(widget, "notifications");
|
||||
const { data: giteaIssues, error: giteaIssuesError } = useWidgetAPI(widget, "issues");
|
||||
|
||||
if (giteaNotificationsError || giteaIssuesError) {
|
||||
return <Container service={service} error={giteaNotificationsError ?? giteaIssuesError} />;
|
||||
}
|
||||
|
||||
if (!giteaNotifications || !giteaIssues) {
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="gitea.notifications" />
|
||||
<Block label="gitea.issues" />
|
||||
<Block label="gitea.pulls" />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="gitea.notifications" value={giteaNotifications.length} />
|
||||
<Block label="gitea.issues" value={giteaIssues.issues.length} />
|
||||
<Block label="gitea.pulls" value={giteaIssues.pulls.length} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user