diff options
author | Özgür Kesim <oec-taler@kesim.org> | 2023-09-12 13:52:55 +0200 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2023-09-12 13:52:55 +0200 |
commit | 121a6da78504204ddf34bf05b5136e09fab0261e (patch) | |
tree | cd220a6e7168e9888b0f83219242f23744fa2cc2 /packages/merchant-backoffice-ui/src/Application.tsx | |
parent | 5495551071a3fdc36c38deb4c1cf6f4aa5b98bd4 (diff) | |
parent | ee8993f11cf81721cc30b4473e40124c2fee0dff (diff) |
Merge branch 'master' into age-withdraw
Diffstat (limited to 'packages/merchant-backoffice-ui/src/Application.tsx')
-rw-r--r-- | packages/merchant-backoffice-ui/src/Application.tsx | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/packages/merchant-backoffice-ui/src/Application.tsx b/packages/merchant-backoffice-ui/src/Application.tsx index 5e82821ae..1a7617643 100644 --- a/packages/merchant-backoffice-ui/src/Application.tsx +++ b/packages/merchant-backoffice-ui/src/Application.tsx @@ -41,7 +41,8 @@ import { 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 { ConnectionPage, LoginPage } from "./paths/login/index.js"; +import { LoginToken } from "./declaration.js"; export function Application(): VNode { return ( @@ -59,25 +60,20 @@ export function Application(): VNode { * @returns */ function ApplicationStatusRoutes(): VNode { - const { url, updateLoginStatus, triedToLog } = useBackendContext(); + const { url: backendURL, updateToken, changeBackend } = useBackendContext(); const result = useBackendConfig(); const { i18n } = useTranslationContext(); - const updateLoginInfoAndGoToRoot = (url: string, token?: string) => { - updateLoginStatus(url, token); - route("/"); - }; - const { currency, version } = result.ok ? result.data : { currency: "unknown", version: "unknown" }; const ctx = useMemo(() => ({ currency, version }), [currency, version]); - if (!triedToLog) { + if (!backendURL) { return ( <Fragment> <NotConnectedAppMenu title="Welcome!" /> - <LoginPage onConfirm={updateLoginInfoAndGoToRoot} /> + <ConnectionPage onConfirm={changeBackend} /> </Fragment> ); } @@ -91,7 +87,7 @@ function ApplicationStatusRoutes(): VNode { return ( <Fragment> <NotConnectedAppMenu title="Login" /> - <LoginPage onConfirm={updateLoginInfoAndGoToRoot} /> + <ConnectionPage onConfirm={changeBackend} /> </Fragment> ); } @@ -109,7 +105,7 @@ function ApplicationStatusRoutes(): VNode { description: `Check your url`, }} /> - <LoginPage onConfirm={updateLoginInfoAndGoToRoot} /> + <ConnectionPage onConfirm={changeBackend} /> </Fragment> ); } @@ -120,10 +116,10 @@ function ApplicationStatusRoutes(): VNode { notification={{ message: i18n.str`Server response with an error code`, type: "ERROR", - description: i18n.str`Got message ${result.message} from ${result.info?.url}`, + description: i18n.str`Got message "${result.message}" from ${result.info?.url}`, }} /> - <LoginPage onConfirm={updateLoginInfoAndGoToRoot} /> + <ConnectionPage onConfirm={changeBackend} /> </Fragment>; } if (result.type === ErrorType.UNREADABLE) { @@ -133,10 +129,10 @@ function ApplicationStatusRoutes(): VNode { notification={{ 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}`, + description: i18n.str`Got message "${result.message}" from ${result.info?.url}`, }} /> - <LoginPage onConfirm={updateLoginInfoAndGoToRoot} /> + <ConnectionPage onConfirm={changeBackend} /> </Fragment>; } return ( @@ -146,10 +142,10 @@ function ApplicationStatusRoutes(): VNode { notification={{ message: i18n.str`Unexpected Error`, type: "ERROR", - description: i18n.str`Got message ${result.message} from ${result.info?.url}`, + description: i18n.str`Got message "${result.message}" from ${result.info?.url}`, }} /> - <LoginPage onConfirm={updateLoginInfoAndGoToRoot} /> + <ConnectionPage onConfirm={changeBackend} /> </Fragment> ); } @@ -168,7 +164,7 @@ function ApplicationStatusRoutes(): VNode { description: i18n.str`Merchant backend server version ${result.data.version} is not compatible with the supported version ${SUPPORTED_VERSION}`, }} /> - <LoginPage onConfirm={updateLoginInfoAndGoToRoot} /> + <ConnectionPage onConfirm={changeBackend} /> </Fragment> } |