From da9ec5eb16298d8ca5690800eca1c15f5a6cfaa5 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 14 Oct 2022 11:40:38 -0300 Subject: refactored terms of service to remove duplicated code prettfied some sources --- .../src/cta/InvoiceCreate/state.ts | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts') diff --git a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts index 4f75e982d..205a664e0 100644 --- a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts +++ b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts @@ -23,7 +23,7 @@ import { useSelectedExchange } from "../../hooks/useSelectedExchange.js"; import * as wxApi from "../../wxApi.js"; import { Props, State } from "./index.js"; -type RecursiveState = S | (() => RecursiveState) +type RecursiveState = S | (() => RecursiveState); export function useComponentState( { amount: amountStr, onClose, onSuccess }: Props, @@ -46,7 +46,7 @@ export function useComponentState( }; } - const exchangeList = hook.response.exchanges + const exchangeList = hook.response.exchanges; return () => { const [subject, setSubject] = useState(""); @@ -55,14 +55,17 @@ export function useComponentState( TalerErrorDetail | undefined >(undefined); + const selectedExchange = useSelectedExchange({ + currency: amount.currency, + defaultExchange: undefined, + list: exchangeList, + }); - const selectedExchange = useSelectedExchange({ currency: amount.currency, defaultExchange: undefined, list: exchangeList }) - - if (selectedExchange.status !== 'ready') { - return selectedExchange + if (selectedExchange.status !== "ready") { + return selectedExchange; } - const exchange = selectedExchange.selected + const exchange = selectedExchange.selected; async function accept(): Promise { try { @@ -105,9 +108,5 @@ export function useComponentState( error: undefined, operationError, }; - } - - - - + }; } -- cgit v1.2.3