import { useTranslation } from "next-i18next";
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 { t } = useTranslation();
const { widget } = service;
const { data: piholeData, error: piholeError } = useWidgetAPI(widget);
if (piholeError) {
return ;
}
if (!widget.fields) {
widget.fields = ["queries", "blocked", "gravity"];
}
if (!piholeData) {
return (
);
}
let blockedValue = `${t("common.number", { value: parseInt(piholeData.ads_blocked_today, 10) })}`;
if (!widget.fields.includes("blocked_percent")) {
blockedValue += ` (${t("common.percent", { value: parseFloat(piholeData.ads_percentage_today.toPrecision(3)) })})`;
}
return (
);
}