/*
This file is part of GNU Taler
(C) 2022-2024 Taler Systems S.A.
GNU Taler is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
GNU Taler; see the file COPYING. If not, see
*/
import {
Footer,
Header,
ToastBanner,
notifyError,
notifyException,
useTranslationContext,
} from "@gnu-taler/web-util/browser";
import { ComponentChildren, Fragment, h, VNode } from "preact";
import { useSettingsContext } from "../context/settings.js";
import { useEffect, useErrorBoundary } from "preact/hooks";
import { TranslatedString } from "@gnu-taler/taler-util";
import {
getAllBooleanPreferences,
getLabelForPreferences,
usePreferences,
} from "../context/preferences.js";
const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined;
const VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : undefined;
export function Frame({ children }: { children: ComponentChildren }): VNode {
const settings = useSettingsContext();
const [preferences, updatePreferences] = usePreferences();
const [error, resetError] = useErrorBoundary();
const { i18n } = useTranslationContext();
useEffect(() => {
if (error) {
if (error instanceof Error) {
console.log("Internal error, please report", error);
notifyException(i18n.str`Internal error, please report.`, error);
} else {
console.log("Internal error, please report", error);
notifyError(
i18n.str`Internal error, please report.`,
String(error) as TranslatedString,
);
}
resetError();
}
}, [error]);
return (
);
}