diff options
author | Sebastian <sebasjm@gmail.com> | 2023-09-04 14:17:55 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-09-04 14:17:55 -0300 |
commit | e1d86816a7c07cb8ca2d54676d5cdbbe513f2ba7 (patch) | |
tree | d4ed5506ab3550a7e9b1a082d7ffeddf9f3c4954 /packages/merchant-backoffice-ui/src/hooks/reserves.ts | |
parent | ff20c3e25e076c24f7cb93eabe58b6f934f51f35 (diff) | |
download | wallet-core-e1d86816a7c07cb8ca2d54676d5cdbbe513f2ba7.tar.xz |
backoffcie new version, lot of changes
Diffstat (limited to 'packages/merchant-backoffice-ui/src/hooks/reserves.ts')
-rw-r--r-- | packages/merchant-backoffice-ui/src/hooks/reserves.ts | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/reserves.ts b/packages/merchant-backoffice-ui/src/hooks/reserves.ts index bb55b2474..b719bfbe6 100644 --- a/packages/merchant-backoffice-ui/src/hooks/reserves.ts +++ b/packages/merchant-backoffice-ui/src/hooks/reserves.ts @@ -31,11 +31,11 @@ export function useReservesAPI(): ReserveMutateAPI { const { request } = useBackendInstanceRequest(); const createReserve = async ( - data: MerchantBackend.Tips.ReserveCreateRequest, + data: MerchantBackend.Rewards.ReserveCreateRequest, ): Promise< - HttpResponseOk<MerchantBackend.Tips.ReserveCreateConfirmation> + HttpResponseOk<MerchantBackend.Rewards.ReserveCreateConfirmation> > => { - const res = await request<MerchantBackend.Tips.ReserveCreateConfirmation>( + const res = await request<MerchantBackend.Rewards.ReserveCreateConfirmation>( `/private/reserves`, { method: "POST", @@ -49,12 +49,12 @@ export function useReservesAPI(): ReserveMutateAPI { return res; }; - const authorizeTipReserve = async ( + const authorizeRewardReserve = async ( pub: string, - data: MerchantBackend.Tips.TipCreateRequest, - ): Promise<HttpResponseOk<MerchantBackend.Tips.TipCreateConfirmation>> => { - const res = await request<MerchantBackend.Tips.TipCreateConfirmation>( - `/private/reserves/${pub}/authorize-tip`, + data: MerchantBackend.Rewards.RewardCreateRequest, + ): Promise<HttpResponseOk<MerchantBackend.Rewards.RewardCreateConfirmation>> => { + const res = await request<MerchantBackend.Rewards.RewardCreateConfirmation>( + `/private/reserves/${pub}/authorize-reward`, { method: "POST", data, @@ -67,11 +67,11 @@ export function useReservesAPI(): ReserveMutateAPI { return res; }; - const authorizeTip = async ( - data: MerchantBackend.Tips.TipCreateRequest, - ): Promise<HttpResponseOk<MerchantBackend.Tips.TipCreateConfirmation>> => { - const res = await request<MerchantBackend.Tips.TipCreateConfirmation>( - `/private/tips`, + const authorizeReward = async ( + data: MerchantBackend.Rewards.RewardCreateRequest, + ): Promise<HttpResponseOk<MerchantBackend.Rewards.RewardCreateConfirmation>> => { + const res = await request<MerchantBackend.Rewards.RewardCreateConfirmation>( + `/private/rewards`, { method: "POST", data, @@ -97,33 +97,33 @@ export function useReservesAPI(): ReserveMutateAPI { return res; }; - return { createReserve, authorizeTip, authorizeTipReserve, deleteReserve }; + return { createReserve, authorizeReward, authorizeRewardReserve, deleteReserve }; } export interface ReserveMutateAPI { createReserve: ( - data: MerchantBackend.Tips.ReserveCreateRequest, - ) => Promise<HttpResponseOk<MerchantBackend.Tips.ReserveCreateConfirmation>>; - authorizeTipReserve: ( + data: MerchantBackend.Rewards.ReserveCreateRequest, + ) => Promise<HttpResponseOk<MerchantBackend.Rewards.ReserveCreateConfirmation>>; + authorizeRewardReserve: ( id: string, - data: MerchantBackend.Tips.TipCreateRequest, - ) => Promise<HttpResponseOk<MerchantBackend.Tips.TipCreateConfirmation>>; - authorizeTip: ( - data: MerchantBackend.Tips.TipCreateRequest, - ) => Promise<HttpResponseOk<MerchantBackend.Tips.TipCreateConfirmation>>; + data: MerchantBackend.Rewards.RewardCreateRequest, + ) => Promise<HttpResponseOk<MerchantBackend.Rewards.RewardCreateConfirmation>>; + authorizeReward: ( + data: MerchantBackend.Rewards.RewardCreateRequest, + ) => Promise<HttpResponseOk<MerchantBackend.Rewards.RewardCreateConfirmation>>; deleteReserve: ( id: string, ) => Promise<HttpResponse<void, MerchantBackend.ErrorDetail>>; } export function useInstanceReserves(): HttpResponse< - MerchantBackend.Tips.TippingReserveStatus, + MerchantBackend.Rewards.RewardReserveStatus, MerchantBackend.ErrorDetail > { const { fetcher } = useBackendInstanceRequest(); const { data, error, isValidating } = useSWR< - HttpResponseOk<MerchantBackend.Tips.TippingReserveStatus>, + HttpResponseOk<MerchantBackend.Rewards.RewardReserveStatus>, RequestError<MerchantBackend.ErrorDetail> >([`/private/reserves`], fetcher); @@ -136,13 +136,13 @@ export function useInstanceReserves(): HttpResponse< export function useReserveDetails( reserveId: string, ): HttpResponse< - MerchantBackend.Tips.ReserveDetail, + MerchantBackend.Rewards.ReserveDetail, MerchantBackend.ErrorDetail > { const { reserveDetailFetcher } = useBackendInstanceRequest(); const { data, error, isValidating } = useSWR< - HttpResponseOk<MerchantBackend.Tips.ReserveDetail>, + HttpResponseOk<MerchantBackend.Rewards.ReserveDetail>, RequestError<MerchantBackend.ErrorDetail> >([`/private/reserves/${reserveId}`], reserveDetailFetcher, { refreshInterval: 0, @@ -158,15 +158,15 @@ export function useReserveDetails( return { loading: true }; } -export function useTipDetails( - tipId: string, -): HttpResponse<MerchantBackend.Tips.TipDetails, MerchantBackend.ErrorDetail> { - const { tipsDetailFetcher } = useBackendInstanceRequest(); +export function useRewardDetails( + rewardId: string, +): HttpResponse<MerchantBackend.Rewards.RewardDetails, MerchantBackend.ErrorDetail> { + const { rewardsDetailFetcher } = useBackendInstanceRequest(); const { data, error, isValidating } = useSWR< - HttpResponseOk<MerchantBackend.Tips.TipDetails>, + HttpResponseOk<MerchantBackend.Rewards.RewardDetails>, RequestError<MerchantBackend.ErrorDetail> - >([`/private/tips/${tipId}`], tipsDetailFetcher, { + >([`/private/rewards/${rewardId}`], rewardsDetailFetcher, { refreshInterval: 0, refreshWhenHidden: false, revalidateOnFocus: false, |