Add detailed Error component for service widgets

This commit is contained in:
Michael Shamoon 2022-10-22 23:00:51 -07:00
parent 7b7740563e
commit 21017e4716
37 changed files with 113 additions and 113 deletions

View file

@ -1,18 +1,15 @@
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: statsData, error: statsError } = useWidgetAPI(widget, "request/count");
if (statsError) {
return <Container error={t("widget.api_error")} />;
if (statsError || statsData?.error) {
const finalError = statsError ?? statsData.error;
return <Container error={finalError} />;
}
if (!statsData) {