diff options
author | Sebastian <sebasjm@gmail.com> | 2023-04-07 18:46:25 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-04-07 18:46:25 -0300 |
commit | cfe7129c4ecaa3057d5e47040f0a9efd8ed0317e (patch) | |
tree | c4a282300fec9be588bdb90bc7b94ab9e21ddfd0 /packages/merchant-backoffice-ui/src/Application.tsx | |
parent | 958747bd08172ce00bc84ea3c543eac414a1d39b (diff) | |
download | wallet-core-cfe7129c4ecaa3057d5e47040f0a9efd8ed0317e.tar.xz |
adding unreadable http response case and removing deprecated fields
Diffstat (limited to 'packages/merchant-backoffice-ui/src/Application.tsx')
-rw-r--r-- | packages/merchant-backoffice-ui/src/Application.tsx | 67 |
1 files changed, 43 insertions, 24 deletions
diff --git a/packages/merchant-backoffice-ui/src/Application.tsx b/packages/merchant-backoffice-ui/src/Application.tsx index ed1fc69f3..354212946 100644 --- a/packages/merchant-backoffice-ui/src/Application.tsx +++ b/packages/merchant-backoffice-ui/src/Application.tsx @@ -20,6 +20,7 @@ */ import { + ErrorType, TranslationProvider, useTranslationContext, } from "@gnu-taler/web-util/lib/index.browser"; @@ -40,6 +41,7 @@ import { ConfigContextProvider } from "./context/config.js"; import { useBackendConfig } from "./hooks/backend.js"; import { strings } from "./i18n/strings.js"; import LoginPage from "./paths/login/index.js"; +import { HttpStatusCode } from "@gnu-taler/taler-util"; export function Application(): VNode { return ( @@ -77,47 +79,63 @@ function ApplicationStatusRoutes(): VNode { ); } - if (result.clientError && result.isUnauthorized) - return ( - <Fragment> - <NotYetReadyAppMenu title="Login" /> - <LoginPage onConfirm={updateLoginInfoAndGoToRoot} /> - </Fragment> - ); - - if (result.clientError && result.isNotfound) - return ( + if (!result.ok) { + if (result.loading) return <Loading />; + if ( + result.type === ErrorType.CLIENT && + result.status === HttpStatusCode.Unauthorized + ) { + return ( + <Fragment> + <NotYetReadyAppMenu title="Login" /> + <LoginPage onConfirm={updateLoginInfoAndGoToRoot} /> + </Fragment> + ); + } + if ( + result.type === ErrorType.CLIENT && + result.status === HttpStatusCode.NotFound + ) { + return ( + <Fragment> + <NotYetReadyAppMenu title="Error" /> + <NotificationCard + notification={{ + message: i18n.str`Server not found`, + type: "ERROR", + description: `Check your url`, + }} + /> + <LoginPage onConfirm={updateLoginInfoAndGoToRoot} /> + </Fragment> + ); + } + if (result.type === ErrorType.SERVER) { <Fragment> <NotYetReadyAppMenu title="Error" /> <NotificationCard notification={{ - message: i18n.str`Server not found`, + message: i18n.str`Server response with an error code`, type: "ERROR", - description: `Check your url`, + description: i18n.str`Got message ${result.message} from ${result.info?.url}`, }} /> <LoginPage onConfirm={updateLoginInfoAndGoToRoot} /> - </Fragment> - ); - - if (result.serverError) - return ( + </Fragment>; + } + if (result.type === ErrorType.UNREADABLE) { <Fragment> <NotYetReadyAppMenu title="Error" /> <NotificationCard notification={{ - message: i18n.str`Couldn't access the server`, + message: i18n.str`Response from server is unreadable, http status: ${result.status}`, type: "ERROR", description: i18n.str`Got message ${result.message} from ${result.info?.url}`, }} /> <LoginPage onConfirm={updateLoginInfoAndGoToRoot} /> - </Fragment> - ); - - if (result.loading) return <Loading />; - - if (!result.ok) + </Fragment>; + } return ( <Fragment> <NotYetReadyAppMenu title="Error" /> @@ -131,6 +149,7 @@ function ApplicationStatusRoutes(): VNode { <LoginPage onConfirm={updateLoginInfoAndGoToRoot} /> </Fragment> ); + } return ( <div class="has-navbar-fixed-top"> |