Skip to content

Commit

Permalink
Merge branch 'master' of github.com:binary-com/deriv-app into hamza/u…
Browse files Browse the repository at this point in the history
…seTradingPlatformPasswordChange-hook-creation-and-changing-password
  • Loading branch information
hamza-deriv committed Sep 12, 2023
2 parents 4800d96 + 5888d4e commit d2df071
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/api/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export { default as useTradingAccountsList } from './useTradingAccountsList';
export { default as useTradingPlatformAccounts } from './useTradingPlatformAccounts';
export { default as useTradingPlatformAvailableAccounts } from './useTradingPlatformAvailableAccounts';
export { default as useWalletAccountsList } from './useWalletAccountsList';
export { default as useTradingPlatformInvestorPasswordChange } from './useTradingPlatformInvestorPasswordChange';
export { default as useCreateMT5Account } from './useCreateMT5Account';
export { default as useCreateOtherCFDAccount } from './useCreateOtherCFDAccount';
export { default as useTradingPlatformpasswordChange } from './useTradingPlatformpasswordChange';
22 changes: 22 additions & 0 deletions packages/api/src/hooks/useTradingPlatformInvestorPasswordChange.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useCallback } from 'react';
import useRequest from '../useRequest';

type TPayload = Parameters<
ReturnType<typeof useRequest<'trading_platform_investor_password_change'>>['mutate']
>[0]['payload'];

/** A custom hook that change the Trading Platform Investor Password. */
const useTradingPlatformInvestorPasswordChange = () => {
const { mutate: _mutate, ...rest } = useRequest('trading_platform_investor_password_change');

/** @param payload - The payload to be sent to the server */
const mutate = useCallback((payload: TPayload) => _mutate({ payload }), [_mutate]);

return {
/** The mutation function that accepts a payload and sends it to the server */
mutate,
...rest,
};
};

export default useTradingPlatformInvestorPasswordChange;
19 changes: 19 additions & 0 deletions packages/api/src/hooks/useVerifyEmail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useCallback } from 'react';
import { useRequest } from '@deriv/api';

type TPayload = Parameters<ReturnType<typeof useRequest<'verify_email'>>['mutate']>[0]['payload'];

/** A custom hook for verifying email address */
const useVerifyEmail = () => {
const { mutate: _mutate, ...rest } = useRequest('verify_email');

const mutate = useCallback((payload: TPayload) => _mutate({ payload }), [_mutate]);

return {
/** The mutation function that accepts a payload and sends it to the server */
mutate,
...rest,
};
};

export default useVerifyEmail;
52 changes: 52 additions & 0 deletions packages/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,58 @@ type TPrivateSocketEndpoints = {
[k: string]: unknown;
};
};
trading_platform_investor_password_change: {
request: {
/**
* Must be `1`
*/
trading_platform_investor_password_change: 1;
/**
* Trading account ID.
*/
account_id: string;
/**
* New investor password. Accepts any printable ASCII character. Must be within 8-25 characters, and include numbers, lowercase and uppercase letters. Must not be the same as the user's email address.
*/
new_password: string;
/**
* Old investor password for validation (non-empty string, accepts any printable ASCII character)
*/
old_password: string;
/**
* Name of trading platform.
*/
platform: 'mt5';
/**
* [Optional] Used to pass data through the websocket, which may be retrieved via the `echo_req` output field. Maximum size is 3500 bytes.
*/
passthrough?: {
[k: string]: unknown;
};
/**
* [Optional] Used to map request to response.
*/
req_id?: number;
};
response: {
trading_platform_password_change?: 0 | 1;
};
/**
* Echo of the request made.
*/
echo_req: {
[k: string]: unknown;
};
/**
* Action name of the request made.
*/
msg_type: 'trading_platform_investor_password_change';
/**
* Optional field sent in request to map to response, present only when request contains `req_id`.
*/
req_id?: number;
[k: string]: unknown;
};
};

type TSocketEndpoints = {
Expand Down
6 changes: 1 addition & 5 deletions packages/hooks/src/useCFDAllAccounts.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { useStore } from '@deriv/stores';

/**
* we can use this hook to get the CFD accounts for both Eu and Non-Eu regions.
* it gets dxtrade_accounts_list and mt5_login_list from store and merges them into one array
* and returns the array
*/
/** @deprecated Use `useMT5LoginList` for MT5 accounts and `useTradingPlatformAccounts` for Other CFD accounts from `@deriv/api` instead. */
const useCFDAllAccounts = () => {
const { client } = useStore();
const { dxtrade_accounts_list, mt5_login_list, derivez_accounts_list } = client;
Expand Down
3 changes: 3 additions & 0 deletions packages/hooks/src/useVerifyEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import useCountdown from './useCountdown';

const RESEND_COUNTDOWN = 60;

/**
* @deprecated Please use useVerifyEmail from @deriv/api instead
*/
const useVerifyEmail = (
type: Parameters<ReturnType<typeof useRequest<'verify_email'>>['mutate']>[0]['payload']['type']
) => {
Expand Down

0 comments on commit d2df071

Please sign in to comment.