From 5f8e332fadf91b95bcbd8dab15211d56a335cb5a Mon Sep 17 00:00:00 2001 From: Jim Daniels Wasswa Date: Thu, 25 Apr 2024 17:34:34 +0800 Subject: [PATCH] refactor: move all p2p mutations to mutations folder and refactor them to use the use-mutation hook --- src/api/authorize/index.tsx | 8 -------- src/api/authorize/use-p2p-advertiser-create.tsx | 13 ------------- .../use-p2p-advertiser-payment-methods.tsx | 13 ------------- src/api/authorize/use-p2p-advertiser-relations.tsx | 13 ------------- src/api/authorize/use-p2p-order-review.tsx | 11 ----------- src/api/mutation/index.tsx | 8 ++++++++ src/api/mutation/use-p2p-advertiser-create.tsx | 13 +++++++++++++ .../mutation/use-p2p-advertiser-payment-methods.tsx | 13 +++++++++++++ src/api/mutation/use-p2p-advertiser-relations.tsx | 13 +++++++++++++ src/api/mutation/use-p2p-order-review.tsx | 11 +++++++++++ 10 files changed, 58 insertions(+), 58 deletions(-) delete mode 100644 src/api/authorize/use-p2p-advertiser-create.tsx delete mode 100644 src/api/authorize/use-p2p-advertiser-payment-methods.tsx delete mode 100644 src/api/authorize/use-p2p-advertiser-relations.tsx delete mode 100644 src/api/authorize/use-p2p-order-review.tsx create mode 100644 src/api/mutation/use-p2p-advertiser-create.tsx create mode 100644 src/api/mutation/use-p2p-advertiser-payment-methods.tsx create mode 100644 src/api/mutation/use-p2p-advertiser-relations.tsx create mode 100644 src/api/mutation/use-p2p-order-review.tsx diff --git a/src/api/authorize/index.tsx b/src/api/authorize/index.tsx index 702cfde..692d31c 100644 --- a/src/api/authorize/index.tsx +++ b/src/api/authorize/index.tsx @@ -24,12 +24,8 @@ import { useOauthApps } from './use-oauth-apps'; import { useP2PAdvertList } from './use-p2p-advert-list'; import { useP2PAdvertiserAdverts } from './use-p2p-advertiser-adverts'; import { useP2PAdvertInfo } from './use-p2p-advert-info'; -import { useP2PAdvertiserCreate } from './use-p2p-advertiser-create'; import { useP2pAdvertiserList } from './use-p2p-advertiser-list'; -import { useP2pAdvertiserPaymentMethods } from './use-p2p-advertiser-payment-methods'; -import { useP2pAdvertiserRelations } from './use-p2p-advertiser-relations'; import { useP2PCountryList } from './use-p2p-country-list'; -import { useP2pOrderReview } from './use-p2p-order-review'; import { useP2pPaymentMethods } from './use-p2p-payment-methods'; import { useP2pPing } from './use-p2p-ping'; import { usePasskeysList } from './use-passkeys-list'; @@ -73,13 +69,9 @@ export { useOauthApps, useP2PAdvertInfo, useP2PAdvertiserAdverts, - useP2PAdvertiserCreate, useP2PAdvertList, useP2pAdvertiserList, - useP2pAdvertiserPaymentMethods, - useP2pAdvertiserRelations, useP2PCountryList, - useP2pOrderReview, useP2pPaymentMethods, useP2pPing, usePasskeysList, diff --git a/src/api/authorize/use-p2p-advertiser-create.tsx b/src/api/authorize/use-p2p-advertiser-create.tsx deleted file mode 100644 index 0247974..0000000 --- a/src/api/authorize/use-p2p-advertiser-create.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { useAuthorizeQuery } from '../../base'; -import { TSocketQueryOptions } from '../../base/use-query'; - -export const useP2PAdvertiserCreate = ({ - ...props -}: Omit, 'name'> = {}) => { - const { data, ...rest } = useAuthorizeQuery({ name: 'p2p_advertiser_create', ...props }); - - return { - data: data?.p2p_advertiser_create, - ...rest, - }; -}; diff --git a/src/api/authorize/use-p2p-advertiser-payment-methods.tsx b/src/api/authorize/use-p2p-advertiser-payment-methods.tsx deleted file mode 100644 index abeb530..0000000 --- a/src/api/authorize/use-p2p-advertiser-payment-methods.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { useAuthorizeQuery } from '../../base'; -import { TSocketQueryOptions } from '../../base/use-query'; - -export const useP2pAdvertiserPaymentMethods = ({ - ...props -}: Omit, 'name'> = {}) => { - const { data, ...rest } = useAuthorizeQuery({ name: 'p2p_advertiser_payment_methods', ...props }); - - return { - data: data?.p2p_advertiser_payment_methods, - ...rest, - }; -}; diff --git a/src/api/authorize/use-p2p-advertiser-relations.tsx b/src/api/authorize/use-p2p-advertiser-relations.tsx deleted file mode 100644 index 4a06d24..0000000 --- a/src/api/authorize/use-p2p-advertiser-relations.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { useAuthorizeQuery } from '../../base'; -import { TSocketQueryOptions } from '../../base/use-query'; - -export const useP2pAdvertiserRelations = ({ - ...props -}: Omit, 'name'> = {}) => { - const { data, ...rest } = useAuthorizeQuery({ name: 'p2p_advertiser_relations', ...props }); - - return { - data: data?.p2p_advertiser_relations, - ...rest, - }; -}; diff --git a/src/api/authorize/use-p2p-order-review.tsx b/src/api/authorize/use-p2p-order-review.tsx deleted file mode 100644 index 87fe567..0000000 --- a/src/api/authorize/use-p2p-order-review.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { useAuthorizeQuery } from '../../base'; -import { TSocketQueryOptions } from '../../base/use-query'; - -export const useP2pOrderReview = ({ ...props }: Omit, 'name'> = {}) => { - const { data, ...rest } = useAuthorizeQuery({ name: 'p2p_order_review', ...props }); - - return { - data: data?.p2p_order_review, - ...rest, - }; -}; diff --git a/src/api/mutation/index.tsx b/src/api/mutation/index.tsx index b23ad67..651062d 100644 --- a/src/api/mutation/index.tsx +++ b/src/api/mutation/index.tsx @@ -42,6 +42,10 @@ import { useP2pOrderCancel } from './use-p2p-order-cancel'; import { useP2pOrderConfirm } from './use-p2p-order-confirm'; import { useP2pOrderDispute } from './use-p2p-order-dispute'; import { useP2POrderCreate } from './use-p2p-order-create'; +import { useP2PAdvertiserCreate } from './use-p2p-advertiser-create'; +import { useP2PAdvertiserPaymentMethods } from './use-p2p-advertiser-payment-methods'; +import { useP2PAdvertiserRelations } from './use-p2p-advertiser-relations'; +import { useP2POrderReview } from './use-p2p-order-review'; import { usePasskeysLogin } from './use-passkeys-login'; import { usePasskeysRegister } from './use-passkeys-register'; import { usePasskeysRename } from './use-passkeys-rename'; @@ -115,6 +119,10 @@ export { useP2pOrderConfirm, useP2pOrderDispute, useP2POrderCreate, + useP2PAdvertiserCreate, + useP2PAdvertiserPaymentMethods, + useP2PAdvertiserRelations, + useP2POrderReview, usePasskeysLogin, usePasskeysRegister, usePasskeysRename, diff --git a/src/api/mutation/use-p2p-advertiser-create.tsx b/src/api/mutation/use-p2p-advertiser-create.tsx new file mode 100644 index 0000000..b3d822d --- /dev/null +++ b/src/api/mutation/use-p2p-advertiser-create.tsx @@ -0,0 +1,13 @@ +import { useMutation } from '../../base'; +import { AugmentedMutationOptions } from '../../base/use-mutation'; + +export const useP2PAdvertiserCreate = ({ + ...props +}: Omit, 'name'> = {}) => { + const { data, ...rest } = useMutation({ name: 'p2p_advertiser_create', ...props }); + + return { + data: data?.p2p_advertiser_create, + ...rest, + }; +}; diff --git a/src/api/mutation/use-p2p-advertiser-payment-methods.tsx b/src/api/mutation/use-p2p-advertiser-payment-methods.tsx new file mode 100644 index 0000000..a5bdc79 --- /dev/null +++ b/src/api/mutation/use-p2p-advertiser-payment-methods.tsx @@ -0,0 +1,13 @@ +import { useMutation } from '../../base'; +import { AugmentedMutationOptions } from '../../base/use-mutation'; + +export const useP2PAdvertiserPaymentMethods = ({ + ...props +}: Omit, 'name'> = {}) => { + const { data, ...rest } = useMutation({ name: 'p2p_advertiser_payment_methods', ...props }); + + return { + data: data?.p2p_advertiser_payment_methods, + ...rest, + }; +}; diff --git a/src/api/mutation/use-p2p-advertiser-relations.tsx b/src/api/mutation/use-p2p-advertiser-relations.tsx new file mode 100644 index 0000000..2da50d1 --- /dev/null +++ b/src/api/mutation/use-p2p-advertiser-relations.tsx @@ -0,0 +1,13 @@ +import { useMutation } from '../../base'; +import { AugmentedMutationOptions } from '../../base/use-mutation'; + +export const useP2PAdvertiserRelations = ({ + ...props +}: Omit, 'name'> = {}) => { + const { data, ...rest } = useMutation({ name: 'p2p_advertiser_relations', ...props }); + + return { + data: data?.p2p_advertiser_relations, + ...rest, + }; +}; diff --git a/src/api/mutation/use-p2p-order-review.tsx b/src/api/mutation/use-p2p-order-review.tsx new file mode 100644 index 0000000..aebcab7 --- /dev/null +++ b/src/api/mutation/use-p2p-order-review.tsx @@ -0,0 +1,11 @@ +import { useMutation } from '../../base'; +import { AugmentedMutationOptions } from '../../base/use-mutation'; + +export const useP2POrderReview = ({ ...props }: Omit, 'name'> = {}) => { + const { data, ...rest } = useMutation({ name: 'p2p_order_review', ...props }); + + return { + data: data?.p2p_order_review, + ...rest, + }; +};