aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-02-16 12:14:24 -0300
committerSebastian <sebasjm@gmail.com>2023-02-16 12:14:24 -0300
commit88e5634c974edc68d0870b1da65e8b0fca7a9de2 (patch)
tree1849a7909ceb93d701d1af718f2af686f90b6e1a
parentd49960639a61bf0d27bf75a71a7f91077f4e2df6 (diff)
workaround swr default import
-rw-r--r--packages/demobank-ui/src/hooks/access.ts19
-rw-r--r--packages/demobank-ui/src/hooks/circuit.ts14
-rw-r--r--packages/demobank-ui/tsconfig.json2
3 files changed, 21 insertions, 14 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, {
diff --git a/packages/demobank-ui/tsconfig.json b/packages/demobank-ui/tsconfig.json
index 78a686aff..abb9a9f36 100644
--- a/packages/demobank-ui/tsconfig.json
+++ b/packages/demobank-ui/tsconfig.json
@@ -48,4 +48,4 @@
"include": [
"src/**/*"
]
-}
+} \ No newline at end of file