summaryrefslogtreecommitdiff
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.ts31
1 files changed, 16 insertions, 15 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/webhooks.ts b/packages/merchant-backoffice-ui/src/hooks/webhooks.ts
index 994bfdbb0..4e62a81c9 100644
--- a/packages/merchant-backoffice-ui/src/hooks/webhooks.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/webhooks.ts
@@ -20,11 +20,11 @@ import {
RequestError,
} from "@gnu-taler/web-util/browser";
import { useEffect, useState } from "preact/hooks";
-import { MerchantBackend } from "../declaration.js";
import { MAX_RESULT_SIZE, PAGE_SIZE } from "../utils/constants.js";
import { useBackendInstanceRequest, useMatchMutate } from "./backend.js";
// FIX default import https://github.com/microsoft/TypeScript/issues/49189
+import { TalerErrorDetail, TalerMerchantApi } from "@gnu-taler/taler-util";
import _useSWR, { SWRHook } from "swr";
const useSWR = _useSWR as unknown as SWRHook;
@@ -33,7 +33,7 @@ export function useWebhookAPI(): WebhookAPI {
const { request } = useBackendInstanceRequest();
const createWebhook = async (
- data: MerchantBackend.Webhooks.WebhookAddDetails,
+ data: TalerMerchantApi.WebhookAddDetails,
): Promise<HttpResponseOk<void>> => {
const res = await request<void>(`/private/webhooks`, {
method: "POST",
@@ -45,7 +45,7 @@ export function useWebhookAPI(): WebhookAPI {
const updateWebhook = async (
webhookId: string,
- data: MerchantBackend.Webhooks.WebhookPatchDetails,
+ data: TalerMerchantApi.WebhookPatchDetails,
): Promise<HttpResponseOk<void>> => {
const res = await request<void>(`/private/webhooks/${webhookId}`, {
method: "PATCH",
@@ -70,11 +70,11 @@ export function useWebhookAPI(): WebhookAPI {
export interface WebhookAPI {
createWebhook: (
- data: MerchantBackend.Webhooks.WebhookAddDetails,
+ data: TalerMerchantApi.WebhookAddDetails,
) => Promise<HttpResponseOk<void>>;
updateWebhook: (
id: string,
- data: MerchantBackend.Webhooks.WebhookPatchDetails,
+ data: TalerMerchantApi.WebhookPatchDetails,
) => Promise<HttpResponseOk<void>>;
deleteWebhook: (id: string) => Promise<HttpResponseOk<void>>;
}
@@ -88,8 +88,8 @@ export function useInstanceWebhooks(
args?: InstanceWebhookFilter,
updatePosition?: (id: string) => void,
): HttpResponsePaginated<
- MerchantBackend.Webhooks.WebhookSummaryResponse,
- MerchantBackend.ErrorDetail
+ TalerMerchantApi.WebhookSummaryResponse,
+ TalerErrorDetail
> {
const { webhookFetcher } = useBackendInstanceRequest();
@@ -104,14 +104,15 @@ export function useInstanceWebhooks(
error: afterError,
isValidating: loadingAfter,
} = useSWR<
- HttpResponseOk<MerchantBackend.Webhooks.WebhookSummaryResponse>,
- RequestError<MerchantBackend.ErrorDetail>
+ HttpResponseOk<TalerMerchantApi.WebhookSummaryResponse>,
+ RequestError<TalerErrorDetail>
+
>([`/private/webhooks`, args?.position, -totalAfter], webhookFetcher);
const [lastAfter, setLastAfter] = useState<
HttpResponse<
- MerchantBackend.Webhooks.WebhookSummaryResponse,
- MerchantBackend.ErrorDetail
+ TalerMerchantApi.WebhookSummaryResponse,
+ TalerErrorDetail
>
>({ loading: true });
useEffect(() => {
@@ -155,14 +156,14 @@ export function useInstanceWebhooks(
export function useWebhookDetails(
webhookId: string,
): HttpResponse<
- MerchantBackend.Webhooks.WebhookDetails,
- MerchantBackend.ErrorDetail
+ TalerMerchantApi.WebhookDetails,
+ TalerErrorDetail
> {
const { webhookFetcher } = useBackendInstanceRequest();
const { data, error, isValidating } = useSWR<
- HttpResponseOk<MerchantBackend.Webhooks.WebhookDetails>,
- RequestError<MerchantBackend.ErrorDetail>
+ HttpResponseOk<TalerMerchantApi.WebhookDetails>,
+ RequestError<TalerErrorDetail>
>([`/private/webhooks/${webhookId}`], webhookFetcher, {
refreshInterval: 0,
refreshWhenHidden: false,