Reintroduce Error component

This commit is contained in:
Matt Sullivan 2024-06-22 09:54:50 +01:00
parent 2fae39e3ce
commit cbb74a9772
2 changed files with 10 additions and 3 deletions

View File

@ -1,19 +1,19 @@
import { useContext } from "react"; import { useContext } from "react";
import { useTranslation } from "next-i18next"; import { useTranslation } from "next-i18next";
import { SettingsContext } from "utils/contexts/settings"; import { SettingsContext } from "utils/contexts/settings";
import { Settings } from "luxon"; import Error from "./error"
export default function Container({ service, children, chart = true, error = false, className = "" }) { export default function Container({ service, children, chart = true, error = false, className = "" }) {
const { t } = useTranslation(); const { t } = useTranslation();
const { settings } = useContext(SettingsContext); const { settings } = useContext(SettingsContext);
const hideErrors = (service.widget.hide_errors || settings.hideErrors) const hideErrors = (settings.hideErrors || service.widget.hide_errors)
return ( return (
<div> <div>
{children} {children}
<div className={`absolute top-0 right-0 bottom-0 left-0 overflow-clip pointer-events-none ${className}`} /> <div className={`absolute top-0 right-0 bottom-0 left-0 overflow-clip pointer-events-none ${className}`} />
{chart && <div className="h-[68px] overflow-clip" />} {chart && <div className="h-[68px] overflow-clip" />}
{!chart && <div className="h-[16px] overflow-clip" />} {!chart && <div className="h-[16px] overflow-clip" />}
{error && !hideErrors && <div className="absolute bottom-2 left-2 z-20 text-red-400 text-xs opacity-75">{t("widget.api_error")}</div>} {error && !hideErrors && <Error />}
</div> </div>
); );
} }

View File

@ -0,0 +1,7 @@
import { useTranslation } from "next-i18next";
export default function Error() {
const { t } = useTranslation();
return <div className="absolute bottom-2 left-2 z-20 text-red-400 text-xs opacity-75">{t("widget.api_error")}</div>;
}