aboutsummaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/hooks/webhooks.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/merchant-backoffice-ui/src/hooks/webhooks.ts')
-rw-r--r--packages/merchant-backoffice-ui/src/hooks/webhooks.ts32
1 files changed, 20 insertions, 12 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/webhooks.ts b/packages/merchant-backoffice-ui/src/hooks/webhooks.ts
index 9f196cefa..e1cd3daf2 100644
--- a/packages/merchant-backoffice-ui/src/hooks/webhooks.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/webhooks.ts
@@ -23,7 +23,7 @@ import {
HttpResponse,
HttpResponseOk,
HttpResponsePaginated,
-} from "../utils/request.js";
+} from "@gnu-taler/web-util/lib/index.browser";
export function useWebhookAPI(): WebhookAPI {
const mutateAll = useMatchMutate();
@@ -84,7 +84,10 @@ export interface InstanceWebhookFilter {
export function useInstanceWebhooks(
args?: InstanceWebhookFilter,
updatePosition?: (id: string) => void,
-): HttpResponsePaginated<MerchantBackend.Webhooks.WebhookSummaryResponse> {
+): HttpResponsePaginated<
+ MerchantBackend.Webhooks.WebhookSummaryResponse,
+ MerchantBackend.ErrorDetail
+> {
const { webhookFetcher } = useBackendInstanceRequest();
const [pageAfter, setPageAfter] = useState(1);
@@ -97,11 +100,14 @@ export function useInstanceWebhooks(
isValidating: loadingAfter,
} = useSWR<
HttpResponseOk<MerchantBackend.Webhooks.WebhookSummaryResponse>,
- HttpError
+ HttpError<MerchantBackend.ErrorDetail>
>([`/private/webhooks`, args?.position, -totalAfter], webhookFetcher);
const [lastAfter, setLastAfter] = useState<
- HttpResponse<MerchantBackend.Webhooks.WebhookSummaryResponse>
+ HttpResponse<
+ MerchantBackend.Webhooks.WebhookSummaryResponse,
+ MerchantBackend.ErrorDetail
+ >
>({ loading: true });
useEffect(() => {
if (afterData) setLastAfter(afterData);
@@ -121,21 +127,20 @@ export function useInstanceWebhooks(
if (afterData.data.webhooks.length < MAX_RESULT_SIZE) {
setPageAfter(pageAfter + 1);
} else {
- const from = `${afterData.data.webhooks[afterData.data.webhooks.length - 1]
- .webhook_id
- }`;
+ const from = `${
+ afterData.data.webhooks[afterData.data.webhooks.length - 1].webhook_id
+ }`;
if (from && updatePosition) updatePosition(from);
}
},
loadMorePrev: () => {
- return
+ return;
},
};
const webhooks = !afterData ? [] : (afterData || lastAfter).data.webhooks;
- if (loadingAfter)
- return { loading: true, data: { webhooks } };
+ if (loadingAfter) return { loading: true, data: { webhooks } };
if (afterData) {
return { ok: true, data: { webhooks }, ...pagination };
}
@@ -144,12 +149,15 @@ export function useInstanceWebhooks(
export function useWebhookDetails(
webhookId: string,
-): HttpResponse<MerchantBackend.Webhooks.WebhookDetails> {
+): HttpResponse<
+ MerchantBackend.Webhooks.WebhookDetails,
+ MerchantBackend.ErrorDetail
+> {
const { webhookFetcher } = useBackendInstanceRequest();
const { data, error, isValidating } = useSWR<
HttpResponseOk<MerchantBackend.Webhooks.WebhookDetails>,
- HttpError
+ HttpError<MerchantBackend.ErrorDetail>
>([`/private/webhooks/${webhookId}`], webhookFetcher, {
refreshInterval: 0,
refreshWhenHidden: false,