import useSWR from "swr"; export default function Ombi({ service }) { const config = service.widget; function buildApiUrl(endpoint) { const { url } = config; return `${url}/api/v1/${endpoint}`; } const fetcher = (url) => { return fetch(url, { method: "GET", withCredentials: true, credentials: "include", headers: { ApiKey: `${config.key}`, "Content-Type": "application/json", }, }).then((res) => res.json()); }; const { data: statsData, error: statsError } = useSWR( buildApiUrl(`Request/count`), fetcher ); if (statsError) { return (
Ombi API Error
); } if (!statsData) { return (
-
COMPLETED
-
QUEUED
-
TOTAL
); } return (
{statsData.pending}
PENDING
{statsData.approved}
APPROVED
{statsData.available}
AVAILABLE
); }