From 4ee903eb5e639fa0e122a689cc431e8f18ca1197 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 6 Nov 2023 11:54:45 -0300 Subject: aml ui --- packages/aml-backoffice-ui/src/pages/Cases.tsx | 12 +++----- .../aml-backoffice-ui/src/pages/CreateAccount.tsx | 36 ++++++++++++---------- .../src/pages/HandleAccountNotReady.tsx | 3 ++ packages/aml-backoffice-ui/src/pages/Home.tsx | 5 --- packages/aml-backoffice-ui/src/pages/Officer.tsx | 10 +++--- packages/aml-backoffice-ui/src/pages/Settings.tsx | 5 --- .../aml-backoffice-ui/src/pages/UnlockAccount.tsx | 19 ++++++------ packages/aml-backoffice-ui/src/pages/Welcome.tsx | 9 ------ 8 files changed, 44 insertions(+), 55 deletions(-) delete mode 100644 packages/aml-backoffice-ui/src/pages/Home.tsx delete mode 100644 packages/aml-backoffice-ui/src/pages/Settings.tsx delete mode 100644 packages/aml-backoffice-ui/src/pages/Welcome.tsx (limited to 'packages/aml-backoffice-ui/src/pages') diff --git a/packages/aml-backoffice-ui/src/pages/Cases.tsx b/packages/aml-backoffice-ui/src/pages/Cases.tsx index 5f79db71e..624f2c985 100644 --- a/packages/aml-backoffice-ui/src/pages/Cases.tsx +++ b/packages/aml-backoffice-ui/src/pages/Cases.tsx @@ -4,17 +4,16 @@ import { VNode, h } from "preact"; import { useState } from "preact/hooks"; import { createNewForm } from "../handlers/forms.js"; import { useCases } from "../hooks/useCases.js"; -import { useOfficer } from "../hooks/useOfficer.js"; import { Pages } from "../pages.js"; import { AmlExchangeBackend } from "../types.js"; import { amlStateConverter } from "./CaseDetails.js"; +import { Officer } from "./Officer.js"; export function Cases() { const { i18n } = useTranslationContext(); const form = createNewForm<{ state: AmlExchangeBackend.AmlState }>(); - const initial = AmlExchangeBackend.AmlState.pending; const [stateFilter, setStateFilter] = useState(initial); @@ -23,16 +22,15 @@ export function Cases() { if (!list) { return } - if (list instanceof TalerError) { return } if (list.data.type === "fail") { switch (list.data.case) { - case "unauthorized": - case "officer-not-found": - case "officer-disabled": return
+ case "unauthorized": return + case "officer-not-found": return + case "officer-disabled": return default: assertUnreachable(list.data) } } @@ -116,7 +114,7 @@ export function Cases() {
{r.h_payto} diff --git a/packages/aml-backoffice-ui/src/pages/CreateAccount.tsx b/packages/aml-backoffice-ui/src/pages/CreateAccount.tsx index 5dcb8b21d..9b8c3c046 100644 --- a/packages/aml-backoffice-ui/src/pages/CreateAccount.tsx +++ b/packages/aml-backoffice-ui/src/pages/CreateAccount.tsx @@ -5,6 +5,7 @@ import { } from "@gnu-taler/web-util/browser"; import { VNode, h } from "preact"; import { createNewForm } from "../handlers/forms.js"; +import { useSettings } from "../hooks/useSettings.js"; export function CreateAccount({ onNewAccount, @@ -16,12 +17,13 @@ export function CreateAccount({ password: string; repeat: string; }>(); + const [settings] = useSettings() return (

- Create account + Create account

@@ -33,29 +35,29 @@ export function CreateAccount({ password: { error: !v.password ? i18n.str`required` - : v.password.length < 8 - ? i18n.str`should have at least 8 characters` - : !v.password.match(/[a-z]/) && v.password.match(/[A-Z]/) - ? i18n.str`should have lowercase and uppercase characters` - : !v.password.match(/\d/) - ? i18n.str`should have numbers` - : !v.password.match(/[^a-zA-Z\d]/) - ? i18n.str`should have at least one character which is not a number or letter` - : undefined, + : settings.allowInsecurePassword + ? undefined + : v.password.length < 8 + ? i18n.str`should have at least 8 characters` + : !v.password.match(/[a-z]/) && v.password.match(/[A-Z]/) + ? i18n.str`should have lowercase and uppercase characters` + : !v.password.match(/\d/) + ? i18n.str`should have numbers` + : !v.password.match(/[^a-zA-Z\d]/) + ? i18n.str`should have at least one character which is not a number or letter` + : undefined, }, repeat: { error: !v.repeat ? i18n.str`required` : v.repeat !== v.password - ? i18n.str`doesn't match` - : undefined, + ? i18n.str`doesn't match` + : undefined, }, }; }} onSubmit={async (v, s) => { - console.log(v, s); const error = s?.password?.error ?? s?.repeat?.error; - console.log(error); if (error) { notifyError( "Can't create account" as TranslatedString, @@ -72,7 +74,9 @@ export function CreateAccount({ name="password" type="password" help={ - "lower and upper case letters, number and special character" as TranslatedString + settings.allowInsecurePassword + ? i18n.str`short password are insecure, turn off insecure password in settings` + : i18n.str`lower and upper case letters, number and special character` } required /> @@ -91,7 +95,7 @@ export function CreateAccount({ type="submit" class="flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-semibold leading-6 text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600" > - Create + Create
diff --git a/packages/aml-backoffice-ui/src/pages/HandleAccountNotReady.tsx b/packages/aml-backoffice-ui/src/pages/HandleAccountNotReady.tsx index 05fd0a019..b3d04d97e 100644 --- a/packages/aml-backoffice-ui/src/pages/HandleAccountNotReady.tsx +++ b/packages/aml-backoffice-ui/src/pages/HandleAccountNotReady.tsx @@ -30,5 +30,8 @@ export function HandleAccountNotReady({ /> ); } + return
+ some +
throw Error(`unexpected account state ${(officer as any).state}`); } diff --git a/packages/aml-backoffice-ui/src/pages/Home.tsx b/packages/aml-backoffice-ui/src/pages/Home.tsx deleted file mode 100644 index 838032d63..000000000 --- a/packages/aml-backoffice-ui/src/pages/Home.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { h } from "preact"; - -export function Home() { - return
Home
; -} diff --git a/packages/aml-backoffice-ui/src/pages/Officer.tsx b/packages/aml-backoffice-ui/src/pages/Officer.tsx index 4af34805a..abada3725 100644 --- a/packages/aml-backoffice-ui/src/pages/Officer.tsx +++ b/packages/aml-backoffice-ui/src/pages/Officer.tsx @@ -1,9 +1,11 @@ import { Fragment, h } from "preact"; import { useOfficer } from "../hooks/useOfficer.js"; import { HandleAccountNotReady } from "./HandleAccountNotReady.js"; +import { useTranslationContext } from "@gnu-taler/web-util/browser"; export function Officer() { const officer = useOfficer(); + const { i18n } = useTranslationContext() if (officer.state !== "ready") { return ; } @@ -11,7 +13,7 @@ export function Officer() { return (

- Public key + Public key

{officer.account.id}

@@ -25,7 +27,7 @@ export function Officer() { rel="noreferrer" class="m-4 block rounded-md w-fit border-0 px-3 py-2 text-center text-sm bg-indigo-700 text-white shadow-sm hover:bg-indigo-700" > - Request account activation + Request account activation

@@ -36,7 +38,7 @@ export function Officer() { }} class="m-4 block rounded-md border-0 bg-gray-200 px-3 py-2 text-center text-sm text-black shadow-sm " > - Lock account + Lock account

@@ -47,7 +49,7 @@ export function Officer() { }} class="m-4 block rounded-md bg-red-600 px-3 py-2 text-center text-sm text-white shadow-sm hover:bg-red-500 " > - Remove account + Forget account

diff --git a/packages/aml-backoffice-ui/src/pages/Settings.tsx b/packages/aml-backoffice-ui/src/pages/Settings.tsx deleted file mode 100644 index ccff3b210..000000000 --- a/packages/aml-backoffice-ui/src/pages/Settings.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { h } from "preact"; - -export function Settings() { - return
Settings
; -} diff --git a/packages/aml-backoffice-ui/src/pages/UnlockAccount.tsx b/packages/aml-backoffice-ui/src/pages/UnlockAccount.tsx index 83d8767fb..a6570ffcc 100644 --- a/packages/aml-backoffice-ui/src/pages/UnlockAccount.tsx +++ b/packages/aml-backoffice-ui/src/pages/UnlockAccount.tsx @@ -1,5 +1,5 @@ import { TranslatedString, UnwrapKeyError } from "@gnu-taler/taler-util"; -import { notifyError, notifyInfo } from "@gnu-taler/web-util/browser"; +import { notifyError, notifyInfo, useTranslationContext } from "@gnu-taler/web-util/browser"; import { VNode, h } from "preact"; import { createNewForm } from "../handlers/forms.js"; @@ -10,6 +10,7 @@ export function UnlockAccount({ onAccountUnlocked: (password: string) => void; onRemoveAccount: () => void; }): VNode { + const { i18n } = useTranslationContext() const Form = createNewForm<{ password: string; }>(); @@ -17,12 +18,12 @@ export function UnlockAccount({ return (
-

- Account locked -

+

+ Account locked +

- Your account is normally locked anytime you reload. To unlock type - your password again. + Your account is normally locked anytime you reload. To unlock type + your password again.

@@ -30,7 +31,7 @@ export function UnlockAccount({
{ try { @@ -63,7 +64,7 @@ export function UnlockAccount({ type="submit" class="flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-semibold leading-6 text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600" > - Unlock + Unlock
@@ -75,7 +76,7 @@ export function UnlockAccount({ }} class="m-4 block rounded-md bg-red-600 px-3 py-2 text-center text-sm text-white shadow-sm hover:bg-red-500 " > - Remove account + Forget account
diff --git a/packages/aml-backoffice-ui/src/pages/Welcome.tsx b/packages/aml-backoffice-ui/src/pages/Welcome.tsx deleted file mode 100644 index 433fbcf59..000000000 --- a/packages/aml-backoffice-ui/src/pages/Welcome.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { h } from "preact"; - -export function Welcome({ name, asd }: { asd?: string; name?: string }) { - return ( -
- {asd} Hello {name} -
- ); -} -- cgit v1.2.3