Skip to content

Commit d1738a6

Browse files
[FEQ] / Ameerul / FEQ-1099 Advertiser Entity (#13036)
* feat: added advertiser entity * chore: removed old advertiser entity hooks from p2p hooks folder
1 parent c6bf6ec commit d1738a6

File tree

11 files changed

+24
-20
lines changed

11 files changed

+24
-20
lines changed

packages/api/src/hooks/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ export { default as useCancelCryptoTransaction } from './useCancelCryptoTransact
2121
export { default as useCashierFiatAddress } from './useCashierFiatAddress';
2222
// TODO: Export these into P2P entities
2323
export { default as useChatCreate } from './p2p/entity/chat/p2p-chat/useChatCreate';
24-
export { default as useAdvertiserInfo } from './p2p/useAdvertiserInfo';
25-
export { default as useAdvertiserUpdate } from './p2p/useAdvertiserUpdate';
2624
export { default as useOrderInfo } from './p2p/entity/order/p2p-order/useOrderInfo';
2725

2826
export { default as useCountryConfig } from './useCountryConfig';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * as advertiser from './p2p-advertiser';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export { default as useCreate } from './useAdvertiserCreate';
2+
export { default as useGetInfo } from './useAdvertiserInfo';
3+
export { default as useGetList } from './useAdvertiserList';
4+
export { default as useUpdate } from './useAdvertiserUpdate';

packages/api/src/hooks/p2p/useCreateAdvertiser.ts renamed to packages/api/src/hooks/p2p/entity/advertiser/p2p-advertiser/useAdvertiserCreate.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useCallback, useMemo } from 'react';
2-
import useMutation from '../../useMutation';
3-
import useInvalidateQuery from '../../useInvalidateQuery';
2+
import useMutation from '../../../../../useMutation';
3+
import useInvalidateQuery from '../../../../../useInvalidateQuery';
44

55
type TCreateAdvertisePayload = NonNullable<
66
Parameters<ReturnType<typeof useMutation<'p2p_advertiser_create'>>['mutate']>
@@ -17,7 +17,7 @@ type TCreateAdvertisePayload = NonNullable<
1717
});
1818
*
1919
*/
20-
const useCreateAdvertiser = () => {
20+
const useAdvertiserCreate = () => {
2121
const invalidate = useInvalidateQuery();
2222
const {
2323
data,
@@ -68,4 +68,4 @@ const useCreateAdvertiser = () => {
6868
};
6969
};
7070

71-
export default useCreateAdvertiser;
71+
export default useAdvertiserCreate;

packages/api/src/hooks/p2p/useAdvertiserInfo.ts renamed to packages/api/src/hooks/p2p/entity/advertiser/p2p-advertiser/useAdvertiserInfo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useMemo } from 'react';
2-
import useQuery from '../../useQuery';
3-
import useAuthorize from '../useAuthorize';
2+
import useQuery from '../../../../../useQuery';
3+
import useAuthorize from '../../../../useAuthorize';
44

55
/** This custom hook returns information about the given advertiser ID */
66
const useAdvertiserInfo = (id?: string) => {

packages/api/src/hooks/p2p/useAdvertiserList.ts renamed to packages/api/src/hooks/p2p/entity/advertiser/p2p-advertiser/useAdvertiserList.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
2-
import useInfiniteQuery from '../../useInfiniteQuery';
3-
import useAuthorize from '../useAuthorize';
2+
import useInfiniteQuery from '../../../../../useInfiniteQuery';
3+
import useAuthorize from '../../../../useAuthorize';
44

55
/**
66
* This custom hook returns the available advertisers who have had or currently have trades with the current advertiser.

packages/api/src/hooks/p2p/useAdvertiserUpdate.ts renamed to packages/api/src/hooks/p2p/entity/advertiser/p2p-advertiser/useAdvertiserUpdate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useCallback, useMemo } from 'react';
2-
import useMutation from '../../useMutation';
3-
import useInvalidateQuery from '../../useInvalidateQuery';
2+
import useMutation from '../../../../../useMutation';
3+
import useInvalidateQuery from '../../../../../useInvalidateQuery';
44

55
type TPayload = NonNullable<
66
Parameters<ReturnType<typeof useMutation<'p2p_advertiser_update'>>['mutate']>[0]

packages/api/src/hooks/p2p/entity/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './advert';
2+
export * from './advertiser';
23
export * from './counterparty';
34
export * from './order-dispute';
45
export * from './payment-method';

packages/p2p-v2/src/hooks/useAdvertiserStats.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { useMemo } from 'react';
2-
import { useAdvertiserInfo } from '@deriv/api';
2+
import { p2p } from '@deriv/api';
33

44
/**
55
* Hook to calculate an advertiser's stats based on their information.
66
*
77
* @param advertiserId - ID of the advertiser stats to reveal. If not provided, by default it will return the user's own stats.
88
*/
99
const useAdvertiserStats = (advertiserId?: string) => {
10-
const { data, isSuccess } = useAdvertiserInfo(advertiserId);
10+
const { data, isSuccess } = p2p.advertiser.useGetInfo(advertiserId);
1111

1212
const transformedData = useMemo(() => {
1313
if (!isSuccess) return;

packages/p2p-v2/src/hooks/useSendbird.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useCallback, useEffect, useRef, useState } from 'react';
2-
import { useAdvertiserInfo, useChatCreate, useOrderInfo, useSendbirdServiceToken, useServerTime } from '@deriv/api';
2+
import { p2p, useChatCreate, useOrderInfo, useSendbirdServiceToken, useServerTime } from '@deriv/api';
33
import SendbirdChat, { BaseChannel, User } from '@sendbird/chat';
44
import { GroupChannel, GroupChannelHandler, GroupChannelModule } from '@sendbird/chat/groupChannel';
55
import { BaseMessage, MessageType, MessageTypeFilter } from '@sendbird/chat/message';
@@ -86,7 +86,7 @@ const useSendbird = (orderId: string) => {
8686
isError: isErrorSendbirdServiceToken,
8787
isSuccess: isSuccessSendbirdServiceToken,
8888
} = useSendbirdServiceToken();
89-
const { data: advertiserInfo, isSuccess: isSuccessAdvertiserInfo } = useAdvertiserInfo();
89+
const { data: advertiserInfo, isSuccess: isSuccessAdvertiserInfo } = p2p.advertiser.useGetInfo();
9090
const { isError: isErrorChatCreate, mutate: createChat } = useChatCreate();
9191
const { data: orderInfo, isError: isErrorOrderInfo } = useOrderInfo(orderId);
9292
const { data: serverTime, isError: isErrorServerTime } = useServerTime();

packages/p2p-v2/src/pages/my-profile/screens/MyProfileAdDetails/MyProfileAdDetails.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React, { useEffect, useMemo, useState } from 'react';
2-
import { useAdvertiserInfo, useAdvertiserUpdate } from '@deriv/api';
2+
import { p2p } from '@deriv/api';
33
import { Button, FullPageMobileWrapper, TextArea } from '../../../../components';
44
import { useDevice } from '../../../../hooks';
55
import './MyProfileAdDetails.scss';
66

77
type TMYProfileAdDetailsTextAreaProps = {
8-
advertiserInfo: NonNullable<ReturnType<typeof useAdvertiserInfo>>['data'];
8+
advertiserInfo: NonNullable<ReturnType<typeof p2p.advertiser.useGetInfo>>['data'];
99
setAdvertDescription: React.Dispatch<React.SetStateAction<string>>;
1010
setContactInfo: React.Dispatch<React.SetStateAction<string>>;
1111
};
@@ -33,8 +33,8 @@ const MyProfileAdDetailsTextArea = ({
3333
};
3434

3535
const MyProfileAdDetails = () => {
36-
const { data: advertiserInfo, isLoading } = useAdvertiserInfo();
37-
const { mutate: updateAdvertiser } = useAdvertiserUpdate();
36+
const { data: advertiserInfo, isLoading } = p2p.advertiser.useGetInfo();
37+
const { mutate: updateAdvertiser } = p2p.advertiser.useUpdate();
3838
const [contactInfo, setContactInfo] = useState('');
3939
const [advertDescription, setAdvertDescription] = useState('');
4040
const { isMobile } = useDevice();

0 commit comments

Comments
 (0)