commit c521c43720799c60919972c314dad564af8686ad
parent 26795a873da076487486edc0dd36384511af5a3f
Author: Sebastian <sebasjm@taler-systems.com>
Date: Mon, 1 Jun 2026 11:19:50 -0300
same as other api
Diffstat:
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/packages/web-util/src/context/merchant-api.ts b/packages/web-util/src/context/merchant-api.ts
@@ -33,7 +33,8 @@ import {
h,
} from "preact";
import { useContext, useEffect, useState } from "preact/hooks";
-import { BrowserFetchHttpLib } from "../index.browser.js";
+import { ErrorLoading } from "../components/ErrorLoadingMerchant.js";
+import { BrowserFetchHttpLib, useTranslationContext } from "../index.browser.js";
import {
APIClient,
ActiviyTracker,
@@ -93,14 +94,11 @@ export const MerchantApiProvider = ({
baseUrl: URL;
evictors?: Evictors;
children: ComponentChildren;
- frameOnError: FunctionComponent<{
- state:
- | ConfigResultFail<TalerMerchantApi.MerchantVersionResponse>
- | undefined;
- }>;
+ frameOnError: FunctionComponent<{ children: ComponentChildren }>;
}): VNode => {
const [checked, setChecked] =
useState<ConfigResult<TalerMerchantApi.MerchantVersionResponse>>();
+ const { i18n } = useTranslationContext();
const [merchantEndpoint, changeMerchantEndpoint] = useState(baseUrl);
@@ -141,8 +139,24 @@ export const MerchantApiProvider = ({
};
}, []);
- if (!checked || checked.type !== "ok") {
- return h(frameOnError, { state: checked }, []);
+ if (checked === undefined) {
+ return h(frameOnError, {
+ children: h("div", {}, i18n.str`Checking compatibility of this webapp with backend service...`),
+ });
+ }
+ if (checked.type === "error") {
+ return h(frameOnError, {
+ children: h(ErrorLoading, { title: i18n.str`There was an error trying to contact the backend service.`, error: checked.error }),
+ });
+ }
+ if (checked.type === "incompatible") {
+ return h(frameOnError, {
+ children: h(
+ "div",
+ {},
+ i18n.str`The server version is not supported. Supported version "${checked.supported}", server version "${checked.result.version}"`,
+ ),
+ });
}
const value: MerchantContextType = {