aboutsummaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/hooks/templates.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-02-10 09:50:54 -0300
committerSebastian <sebasjm@gmail.com>2023-02-10 09:52:01 -0300
commit53af8b486fd8a538c1f54a2ce66ed5f74b2b46ed (patch)
treefdda21230b6f98a8cf84f6459910c76c610234dd /packages/merchant-backoffice-ui/src/hooks/templates.ts
parent7a591c39d78c5183ae05d36221d0bcf8322cea92 (diff)
downloadwallet-core-53af8b486fd8a538c1f54a2ce66ed5f74b2b46ed.tar.xz
fix: request error is whats being thrown
Diffstat (limited to 'packages/merchant-backoffice-ui/src/hooks/templates.ts')
-rw-r--r--packages/merchant-backoffice-ui/src/hooks/templates.ts20
1 files changed, 10 insertions, 10 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/templates.ts b/packages/merchant-backoffice-ui/src/hooks/templates.ts
index 124786887..579478537 100644
--- a/packages/merchant-backoffice-ui/src/hooks/templates.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/templates.ts
@@ -13,17 +13,17 @@
You should have received a copy of the GNU General Public License along with
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { MerchantBackend } from "../declaration.js";
-import { useMatchMutate, useBackendInstanceRequest } from "./backend.js";
-import useSWR from "swr";
-import { MAX_RESULT_SIZE, PAGE_SIZE } from "../utils/constants.js";
-import { useEffect, useState } from "preact/hooks";
import {
- HttpError,
HttpResponse,
HttpResponseOk,
HttpResponsePaginated,
+ RequestError,
} from "@gnu-taler/web-util/lib/index.browser";
+import { useEffect, useState } from "preact/hooks";
+import useSWR from "swr";
+import { MerchantBackend } from "../declaration.js";
+import { MAX_RESULT_SIZE, PAGE_SIZE } from "../utils/constants.js";
+import { useBackendInstanceRequest, useMatchMutate } from "./backend.js";
export function useTemplateAPI(): TemplateAPI {
const mutateAll = useMatchMutate();
@@ -148,7 +148,7 @@ export function useInstanceTemplates(
isValidating: loadingAfter,
} = useSWR<
HttpResponseOk<MerchantBackend.Template.TemplateSummaryResponse>,
- HttpError<MerchantBackend.ErrorDetail>
+ RequestError<MerchantBackend.ErrorDetail>
>([`/private/templates`, args?.position, -totalAfter], templateFetcher);
//this will save last result
@@ -167,7 +167,7 @@ export function useInstanceTemplates(
}, [afterData /*, beforeData*/]);
// if (beforeError) return beforeError;
- if (afterError) return afterError;
+ if (afterError) return afterError.info;
// if the query returns less that we ask, then we have reach the end or beginning
const isReachingEnd =
@@ -231,7 +231,7 @@ export function useTemplateDetails(
const { data, error, isValidating } = useSWR<
HttpResponseOk<MerchantBackend.Template.TemplateDetails>,
- HttpError<MerchantBackend.ErrorDetail>
+ RequestError<MerchantBackend.ErrorDetail>
>([`/private/templates/${templateId}`], templateFetcher, {
refreshInterval: 0,
refreshWhenHidden: false,
@@ -242,6 +242,6 @@ export function useTemplateDetails(
if (isValidating) return { loading: true, data: data?.data };
if (data) return data;
- if (error) return error;
+ if (error) return error.info;
return { loading: true };
}