forked from deriv-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adrienne/feat: added use-get-status-account hook (deriv-com#9808)
* 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
1 parent
b3e6eec
commit 04eebe8
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |