From 237c4e8adae997e84f5fb7a8fe5c03b1148e99dc Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 27 Mar 2024 01:05:10 -0300 Subject: wip #8655 --- packages/web-util/src/context/merchant-api.ts | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'packages/web-util/src/context') diff --git a/packages/web-util/src/context/merchant-api.ts b/packages/web-util/src/context/merchant-api.ts index a531a5958..23ea05cd2 100644 --- a/packages/web-util/src/context/merchant-api.ts +++ b/packages/web-util/src/context/merchant-api.ts @@ -79,6 +79,9 @@ type Evictors = { type ConfigResult = | undefined | { type: "ok"; config: T; hints: VersionHint[] } + | ConfigResultFail; + +export type ConfigResultFail = | { type: "incompatible"; result: T; supported: string } | { type: "error"; error: TalerError }; @@ -91,7 +94,7 @@ export const MerchantApiProvider = ({ baseUrl: URL; evictors?: Evictors; children: ComponentChildren; - frameOnError: FunctionComponent<{ children: ComponentChildren }>; + frameOnError: FunctionComponent<{ state: ConfigResultFail | undefined }>; }): VNode => { const [checked, setChecked] = useState>(); @@ -120,24 +123,8 @@ export const MerchantApiProvider = ({ }); }, []); - if (checked === undefined) { - return h(frameOnError, { - children: h("div", {}, "checking compatibility with server..."), - }); - } - if (checked.type === "error") { - return h(frameOnError, { - children: h(ErrorLoading, { error: checked.error, showDetail: true }), - }); - } - 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}"`, - ), - }); + if (!checked || checked.type !== "ok") { + return h(frameOnError, { state: checked }, []); } const value: MerchantContextType = { -- cgit v1.2.3