2022-08-25 16:29:26 +03:00
|
|
|
import useSWR from "swr";
|
|
|
|
|
|
|
|
import Widget from "../widget";
|
|
|
|
import Block from "../block";
|
|
|
|
|
2022-09-04 21:58:42 +03:00
|
|
|
import { formatApiUrl } from "utils/api-helpers";
|
|
|
|
|
2022-08-25 16:29:26 +03:00
|
|
|
export default function Ombi({ service }) {
|
|
|
|
const config = service.widget;
|
|
|
|
|
2022-09-04 21:58:42 +03:00
|
|
|
const { data: statsData, error: statsError } = useSWR(formatApiUrl(config, `Request/count`));
|
2022-08-25 16:29:26 +03:00
|
|
|
|
|
|
|
if (statsError) {
|
|
|
|
return <Widget error="Ombi API Error" />;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!statsData) {
|
|
|
|
return (
|
|
|
|
<Widget>
|
|
|
|
<Block label="Pending" />
|
|
|
|
<Block label="Approved" />
|
|
|
|
<Block label="Available" />
|
|
|
|
</Widget>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Widget>
|
|
|
|
<Block label="Pending" value={statsData.pending} />
|
|
|
|
<Block label="Approved" value={statsData.approved} />
|
|
|
|
<Block label="Available" value={statsData.available} />
|
|
|
|
</Widget>
|
|
|
|
);
|
|
|
|
}
|