From 1723f16b9c4b008e9e44578c2587c7a1bd6560b4 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Sat, 25 Feb 2023 19:43:45 -0300
Subject: some fixes afte testing demobank with ms

---
 .../merchant-backoffice-ui/src/InstanceRoutes.tsx  | 50 ++++++++++++++--------
 1 file changed, 33 insertions(+), 17 deletions(-)

(limited to 'packages/merchant-backoffice-ui/src/InstanceRoutes.tsx')

diff --git a/packages/merchant-backoffice-ui/src/InstanceRoutes.tsx b/packages/merchant-backoffice-ui/src/InstanceRoutes.tsx
index 5929b031a..e31ff4513 100644
--- a/packages/merchant-backoffice-ui/src/InstanceRoutes.tsx
+++ b/packages/merchant-backoffice-ui/src/InstanceRoutes.tsx
@@ -22,6 +22,7 @@
 import {
   useTranslationContext,
   HttpError,
+  ErrorType,
 } from "@gnu-taler/web-util/lib/index.browser";
 import { format } from "date-fns";
 import { Fragment, FunctionComponent, h, VNode } from "preact";
@@ -163,16 +164,25 @@ export function InstanceRoutes({
     return function ServerErrorRedirectToImpl(
       error: HttpError<MerchantBackend.ErrorDetail>,
     ) {
-      setGlobalNotification({
-        message: i18n.str`The backend reported a problem: HTTP status #${error.status}`,
-        description: i18n.str`Diagnostic from ${error.info?.url} is "${error.message}"`,
-        details:
-          error.clientError || error.serverError
-            ? error.error?.detail
-            : undefined,
-        type: "ERROR",
-        to,
-      });
+      if (error.type === ErrorType.TIMEOUT) {
+        setGlobalNotification({
+          message: i18n.str`The request to the backend take too long and was cancelled`,
+          description: i18n.str`Diagnostic from ${error.info?.url} is "${error.message}"`,
+          type: "ERROR",
+          to,
+        });
+      } else {
+        setGlobalNotification({
+          message: i18n.str`The backend reported a problem: HTTP status #${error.status}`,
+          description: i18n.str`Diagnostic from ${error.info?.url} is "${error.message}"`,
+          details:
+            error.clientError || error.serverError
+              ? error.error?.detail
+              : undefined,
+          type: "ERROR",
+          to,
+        });
+      }
       return <Redirect to={to} />;
     };
   }
@@ -572,19 +582,25 @@ function AdminInstanceUpdatePage({
         {...rest}
         instanceId={id}
         onLoadError={(error: HttpError<MerchantBackend.ErrorDetail>) => {
-          return (
-            <Fragment>
-              <NotificationCard
-                notification={{
+          const notif =
+            error.type === ErrorType.TIMEOUT
+              ? {
+                  message: i18n.str`The request to the backend take too long and was cancelled`,
+                  description: i18n.str`Diagnostic from ${error.info?.url} is "${error.message}"`,
+                  type: "ERROR" as const,
+                }
+              : {
                   message: i18n.str`The backend reported a problem: HTTP status #${error.status}`,
                   description: i18n.str`Diagnostic from ${error.info?.url} is "${error.message}"`,
                   details:
                     error.clientError || error.serverError
                       ? error.error?.detail
                       : undefined,
-                  type: "ERROR",
-                }}
-              />
+                  type: "ERROR" as const,
+                };
+          return (
+            <Fragment>
+              <NotificationCard notification={notif} />
               <LoginPage onConfirm={updateLoginStatus} />
             </Fragment>
           );
-- 
cgit v1.2.3

