diff options
author | Sebastian <sebasjm@gmail.com> | 2023-10-21 20:25:38 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-10-21 20:25:50 -0300 |
commit | 2ac73949e7cb8de44e56f2fecae617efab15671e (patch) | |
tree | 144a97d71bc9fa964675ef0cc764087ceb14e8eb /packages/demobank-ui/src/hooks/circuit.ts | |
parent | 4b98b693d696d90f30f0a6546b0e1f4bc181a5f2 (diff) | |
download | wallet-core-2ac73949e7cb8de44e56f2fecae617efab15671e.tar.xz |
more ui
Diffstat (limited to 'packages/demobank-ui/src/hooks/circuit.ts')
-rw-r--r-- | packages/demobank-ui/src/hooks/circuit.ts | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/packages/demobank-ui/src/hooks/circuit.ts b/packages/demobank-ui/src/hooks/circuit.ts index 0f7af5fe5..06e068d6d 100644 --- a/packages/demobank-ui/src/hooks/circuit.ts +++ b/packages/demobank-ui/src/hooks/circuit.ts @@ -15,16 +15,15 @@ */ import { useState } from "preact/hooks"; -import { useBackendContext } from "../context/backend.js"; import { MAX_RESULT_SIZE, PAGE_SIZE } from "../utils.js"; import { useBackendState } from "./backend.js"; -// FIX default import https://github.com/microsoft/TypeScript/issues/49189 import { AccessToken, AmountJson, Amounts, OperationOk, TalerCoreBankResultByMethod, TalerCorebankApi, TalerError, TalerHttpError } from "@gnu-taler/taler-util"; import _useSWR, { SWRHook } from "swr"; import { useBankCoreApiContext } from "../context/config.js"; import { assertUnreachable } from "../pages/HomePage.js"; +// FIX default import https://github.com/microsoft/TypeScript/issues/49189 const useSWR = _useSWR as unknown as SWRHook; export type TransferCalculation = { @@ -44,12 +43,8 @@ type CashoutEstimators = { }; export function useEstimator(): CashoutEstimators { - const { state } = useBackendContext(); + const { state } = useBackendState(); const { api } = useBankCoreApiContext(); - const creds = - state.status !== "loggedIn" - ? undefined - : state.token; return { estimateByCredit: async (amount, fee, rate) => { const resp = await api.getCashoutRate({ @@ -101,13 +96,14 @@ export function useEstimator(): CashoutEstimators { } export function useRatiosAndFeeConfig() { - const { api } = useBankCoreApiContext(); + const { api, config } = useBankCoreApiContext(); + function fetcher() { return api.getConversionRates() } const { data, error } = useSWR<TalerCoreBankResultByMethod<"getConversionRates">, TalerHttpError>( - [, "getConversionRates"], fetcher, { + !config.have_cashout || !config.fiat_currency ? false : [, "getConversionRates"], fetcher, { refreshInterval: 60 * 1000, refreshWhenHidden: false, revalidateOnFocus: false, |