summaryrefslogtreecommitdiff
path: root/packages/web-util/src/context/merchant-api.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/web-util/src/context/merchant-api.ts')
-rw-r--r--packages/web-util/src/context/merchant-api.ts25
1 files changed, 6 insertions, 19 deletions
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<T> =
| undefined
| { type: "ok"; config: T; hints: VersionHint[] }
+ | ConfigResultFail<T>;
+
+export type ConfigResultFail<T> =
| { 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<TalerMerchantApi.VersionResponse> | undefined }>;
}): VNode => {
const [checked, setChecked] =
useState<ConfigResult<TalerMerchantApi.VersionResponse>>();
@@ -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 = {