workaround swr default import
This commit is contained in:
parent
d49960639a
commit
88e5634c97
@ -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>
|
||||
>(
|
||||
|
@ -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, {
|
||||
|
Loading…
Reference in New Issue
Block a user