aboutsummaryrefslogtreecommitdiff
path: root/packages/aml-backoffice-ui/src/Dashboard.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/aml-backoffice-ui/src/Dashboard.tsx')
-rw-r--r--packages/aml-backoffice-ui/src/Dashboard.tsx232
1 files changed, 132 insertions, 100 deletions
diff --git a/packages/aml-backoffice-ui/src/Dashboard.tsx b/packages/aml-backoffice-ui/src/Dashboard.tsx
index 3951b48c7..78980265d 100644
--- a/packages/aml-backoffice-ui/src/Dashboard.tsx
+++ b/packages/aml-backoffice-ui/src/Dashboard.tsx
@@ -1,17 +1,39 @@
+/*
+ This file is part of GNU Taler
+ (C) 2022 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 <http://www.gnu.org/licenses/>
+ */
import { TranslatedString } from "@gnu-taler/taler-util";
-import { Footer, ToastBanner, Header, notifyError, notifyException, useTranslationContext } from "@gnu-taler/web-util/browser";
-import { ComponentChildren, Fragment, VNode, h } from "preact";
+import {
+ Footer,
+ Header,
+ ToastBanner,
+ notifyError,
+ notifyException,
+ useTranslationContext,
+} from "@gnu-taler/web-util/browser";
+import { ComponentChildren, VNode, h } from "preact";
import { useEffect, useErrorBoundary } from "preact/hooks";
import { useOfficer } from "./hooks/useOfficer.js";
-import { getAllBooleanSettings, getLabelForSetting, useSettings } from "./hooks/useSettings.js";
+import {
+ getAllBooleanSettings,
+ getLabelForSetting,
+ useSettings,
+} from "./hooks/useSettings.js";
import { Pages } from "./pages.js";
import { PageEntry, useChangeLocation } from "./route.js";
import { uiSettings } from "./settings.js";
-function classNames(...classes: string[]) {
- return classes.filter(Boolean).join(" ");
-}
-
/**
* mapping route to view
* not found (error page)
@@ -37,12 +59,6 @@ function classNames(...classes: string[]) {
const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined;
const VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : undefined;
-const versionText = VERSION
- ? GIT_HASH
- ? `v${VERSION} (${GIT_HASH.substring(0, 8)})`
- : VERSION
- : "";
-
/**
* TO BE FIXED:
*
@@ -77,16 +93,16 @@ const versionText = VERSION
/**
* check this fields
- *
+ *
* Signature of Contracting partner, 902_9e
* Currency and amount of deposited assets, 902_5e
* Signature on declaration of trust, 902.13e
* also fundations
* also life insurance
- *
+ *
* no all state are handled by all the inputs
* all the input implementation should respect
- * ui props and state
+ * ui props and state
*/
export function ExchangeAmlFrame({
@@ -96,114 +112,134 @@ export function ExchangeAmlFrame({
}): VNode {
const { i18n } = useTranslationContext();
- const [error, resetError] = useErrorBoundary();
+ const [error] = useErrorBoundary();
useEffect(() => {
if (error) {
if (error instanceof Error) {
- notifyException(i18n.str`Internal error, please report.`, error)
+ notifyException(i18n.str`Internal error, please report.`, error);
} else {
- notifyError(i18n.str`Internal error, please report.`, String(error) as TranslatedString)
+ notifyError(
+ i18n.str`Internal error, please report.`,
+ String(error) as TranslatedString,
+ );
}
- console.log(error)
+ console.log(error);
// resetError()
}
- }, [error])
+ }, [error]);
const officer = useOfficer();
const [settings, updateSettings] = useSettings();
- return (<div class="min-h-full flex flex-col m-0 bg-slate-200" style="min-height: 100vh;">
- <div class="bg-indigo-600 pb-32">
- <Header
- title="Exchange"
- iconLinkURL={uiSettings.backendBaseURL ?? "#"}
- onLogout={officer.state !== "ready" ? undefined : () => {
- officer.lock()
- }}
- sites={[]}
- supportedLangs={["en", "es", "de"]}
- >
- <li>
- <div class="text-xs font-semibold leading-6 text-gray-400">
- <i18n.Translate>Preferences</i18n.Translate>
- </div>
- <ul role="list" class="space-y-1">
- {getAllBooleanSettings().map(set => {
- const isOn: boolean = !!settings[set]
- return <li class="mt-2 pl-2">
- <div class="flex items-center justify-between">
- <span class="flex flex-grow flex-col">
- <span class="text-sm text-black font-medium leading-6 " id="availability-label">
- {getLabelForSetting(set, i18n)}
- </span>
- </span>
- <button type="button" data-enabled={isOn} class="bg-indigo-600 data-[enabled=false]:bg-gray-200 relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2" role="switch" aria-checked="false" aria-labelledby="availability-label" aria-describedby="availability-description"
-
- onClick={() => { updateSettings(set, !isOn); }}>
- <span aria-hidden="true" data-enabled={isOn} class="translate-x-5 data-[enabled=false]:translate-x-0 pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out"></span>
- </button>
- </div>
- </li>
- })}
- </ul>
- </li>
- </Header>
- </div>
+ return (
+ <div
+ class="min-h-full flex flex-col m-0 bg-slate-200"
+ style="min-height: 100vh;"
+ >
+ <div class="bg-indigo-600 pb-32">
+ <Header
+ title="Exchange"
+ iconLinkURL={uiSettings.backendBaseURL ?? "#"}
+ onLogout={
+ officer.state !== "ready"
+ ? undefined
+ : () => {
+ officer.lock();
+ }
+ }
+ sites={[]}
+ supportedLangs={["en", "es", "de"]}
+ >
+ <li>
+ <div class="text-xs font-semibold leading-6 text-gray-400">
+ <i18n.Translate>Preferences</i18n.Translate>
+ </div>
+ <ul role="list" class="space-y-1">
+ {getAllBooleanSettings().map((set) => {
+ const isOn: boolean = !!settings[set];
+ return (
+ <li key={set} class="mt-2 pl-2">
+ <div class="flex items-center justify-between">
+ <span class="flex flex-grow flex-col">
+ <span
+ class="text-sm text-black font-medium leading-6 "
+ id="availability-label"
+ >
+ {getLabelForSetting(set, i18n)}
+ </span>
+ </span>
+ <button
+ type="button"
+ data-enabled={isOn}
+ class="bg-indigo-600 data-[enabled=false]:bg-gray-200 relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2"
+ role="switch"
+ aria-checked="false"
+ aria-labelledby="availability-label"
+ aria-describedby="availability-description"
+ onClick={() => {
+ updateSettings(set, !isOn);
+ }}
+ >
+ <span
+ aria-hidden="true"
+ data-enabled={isOn}
+ class="translate-x-5 data-[enabled=false]:translate-x-0 pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out"
+ ></span>
+ </button>
+ </div>
+ </li>
+ );
+ })}
+ </ul>
+ </li>
+ </Header>
+ </div>
- <div class="fixed z-20 w-full">
- <div class="mx-auto w-4/5">
- <ToastBanner />
+ <div class="fixed z-20 w-full">
+ <div class="mx-auto w-4/5">
+ <ToastBanner />
+ </div>
</div>
- </div>
- <div class="-mt-32 flex grow ">
- {officer.state !== "ready" ? undefined :
- <Navigation />
- }
- <div class="flex mx-auto my-4">
- <main class="rounded-lg bg-white px-5 py-6 shadow">
- {children}
- </main>
+ <div class="-mt-32 flex grow ">
+ {officer.state !== "ready" ? undefined : <Navigation />}
+ <div class="flex mx-auto my-4">
+ <main class="rounded-lg bg-white px-5 py-6 shadow">{children}</main>
+ </div>
</div>
+ <Footer
+ testingUrlKey="exchange-base-url"
+ GIT_HASH={GIT_HASH}
+ VERSION={VERSION}
+ />
</div>
-
- <Footer
- testingUrlKey="exchange-base-url"
- GIT_HASH={GIT_HASH}
- VERSION={VERSION}
- />
- </div>
);
}
function Navigation(): VNode {
- const { i18n } = useTranslationContext()
- const pageList: Array<PageEntry> = [
- Pages.officer,
- Pages.cases
- ]
+ const pageList: Array<PageEntry> = [Pages.officer, Pages.cases];
const location = useChangeLocation();
return (
<div class="hidden sm:block min-w-min bg-indigo-600 divide-y rounded-r-lg divide-cyan-800 overflow-y-auto overflow-x-clip">
-
<nav class="flex flex-1 flex-col mx-4 mt-4 mb-2">
<ul role="list" class="flex flex-1 flex-col gap-y-7">
<li>
<ul role="list" class="-mx-2 space-y-1">
- {pageList.map(p => {
-
- return <li>
- <a href={p.url} data-selected={location == p.url}
- class="data-[selected=true]:bg-indigo-700 pr-4 data-[selected=true]:text-white text-indigo-200 hover:text-white hover:bg-indigo-700 group flex gap-x-3 rounded-md p-2 text-sm leading-6 font-semibold">
- {p.Icon && <p.Icon />}
- <span class="hidden md:inline">
- {p.name}
- </span>
- </a>
- </li>
-
+ {pageList.map((p) => {
+ return (
+ <li key={p.url}>
+ <a
+ href={p.url}
+ data-selected={location == p.url}
+ class="data-[selected=true]:bg-indigo-700 pr-4 data-[selected=true]:text-white text-indigo-200 hover:text-white hover:bg-indigo-700 group flex gap-x-3 rounded-md p-2 text-sm leading-6 font-semibold"
+ >
+ {p.Icon && <p.Icon />}
+ <span class="hidden md:inline">{p.name}</span>
+ </a>
+ </li>
+ );
})}
{/* <li>
<a href="#" class="text-indigo-200 hover:text-white hover:bg-indigo-700 group flex gap-x-3 rounded-md p-2 text-sm leading-6 font-semibold">
@@ -223,12 +259,8 @@ function Navigation(): VNode {
Settings
</a>
</li> */}
-
</ul>
</nav>
</div>
- )
-
+ );
}
-
-