diff options
Diffstat (limited to 'packages/merchant-backoffice-ui/src/hooks/backend.ts')
-rw-r--r-- | packages/merchant-backoffice-ui/src/hooks/backend.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/backend.ts b/packages/merchant-backoffice-ui/src/hooks/backend.ts index a0639a4a0..3f3db2fa1 100644 --- a/packages/merchant-backoffice-ui/src/hooks/backend.ts +++ b/packages/merchant-backoffice-ui/src/hooks/backend.ts @@ -115,6 +115,11 @@ interface useBackendInstanceRequestType { position?: string, delta?: number, ) => Promise<HttpResponseOk<T>>; + webhookFetcher: <T>( + path: string, + position?: string, + delta?: number, + ) => Promise<HttpResponseOk<T>>; } interface useBackendBaseRequestType { request: <T>( @@ -274,6 +279,23 @@ export function useBackendInstanceRequest(): useBackendInstanceRequestType { [backend, token], ); + const webhookFetcher = useCallback( + function webhookFetcherImpl<T>( + path: string, + position?: string, + delta?: number, + ): Promise<HttpResponseOk<T>> { + const params: any = {}; + if (delta !== undefined) { + params.limit = delta; + } + if (position !== undefined) params.offset = position; + + return requestHandler<T>(backend, path, { params, token }); + }, + [backend, token], + ); + return { request, fetcher, @@ -283,5 +305,6 @@ export function useBackendInstanceRequest(): useBackendInstanceRequestType { tipsDetailFetcher, transferFetcher, templateFetcher, + webhookFetcher, }; } |