From da93d2ba7eca78359490d5e35b8c70b2bcaf4072 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 12 May 2023 11:23:38 -0300 Subject: fix getting wrong error message after 401 response in merchant backoffice --- packages/demobank-ui/src/hooks/access.ts | 8 ++++---- packages/demobank-ui/src/hooks/backend.ts | 4 +++- packages/demobank-ui/src/hooks/circuit.ts | 8 ++++---- 3 files changed, 11 insertions(+), 9 deletions(-) (limited to 'packages/demobank-ui') diff --git a/packages/demobank-ui/src/hooks/access.ts b/packages/demobank-ui/src/hooks/access.ts index 0d4a8bab8..b8b6ab899 100644 --- a/packages/demobank-ui/src/hooks/access.ts +++ b/packages/demobank-ui/src/hooks/access.ts @@ -209,7 +209,7 @@ export function useAccountDetails( }); return clone; } - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } @@ -239,7 +239,7 @@ export function useWithdrawalDetails( // if (isValidating) return { loading: true, data: data?.data }; if (data) return data; - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } @@ -269,7 +269,7 @@ export function useTransactionDetails( // if (isValidating) return { loading: true, data: data?.data }; if (data) return data; - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } @@ -307,7 +307,7 @@ export function usePublicAccounts( if (afterData) setLastAfter(afterData); }, [afterData]); - if (afterError) return afterError.info; + if (afterError) return afterError.cause; // if the query returns less that we ask, then we have reach the end or beginning const isReachingEnd = diff --git a/packages/demobank-ui/src/hooks/backend.ts b/packages/demobank-ui/src/hooks/backend.ts index df85252f7..83df53a1a 100644 --- a/packages/demobank-ui/src/hooks/backend.ts +++ b/packages/demobank-ui/src/hooks/backend.ts @@ -347,7 +347,9 @@ export function useBackendConfig(): HttpResponse< useEffect(() => { request(`/config`) .then((data) => setResult(data)) - .catch((error) => setResult(error)); + .catch((error: RequestError) => + setResult(error.cause), + ); }, [request]); return result; diff --git a/packages/demobank-ui/src/hooks/circuit.ts b/packages/demobank-ui/src/hooks/circuit.ts index 3ed8ad358..06557b77f 100644 --- a/packages/demobank-ui/src/hooks/circuit.ts +++ b/packages/demobank-ui/src/hooks/circuit.ts @@ -379,7 +379,7 @@ export function useBusinessAccountDetails( }); if (data) return data; - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } @@ -406,7 +406,7 @@ export function useRatiosAndFeeConfig(): HttpResponse< }); if (data) return data; - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } @@ -479,7 +479,7 @@ export function useBusinessAccounts( return { ok: true as const, data: { customers }, ...pagination }; }, [afterData?.data]); - if (afterError) return afterError.info; + if (afterError) return afterError.cause; if (afterData) { return result; } @@ -565,6 +565,6 @@ export function useCashoutDetails( }); if (data) return data; - if (error) return error.info; + if (error) return error.cause; return { loading: true }; } -- cgit v1.2.3