diff options
author | Sebastian <sebasjm@gmail.com> | 2024-03-29 16:52:25 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-03-29 16:52:40 -0300 |
commit | c3cba95a9fd88eb77fd18263287d3a63a9f757e2 (patch) | |
tree | 5d05bc48742c0984d8d0aff3a4c2a94c54332803 /packages/merchant-backoffice-ui/src/hooks/webhooks.ts | |
parent | 81f87ede72ada7e7f313b9a4212e0c75c5f54ac9 (diff) | |
download | wallet-core-c3cba95a9fd88eb77fd18263287d3a63a9f757e2.tar.xz |
wip #8655
Diffstat (limited to 'packages/merchant-backoffice-ui/src/hooks/webhooks.ts')
-rw-r--r-- | packages/merchant-backoffice-ui/src/hooks/webhooks.ts | 105 |
1 files changed, 52 insertions, 53 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/webhooks.ts b/packages/merchant-backoffice-ui/src/hooks/webhooks.ts index 4e62a81c9..cc817b84e 100644 --- a/packages/merchant-backoffice-ui/src/hooks/webhooks.ts +++ b/packages/merchant-backoffice-ui/src/hooks/webhooks.ts @@ -28,56 +28,56 @@ import { TalerErrorDetail, TalerMerchantApi } from "@gnu-taler/taler-util"; import _useSWR, { SWRHook } from "swr"; const useSWR = _useSWR as unknown as SWRHook; -export function useWebhookAPI(): WebhookAPI { - const mutateAll = useMatchMutate(); - const { request } = useBackendInstanceRequest(); - - const createWebhook = async ( - data: TalerMerchantApi.WebhookAddDetails, - ): Promise<HttpResponseOk<void>> => { - const res = await request<void>(`/private/webhooks`, { - method: "POST", - data, - }); - await mutateAll(/.*private\/webhooks.*/); - return res; - }; - - const updateWebhook = async ( - webhookId: string, - data: TalerMerchantApi.WebhookPatchDetails, - ): Promise<HttpResponseOk<void>> => { - const res = await request<void>(`/private/webhooks/${webhookId}`, { - method: "PATCH", - data, - }); - await mutateAll(/.*private\/webhooks.*/); - return res; - }; - - const deleteWebhook = async ( - webhookId: string, - ): Promise<HttpResponseOk<void>> => { - const res = await request<void>(`/private/webhooks/${webhookId}`, { - method: "DELETE", - }); - await mutateAll(/.*private\/webhooks.*/); - return res; - }; - - return { createWebhook, updateWebhook, deleteWebhook }; -} - -export interface WebhookAPI { - createWebhook: ( - data: TalerMerchantApi.WebhookAddDetails, - ) => Promise<HttpResponseOk<void>>; - updateWebhook: ( - id: string, - data: TalerMerchantApi.WebhookPatchDetails, - ) => Promise<HttpResponseOk<void>>; - deleteWebhook: (id: string) => Promise<HttpResponseOk<void>>; -} +// export function useWebhookAPI(): WebhookAPI { +// const mutateAll = useMatchMutate(); +// const { request } = useBackendInstanceRequest(); + +// const createWebhook = async ( +// data: TalerMerchantApi.WebhookAddDetails, +// ): Promise<HttpResponseOk<void>> => { +// const res = await request<void>(`/private/webhooks`, { +// method: "POST", +// data, +// }); +// await mutateAll(/.*private\/webhooks.*/); +// return res; +// }; + +// const updateWebhook = async ( +// webhookId: string, +// data: TalerMerchantApi.WebhookPatchDetails, +// ): Promise<HttpResponseOk<void>> => { +// const res = await request<void>(`/private/webhooks/${webhookId}`, { +// method: "PATCH", +// data, +// }); +// await mutateAll(/.*private\/webhooks.*/); +// return res; +// }; + +// const deleteWebhook = async ( +// webhookId: string, +// ): Promise<HttpResponseOk<void>> => { +// const res = await request<void>(`/private/webhooks/${webhookId}`, { +// method: "DELETE", +// }); +// await mutateAll(/.*private\/webhooks.*/); +// return res; +// }; + +// return { createWebhook, updateWebhook, deleteWebhook }; +// } + +// export interface WebhookAPI { +// createWebhook: ( +// data: TalerMerchantApi.WebhookAddDetails, +// ) => Promise<HttpResponseOk<void>>; +// updateWebhook: ( +// id: string, +// data: TalerMerchantApi.WebhookPatchDetails, +// ) => Promise<HttpResponseOk<void>>; +// deleteWebhook: (id: string) => Promise<HttpResponseOk<void>>; +// } export interface InstanceWebhookFilter { //FIXME: add filter to the webhook list @@ -133,9 +133,8 @@ 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); } }, |