From 770ab6f01dc81a16f384f314982bd761540f8e65 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 19 Dec 2022 12:11:50 -0300 Subject: build and test like other webapps --- .../merchant-backoffice-ui/src/Application.tsx | 109 +++++++++++++++++++++ .../src/components/menu/SideBar.tsx | 5 +- packages/merchant-backoffice-ui/src/custom.d.ts | 2 + packages/merchant-backoffice-ui/src/index.html | 39 ++++++++ packages/merchant-backoffice-ui/src/index.tsx | 94 +----------------- .../merchant-backoffice-ui/src/scss/_mixins.scss | 2 +- packages/merchant-backoffice-ui/src/template.html | 52 ---------- 7 files changed, 159 insertions(+), 144 deletions(-) create mode 100644 packages/merchant-backoffice-ui/src/Application.tsx create mode 100644 packages/merchant-backoffice-ui/src/index.html delete mode 100644 packages/merchant-backoffice-ui/src/template.html (limited to 'packages/merchant-backoffice-ui/src') diff --git a/packages/merchant-backoffice-ui/src/Application.tsx b/packages/merchant-backoffice-ui/src/Application.tsx new file mode 100644 index 000000000..4aa0f7891 --- /dev/null +++ b/packages/merchant-backoffice-ui/src/Application.tsx @@ -0,0 +1,109 @@ +/* + This file is part of GNU Taler + (C) 2021-2023 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see + */ + +/** +* +* @author Sebastian Javier Marchano (sebasjm) +*/ + +import { h, VNode } from 'preact'; +import { route } from 'preact-router'; +import { useMemo } from "preact/hooks"; +import { ApplicationReadyRoutes } from "./ApplicationReadyRoutes.js"; +import { Loading } from "./components/exception/loading.js"; +import { NotificationCard, NotYetReadyAppMenu } from "./components/menu/index.js"; +import { BackendContextProvider, useBackendContext } from './context/backend.js'; +import { ConfigContextProvider } from './context/config.js'; +import { TranslationProvider } from './context/translation.js'; +import { useBackendConfig } from "./hooks/backend.js"; +import { useTranslator } from './i18n/index.js'; +import LoginPage from './paths/login/index.js'; + +export function Application(): VNode { + return ( + // + + + + + + // + ); +} + +function ApplicationStatusRoutes(): VNode { + const { updateLoginStatus, triedToLog } = useBackendContext() + const result = useBackendConfig(); + const i18n = useTranslator() + + 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) { + return
+ + +
+ } + + if (result.clientError && result.isUnauthorized) return
+ + +
+ + if (result.clientError && result.isNotfound) return
+ + + +
+ + if (result.serverError) return
+ + + +
+ + if (result.loading) return + + if (!result.ok) return
+ + + +
+ + return
+ + + +
+} diff --git a/packages/merchant-backoffice-ui/src/components/menu/SideBar.tsx b/packages/merchant-backoffice-ui/src/components/menu/SideBar.tsx index b96e431f8..1d15bb094 100644 --- a/packages/merchant-backoffice-ui/src/components/menu/SideBar.tsx +++ b/packages/merchant-backoffice-ui/src/components/menu/SideBar.tsx @@ -28,6 +28,9 @@ import { useInstanceKYCDetails } from "../../hooks/instance.js"; import { Translate } from "../../i18n/index.js"; import { LangSelector } from "./LangSelector.js"; +const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined; +const VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : undefined; + interface Props { onLogout: () => void; mobile?: boolean; @@ -76,7 +79,7 @@ export function Sidebar({ class="is-size-7 has-text-right" style={{ lineHeight: 0, marginTop: -10 }} > - {process.env.__VERSION__} ({config.version}) + {VERSION} ({config.version}) diff --git a/packages/merchant-backoffice-ui/src/custom.d.ts b/packages/merchant-backoffice-ui/src/custom.d.ts index b357d34ab..e60fa0c83 100644 --- a/packages/merchant-backoffice-ui/src/custom.d.ts +++ b/packages/merchant-backoffice-ui/src/custom.d.ts @@ -38,3 +38,5 @@ declare module '*.scss' { const content: Record; export default content; } +declare const __VERSION__: string; +declare const __GIT_HASH__: string; diff --git a/packages/merchant-backoffice-ui/src/index.html b/packages/merchant-backoffice-ui/src/index.html new file mode 100644 index 000000000..5f7080df8 --- /dev/null +++ b/packages/merchant-backoffice-ui/src/index.html @@ -0,0 +1,39 @@ + + + + + + + + + + + + + Merchant Backoffice + + + + + + + +
+ + diff --git a/packages/merchant-backoffice-ui/src/index.tsx b/packages/merchant-backoffice-ui/src/index.tsx index 3802a2149..c60471099 100644 --- a/packages/merchant-backoffice-ui/src/index.tsx +++ b/packages/merchant-backoffice-ui/src/index.tsx @@ -14,97 +14,11 @@ GNU Taler; see the file COPYING. If not, see */ -/** -* -* @author Sebastian Javier Marchano (sebasjm) -*/ +import {Application} from "./Application.js"; -import { h, VNode } from 'preact'; -import { route } from 'preact-router'; -import { useMemo } from "preact/hooks"; -import { ApplicationReadyRoutes } from "./ApplicationReadyRoutes.js"; -import { Loading } from "./components/exception/loading.js"; -import { NotificationCard, NotYetReadyAppMenu } from "./components/menu/index.js"; -import { BackendContextProvider, useBackendContext } from './context/backend.js'; -import { ConfigContextProvider } from './context/config.js'; -import { TranslationProvider } from './context/translation.js'; -import { useBackendConfig } from "./hooks/backend.js"; -import { useTranslator } from './i18n/index.js'; -import LoginPage from './paths/login/index.js'; +import { h, render } from "preact"; import "./scss/main.scss"; -export default function Application(): VNode { - return ( - // - - - - - - // - ); -} +const app = document.getElementById("app"); -function ApplicationStatusRoutes(): VNode { - const { updateLoginStatus, triedToLog } = useBackendContext() - const result = useBackendConfig(); - const i18n = useTranslator() - - 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) { - return
- - -
- } - - if (result.clientError && result.isUnauthorized) return
- - -
- - if (result.clientError && result.isNotfound) return
- - - -
- - if (result.serverError) return
- - - -
- - if (result.loading) return - - if (!result.ok) return
- - - -
- - return
- - - -
-} +render(, app as any); diff --git a/packages/merchant-backoffice-ui/src/scss/_mixins.scss b/packages/merchant-backoffice-ui/src/scss/_mixins.scss index 8df866de4..7d5f6b144 100644 --- a/packages/merchant-backoffice-ui/src/scss/_mixins.scss +++ b/packages/merchant-backoffice-ui/src/scss/_mixins.scss @@ -28,7 +28,7 @@ width: $icon-base-width; &.has-update-mark:after { - right: ($icon-base-width / 2) - .85; + right: calc($icon-base-width / 2) - .85; } } } diff --git a/packages/merchant-backoffice-ui/src/template.html b/packages/merchant-backoffice-ui/src/template.html deleted file mode 100644 index 306b90f11..000000000 --- a/packages/merchant-backoffice-ui/src/template.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - <%= htmlWebpackPlugin.options.title %> - - - - - - - - <% if (htmlWebpackPlugin.options.manifest.theme_color) { %> - - <% } %> - - <% for (const index in htmlWebpackPlugin.files.css) { %> - <% const file = htmlWebpackPlugin.files.css[index] %> - - <% } %> - - - - - - - - - -- cgit v1.2.3