diff options
Diffstat (limited to 'packages/demobank-ui/src/hooks')
-rw-r--r-- | packages/demobank-ui/src/hooks/access.ts | 19 | ||||
-rw-r--r-- | packages/demobank-ui/src/hooks/circuit.ts | 14 |
2 files changed, 20 insertions, 13 deletions
diff --git a/packages/demobank-ui/src/hooks/access.ts b/packages/demobank-ui/src/hooks/access.ts index 9314af557..0379de27d 100644 --- a/packages/demobank-ui/src/hooks/access.ts +++ b/packages/demobank-ui/src/hooks/access.ts @@ -18,18 +18,21 @@ import { HttpResponse, HttpResponseOk, HttpResponsePaginated, - RequestError, + RequestError } from "@gnu-taler/web-util/lib/index.browser"; import { useEffect, useState } from "preact/hooks"; -import useSWR from "swr"; import { useBackendContext } from "../context/backend.js"; import { MAX_RESULT_SIZE, PAGE_SIZE } from "../utils.js"; import { useAuthenticatedBackend, useMatchMutate, - usePublicBackend, + usePublicBackend } from "./backend.js"; +// FIX default import https://github.com/microsoft/TypeScript/issues/49189 +import _useSWR, { SWRHook } from 'swr'; +const useSWR = _useSWR as unknown as SWRHook + export function useAccessAPI(): AccessAPI { const mutateAll = useMatchMutate(); const { request } = useAuthenticatedBackend(); @@ -162,7 +165,7 @@ export function useAccountDetails( > { const { fetcher } = useAuthenticatedBackend(); - const { data, error } = useSWR.default< + const { data, error } = useSWR< HttpResponseOk<SandboxBackend.Access.BankAccountBalanceResponse>, RequestError<SandboxBackend.SandboxError> >([`access-api/accounts/${account}`], fetcher, { @@ -192,7 +195,7 @@ export function useWithdrawalDetails( > { const { fetcher } = useAuthenticatedBackend(); - const { data, error } = useSWR.default< + const { data, error } = useSWR< HttpResponseOk<SandboxBackend.Access.BankAccountGetWithdrawalResponse>, RequestError<SandboxBackend.SandboxError> >([`access-api/accounts/${account}/withdrawals/${wid}`], fetcher, { @@ -222,7 +225,7 @@ export function useTransactionDetails( > { const { fetcher } = useAuthenticatedBackend(); - const { data, error } = useSWR.default< + const { data, error } = useSWR< HttpResponseOk<SandboxBackend.Access.BankAccountTransactionInfo>, RequestError<SandboxBackend.SandboxError> >([`access-api/accounts/${account}/transactions/${tid}`], fetcher, { @@ -261,7 +264,7 @@ export function usePublicAccounts( data: afterData, error: afterError, isValidating: loadingAfter, - } = useSWR.default< + } = useSWR< HttpResponseOk<SandboxBackend.Access.PublicAccountsResponse>, RequestError<SandboxBackend.SandboxError> >([`public-accounts`, args?.page, PAGE_SIZE], paginatedFetcher); @@ -329,7 +332,7 @@ export function useTransactions( data: afterData, error: afterError, isValidating: loadingAfter, - } = useSWR.default< + } = useSWR< HttpResponseOk<SandboxBackend.Access.BankAccountTransactionsResponse>, RequestError<SandboxBackend.SandboxError> >( diff --git a/packages/demobank-ui/src/hooks/circuit.ts b/packages/demobank-ui/src/hooks/circuit.ts index 19a48224f..21e5ce852 100644 --- a/packages/demobank-ui/src/hooks/circuit.ts +++ b/packages/demobank-ui/src/hooks/circuit.ts @@ -22,11 +22,14 @@ import { useApiContext, } from "@gnu-taler/web-util/lib/index.browser"; import { useEffect, useMemo, useState } from "preact/hooks"; -import useSWR from "swr"; import { useBackendContext } from "../context/backend.js"; import { MAX_RESULT_SIZE, PAGE_SIZE } from "../utils.js"; import { useAuthenticatedBackend, useMatchMutate } from "./backend.js"; +// FIX default import https://github.com/microsoft/TypeScript/issues/49189 +import _useSWR, { SWRHook } from 'swr'; +const useSWR = _useSWR as unknown as SWRHook + export function useAdminAccountAPI(): AdminAccountAPI { const { request } = useAuthenticatedBackend(); const mutateAll = useMatchMutate(); @@ -194,7 +197,7 @@ export function useBusinessAccountDetails( > { const { fetcher } = useAuthenticatedBackend(); - const { data, error } = useSWR.default< + const { data, error } = useSWR< HttpResponseOk<SandboxBackend.Circuit.CircuitAccountData>, RequestError<SandboxBackend.SandboxError> >([`circuit-api/accounts/${account}`], fetcher, { @@ -232,7 +235,7 @@ export function useBusinessAccounts( data: afterData, error: afterError, // isValidating: loadingAfter, - } = useSWR.default< + } = useSWR< HttpResponseOk<SandboxBackend.Circuit.CircuitAccounts>, RequestError<SandboxBackend.SandboxError> >( @@ -302,7 +305,8 @@ export function useCashouts(): HttpResponse< > { const { fetcher, multiFetcher } = useAuthenticatedBackend(); - const { data: list, error: listError } = useSWR.default< + + const { data: list, error: listError } = useSWR< HttpResponseOk<SandboxBackend.Circuit.Cashouts>, RequestError<SandboxBackend.SandboxError> >([`circuit-api/cashouts`], fetcher, { @@ -316,7 +320,7 @@ export function useCashouts(): HttpResponse< const paths = (list?.data.cashouts || []).map( (cashoutId) => `circuit-api/cashouts/${cashoutId}`, ); - const { data: cashouts, error: productError } = useSWR.default< + const { data: cashouts, error: productError } = useSWR< HttpResponseOk<SandboxBackend.Circuit.CashoutStatusResponse>[], RequestError<SandboxBackend.SandboxError> >([paths], multiFetcher, { |