From 56ab1691483a6463795904b4747f18e6293c465a Mon Sep 17 00:00:00 2001 From: Farrah Mae Ochoa Date: Wed, 16 Oct 2024 08:56:03 +0400 Subject: [PATCH] chore: added notification hooks --- src/api/mutation/index.tsx | 2 + .../use-notifications-update-status.tsx | 11 ++ src/api/subscription/index.ts | 3 +- .../subscription/use-notifications-list.tsx | 9 ++ src/types/api.types.ts | 151 +++++++++--------- 5 files changed, 103 insertions(+), 73 deletions(-) create mode 100644 src/api/mutation/use-notifications-update-status.tsx create mode 100644 src/api/subscription/use-notifications-list.tsx diff --git a/src/api/mutation/index.tsx b/src/api/mutation/index.tsx index 24fc26f..9ba45c9 100644 --- a/src/api/mutation/index.tsx +++ b/src/api/mutation/index.tsx @@ -35,6 +35,7 @@ import { useNewAccountReal } from './use-new-account-real'; import { useNewAccountVirtual } from './use-new-account-virtual'; import { useNewAccountWallet } from './use-new-account-wallet'; import { useNotificationEvent } from './use-notification-event'; +import { useNotificationsUpdateStatus } from './use-notifications-update-status'; import { useP2pAdvertCreate } from './use-p2p-advert-create'; import { useP2pAdvertUpdate } from './use-p2p-advert-update'; import { useP2pAdvertiserUpdate } from './use-p2p-advertiser-update'; @@ -115,6 +116,7 @@ export { useNewAccountVirtual, useNewAccountWallet, useNotificationEvent, + useNotificationsUpdateStatus, useP2pAdvertCreate, useP2pAdvertUpdate, useP2pAdvertiserUpdate, diff --git a/src/api/mutation/use-notifications-update-status.tsx b/src/api/mutation/use-notifications-update-status.tsx new file mode 100644 index 0000000..f41161d --- /dev/null +++ b/src/api/mutation/use-notifications-update-status.tsx @@ -0,0 +1,11 @@ +import { useMutation } from '../../base'; +import { AugmentedMutationOptions } from '../../base/use-mutation'; + +export const useNotificationsUpdateStatus = ({ ...props }: Omit, 'name'> = {}) => { + const { data, ...rest } = useMutation({ name: 'notifications_update_status', ...props }); + + return { + data: data?.notifications_update_status, + ...rest, + }; +}; diff --git a/src/api/subscription/index.ts b/src/api/subscription/index.ts index 6412d01..49c9fab 100644 --- a/src/api/subscription/index.ts +++ b/src/api/subscription/index.ts @@ -1,7 +1,8 @@ +import { useNotificationsList } from './use-notifications-list'; import { useP2PAdvertiserInfo } from './use-p2p-advertiser-info'; import { useP2PSettings } from './use-p2p-settings'; import { useP2POrderList } from './use-p2p-order-list'; import { useP2POrderInfo } from './use-p2p-order-info'; import { useExchangeRates } from './use-exchange-rates'; -export { useExchangeRates, useP2PAdvertiserInfo, useP2PSettings, useP2POrderList, useP2POrderInfo }; +export { useNotificationsList, useExchangeRates, useP2PAdvertiserInfo, useP2PSettings, useP2POrderList, useP2POrderInfo }; diff --git a/src/api/subscription/use-notifications-list.tsx b/src/api/subscription/use-notifications-list.tsx new file mode 100644 index 0000000..8b21472 --- /dev/null +++ b/src/api/subscription/use-notifications-list.tsx @@ -0,0 +1,9 @@ +import { useAuthorizedSubscription } from '../../base'; + +export const useNotificationsList = () => { + const { data, ...rest } = useAuthorizedSubscription('notifications_list'); + return { + data: data?.notifications_list, + ...rest, + }; +}; diff --git a/src/types/api.types.ts b/src/types/api.types.ts index 7fe4514..726422b 100644 --- a/src/types/api.types.ts +++ b/src/types/api.types.ts @@ -101,6 +101,8 @@ import type { NewRealMoneyAccountDerivInvestmentEuropeLtdResponse, NewVirtualMoneyAccountRequest, NewVirtualMoneyAccountResponse, + NotificationsListRequest, + NotificationsListResponse, OAuthApplicationsRequest, OAuthApplicationsResponse, P2PAdvertCreateRequest, @@ -496,64 +498,64 @@ export type TPrivateSocketEndpoints = { * Available Trading Accounts */ trading_platform_available_accounts?: - | { - /** - * A list of Deriv landing companies that can work with this account type - */ - linkable_landing_companies?: ('svg' | 'maltainvest')[]; - /** - * The type of market tradable by this account - */ - market_type?: 'financial' | 'gaming' | 'all'; - /** - * Landing Company legal name - */ - name?: string; - /** - * Legal requirements for the Landing Company - */ - requirements?: { - /** - * After first deposit requirements - */ - after_first_deposit?: { - /** - * Financial assessment requirements - */ - financial_assessment?: string[]; - }; - /** - * Compliance requirements - */ - compliance?: { - /** - * Compliance MT5 requirements - */ - mt5?: string[]; - /** - * Compliance tax information requirements - */ - tax_information?: string[]; - }; - /** - * Sign up requirements - */ - signup?: string[]; - /** - * Withdrawal requirements - */ - withdrawal?: string[]; - }; - /** - * Landing Company short code - */ - shortcode?: string; - /** - * Sub account type - */ - sub_account_type?: 'standard' | 'swap_free' | 'stp'; - }[] - | null; + | { + /** + * A list of Deriv landing companies that can work with this account type + */ + linkable_landing_companies?: ('svg' | 'maltainvest')[]; + /** + * The type of market tradable by this account + */ + market_type?: 'financial' | 'gaming' | 'all'; + /** + * Landing Company legal name + */ + name?: string; + /** + * Legal requirements for the Landing Company + */ + requirements?: { + /** + * After first deposit requirements + */ + after_first_deposit?: { + /** + * Financial assessment requirements + */ + financial_assessment?: string[]; + }; + /** + * Compliance requirements + */ + compliance?: { + /** + * Compliance MT5 requirements + */ + mt5?: string[]; + /** + * Compliance tax information requirements + */ + tax_information?: string[]; + }; + /** + * Sign up requirements + */ + signup?: string[]; + /** + * Withdrawal requirements + */ + withdrawal?: string[]; + }; + /** + * Landing Company short code + */ + shortcode?: string; + /** + * Sub account type + */ + sub_account_type?: 'standard' | 'swap_free' | 'stp'; + }[] + | null; /** * Echo of the request made. */ @@ -880,14 +882,14 @@ export type TPrivateSocketEndpoints = { }; response: { trading_platform_deposit?: - | { - /** - * The reference number for the related deposit to the trading account - */ - transaction_id?: number; - [k: string]: unknown; - } - | 1; + | { + /** + * The reference number for the related deposit to the trading account + */ + transaction_id?: number; + [k: string]: unknown; + } + | 1; }; /** * Echo of the request made. @@ -1218,6 +1220,10 @@ type TSocketEndpoints = { request: NewVirtualMoneyAccountRequest; response: NewVirtualMoneyAccountResponse; }; + notifications_list: { + request: NotificationsListRequest; + response: NotificationsListResponse; + }; oauth_apps: { request: OAuthApplicationsRequest; response: OAuthApplicationsResponse; @@ -1489,6 +1495,7 @@ export type TSocketSubscribableEndpointNames = Extract< | 'cashier_payments' | 'crypto_estimations' | 'exchange_rates' + | 'notifications_list' | 'p2p_advert_info' | 'p2p_advertiser_create' | 'p2p_advertiser_info' @@ -1564,12 +1571,12 @@ export type TSocketRequestPayload< T extends TSocketEndpointNames | TSocketPaginateableEndpointNames = TSocketEndpointNames, > = Partial> extends TSocketRequestCleaned - ? T extends TSocketPaginateableEndpointNames - ? TSocketPaginatateableRequestCleaned - : TSocketRequestCleaned - : T extends TSocketPaginateableEndpointNames - ? TSocketPaginatateableRequestCleaned - : TSocketRequestCleaned; + ? T extends TSocketPaginateableEndpointNames + ? TSocketPaginatateableRequestCleaned + : TSocketRequestCleaned + : T extends TSocketPaginateableEndpointNames + ? TSocketPaginatateableRequestCleaned + : TSocketRequestCleaned; export type TSocketPaginateableEndpointNames = KeysMatching< TSocketEndpoints,