diff options
author | Sebastian <sebasjm@gmail.com> | 2022-06-06 00:04:53 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-06-06 00:04:53 -0300 |
commit | e3c92b6080f4b2c7f146bd84953ef51114b23cdb (patch) | |
tree | 72391332d5a949bf2c7009d56ad633f3d4c1a30e /packages/anastasis-webui/src | |
parent | 1c1384d7c8193aa17375e630a960644f669d2b48 (diff) | |
download | wallet-core-e3c92b6080f4b2c7f146bd84953ef51114b23cdb.tar.xz |
updating package
Diffstat (limited to 'packages/anastasis-webui/src')
5 files changed, 49 insertions, 59 deletions
diff --git a/packages/anastasis-webui/src/components/picker/DurationPicker.tsx b/packages/anastasis-webui/src/components/picker/DurationPicker.tsx index 8a1faf4d0..dc4a13a44 100644 --- a/packages/anastasis-webui/src/components/picker/DurationPicker.tsx +++ b/packages/anastasis-webui/src/components/picker/DurationPicker.tsx @@ -21,7 +21,7 @@ import { h, VNode } from "preact"; import { useState } from "preact/hooks"; -import { useTranslator } from "../../i18n"; +import { useTranslator } from "../../i18n/index.js"; import "../../scss/DurationPicker.scss"; export interface Props { diff --git a/packages/anastasis-webui/src/hooks/use-anastasis-reducer.ts b/packages/anastasis-webui/src/hooks/use-anastasis-reducer.ts index 1b77db38f..1ff3f66fa 100644 --- a/packages/anastasis-webui/src/hooks/use-anastasis-reducer.ts +++ b/packages/anastasis-webui/src/hooks/use-anastasis-reducer.ts @@ -323,7 +323,7 @@ export function useAnastasisReducer(): AnastasisReducerApi { }, }); }, - async discoverMore(): Promise<void> {}, + async discoverMore(): Promise<void> { }, async startRecover() { let s: ReducerState; if (remoteReducer) { @@ -403,7 +403,7 @@ export function useAnastasisReducer(): AnastasisReducerApi { } class ReducerTxImpl implements ReducerTransactionHandle { - constructor(public transactionState: ReducerState) {} + constructor(public transactionState: ReducerState) { } async transition(action: string, args: any): Promise<ReducerState> { let s: ReducerState; if (remoteReducer) { diff --git a/packages/anastasis-webui/src/pages/home/AddingProviderScreen.tsx b/packages/anastasis-webui/src/pages/home/AddingProviderScreen.tsx index d85aa5974..3f3abdb54 100644 --- a/packages/anastasis-webui/src/pages/home/AddingProviderScreen.tsx +++ b/packages/anastasis-webui/src/pages/home/AddingProviderScreen.tsx @@ -59,6 +59,26 @@ export function AddingProviderScreen({ providerType, onCancel }: Props): VNode { ? authMethods[providerType].label : undefined; + const allAuthProviders = + !reducer || + !reducer.currentReducerState || + reducer.currentReducerState.reducer_type === "error" || + !reducer.currentReducerState.authentication_providers + ? {} + : reducer.currentReducerState.authentication_providers; + const authProviders = Object.keys(allAuthProviders).filter((provUrl) => { + const p = allAuthProviders[provUrl]; + if (!providerLabel) { + return p && "currency" in p; + } else { + return ( + p && + "currency" in p && + p.methods.findIndex((m) => m.type === providerType) !== -1 + ); + } + }); + //FIXME: move this timeout logic into a hook const timeout = useRef<number | undefined>(undefined); useEffect(() => { @@ -69,17 +89,22 @@ export function AddingProviderScreen({ providerType, onCancel }: Props): VNode { try { setTesting(true); await testProvider(url, providerType); - // this is use as tested but everything when ok - // undefined will mean that the field is not dirty setError(""); } catch (e) { - console.log("tuvieja", e); if (e instanceof Error) setError(e.message); } setTesting(false); }, 200); }, [providerURL, reducer]); + async function addProvider(provider_url: string): Promise<void> { + await reducer?.transition("add_provider", { provider_url }); + onCancel(); + } + function deleteProvider(provider_url: string): void { + reducer?.transition("delete_provider", { provider_url }); + } + if (!reducer) { return <div>no reducer in context</div>; } @@ -91,29 +116,6 @@ export function AddingProviderScreen({ providerType, onCancel }: Props): VNode { return <div>invalid state</div>; } - async function addProvider(provider_url: string): Promise<void> { - await reducer?.transition("add_provider", { provider_url }); - onCancel(); - } - function deleteProvider(provider_url: string): void { - reducer?.transition("delete_provider", { provider_url }); - } - - const allAuthProviders = - reducer.currentReducerState.authentication_providers || {}; - const authProviders = Object.keys(allAuthProviders).filter((provUrl) => { - const p = allAuthProviders[provUrl]; - if (!providerLabel) { - return p && "currency" in p; - } else { - return ( - p && - "currency" in p && - p.methods.findIndex((m) => m.type === providerType) !== -1 - ); - } - }); - let errors = !providerURL ? "Add provider URL" : undefined; let url: string | undefined; try { @@ -190,7 +192,9 @@ export function AddingProviderScreen({ providerType, onCancel }: Props): VNode { {authProviders.map((k) => { const p = allAuthProviders[k] as AuthenticationProviderStatusOk; - return <TableRow url={k} info={p} onDelete={deleteProvider} />; + return ( + <TableRow key={k} url={k} info={p} onDelete={deleteProvider} /> + ); })} </div> </AnastasisClientFrame> diff --git a/packages/anastasis-webui/src/pages/home/style.css b/packages/anastasis-webui/src/pages/home/style.css deleted file mode 100644 index e69de29bb..000000000 --- a/packages/anastasis-webui/src/pages/home/style.css +++ /dev/null diff --git a/packages/anastasis-webui/src/utils/index.tsx b/packages/anastasis-webui/src/utils/index.tsx index 2e502cacb..a59b19323 100644 --- a/packages/anastasis-webui/src/utils/index.tsx +++ b/packages/anastasis-webui/src/utils/index.tsx @@ -1,6 +1,4 @@ -/* eslint-disable @typescript-eslint/camelcase */ import { - AuthenticationProviderStatus, AuthenticationProviderStatusError, AuthenticationProviderStatusOk, BackupStates, @@ -9,7 +7,11 @@ import { ReducerStateRecovery, } from "@gnu-taler/anastasis-core"; import { FunctionalComponent, h, VNode } from "preact"; -import { AnastasisProvider } from "../context/anastasis"; +import { AnastasisProvider } from "../context/anastasis.js"; + +const noop = async (): Promise<void> => { + return; +}; export function createExample<Props>( Component: FunctionalComponent<Props>, @@ -21,39 +23,23 @@ export function createExample<Props>( <AnastasisProvider value={{ currentReducerState, - discoverMore: async () => {}, - discoverStart: async () => {}, + discoverMore: noop, + discoverStart: noop, discoveryState: { state: "none", }, currentError: undefined, - back: async () => { - null; - }, - dismissError: async () => { - null; - }, - reset: () => { - null; - }, - runTransaction: async () => { - null; - }, - startBackup: () => { - null; - }, - startRecover: () => { - null; - }, - transition: async () => { - null; - }, + back: noop, + dismissError: noop, + reset: noop, + runTransaction: noop, + startBackup: noop, + startRecover: noop, + transition: noop, exportState: () => { return "{}"; }, - importState(s: string) { - /* do nothing */ - }, + importState: noop, }} > <Component {...args} /> |