Skip to content

Commit

Permalink
adrienne/feat: added use-get-status-account hook (deriv-com#9808)
Browse files Browse the repository at this point in the history
* feat: added use-get-status-account hook

* chore: updated comments

* fix: make use-accounts-list dependent on use-get-account-status hook

* chore: incorporated review changes

* fix: fixed typescript issue in wallets
  • Loading branch information
adrienne-deriv authored Aug 28, 2023
1 parent b3e6eec commit 04eebe8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 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 @@ -3,6 +3,7 @@ export { default as useActiveWalletAccounts } from './useActiveWalletAccounts';
export { default as useAuthorize } from './useAuthorize';
export { default as useBalance } from './useBalance';
export { default as useCurrencyConfig } from './useCurrencyConfig';
export { default as useGetAccountStatus } from './useGetAccountStatus';
export { default as useLandingCompany } from './useLandingCompany';
export { default as useMT5LoginList } from './useMT5LoginList';
export { default as useSettings } from './useSettings';
Expand Down
28 changes: 28 additions & 0 deletions packages/api/src/hooks/useGetAccountStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useMemo } from 'react';
import useFetch from '../useFetch';

/** A hook that retrieves the account status */
const useGetAccountStatus = () => {
const { data: get_account_status_data, ...rest } = useFetch('get_account_status');

// Add additional information to the authorize response.
const modified_account_status = useMemo(() => {
if (!get_account_status_data?.get_account_status) return;

return {
...get_account_status_data.get_account_status,
/** Indicates whether the client should be prompted to authenticate their account. */
should_prompt_client_to_authenticate: Boolean(
get_account_status_data.get_account_status.prompt_client_to_authenticate
),
};
}, [get_account_status_data?.get_account_status]);

return {
/** Account status details. */
data: modified_account_status,
...rest,
};
};

export default useGetAccountStatus;

0 comments on commit 04eebe8

Please sign in to comment.