-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into test-coverage-dbot
- Loading branch information
Showing
138 changed files
with
1,855 additions
and
594 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
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
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 |
---|---|---|
@@ -1,8 +1,16 @@ | ||
export { default as useAccountsList } from './useAccountsList'; | ||
export { default as useActiveWalletAccounts } from './useActiveWalletAccounts'; | ||
export { default as useActiveAccount } from './useActiveAccount'; | ||
export { default as useActiveTradingAccount } from './useActiveTradingAccount'; | ||
export { default as useActiveWalletAccount } from './useActiveWalletAccount'; | ||
export { default as useAllAvailableAccounts } from './useAllAvailableAccounts'; | ||
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'; | ||
export { default as useTradingAccountsList } from './useTradingAccountsList'; | ||
export { default as useTradingPlatformAccounts } from './useTradingPlatformAccounts'; | ||
export { default as useTradingPlatformAvailableAccounts } from './useTradingPlatformAvailableAccounts'; | ||
export { default as useWalletAccountsList } from './useWalletAccountsList'; |
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,31 @@ | ||
import { useMemo } from 'react'; | ||
import useFetch from '../useFetch'; | ||
|
||
/** | ||
* A custom hook to get available account types for a specific landing company. | ||
*/ | ||
const useAccountTypes = (landing_company?: string) => { | ||
const { data, ...rest } = useFetch('get_account_types', { | ||
payload: { company: landing_company }, | ||
options: { enabled: Boolean(landing_company) }, | ||
}); | ||
|
||
// Add additional information to the account types response. | ||
const modified_account_types = useMemo(() => { | ||
if (!data?.get_account_types) return; | ||
|
||
return { | ||
...data.get_account_types, | ||
/** Landing company for the account types */ | ||
landing_company, | ||
}; | ||
}, [data?.get_account_types, landing_company]); | ||
|
||
return { | ||
/** The account types response. */ | ||
data: modified_account_types, | ||
...rest, | ||
}; | ||
}; | ||
|
||
export default useAccountTypes; |
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,16 @@ | ||
import { useMemo } from 'react'; | ||
import useAccountsList from './useAccountsList'; | ||
|
||
/** A custom hook that returns the account object for the current active account. */ | ||
const useActiveAccount = () => { | ||
const { data, ...rest } = useAccountsList(); | ||
const active_account = useMemo(() => data?.find(account => account.is_active), [data]); | ||
|
||
return { | ||
/** User's current active account. */ | ||
data: active_account, | ||
...rest, | ||
}; | ||
}; | ||
|
||
export default useActiveAccount; |
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,16 @@ | ||
import { useMemo } from 'react'; | ||
import useTradingAccountsList from './useTradingAccountsList'; | ||
|
||
/** A custom hook that returns the trading object for the current active trading. */ | ||
const useActiveTradingAccount = () => { | ||
const { data, ...rest } = useTradingAccountsList(); | ||
const active_trading = useMemo(() => data?.find(trading => trading.is_active), [data]); | ||
|
||
return { | ||
/** User's current active trading. */ | ||
data: active_trading, | ||
...rest, | ||
}; | ||
}; | ||
|
||
export default useActiveTradingAccount; |
File renamed without changes.
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,24 @@ | ||
import { useMemo } from 'react'; | ||
import useAccountTypes from './useAccountTypes'; | ||
import useLandingCompany from './useLandingCompany'; | ||
|
||
/** A custom hook to get all available accounts that user can have. */ | ||
const useAllAvailableAccounts = () => { | ||
const { data: landing_company_data } = useLandingCompany(); | ||
const { data: account_types_data, ...rest } = useAccountTypes(landing_company_data?.financial_company?.shortcode); | ||
|
||
// Add additional information to the account types response. | ||
const modified_account_types_data = useMemo(() => { | ||
if (!account_types_data) return; | ||
|
||
return { ...account_types_data }; | ||
}, [account_types_data]); | ||
|
||
return { | ||
/** The account types response. */ | ||
data: modified_account_types_data, | ||
...rest, | ||
}; | ||
}; | ||
|
||
export default useAllAvailableAccounts; |
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
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 custom hook to retrieves the account status for the current user. */ | ||
const useGetAccountStatus = () => { | ||
const { data: get_account_status_data, ...rest } = useFetch('get_account_status'); | ||
|
||
// Add additional information to the account status 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 { | ||
/** The account status response. */ | ||
data: modified_account_status, | ||
...rest, | ||
}; | ||
}; | ||
|
||
export default useGetAccountStatus; |
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,27 @@ | ||
import { useMemo } from 'react'; | ||
import useFetch from '../useFetch'; | ||
import useSettings from './useSettings'; | ||
|
||
/** A custom hook that returns the available landing companies of the user's country. */ | ||
const useLandingCompany = () => { | ||
const { data: settings_data } = useSettings(); | ||
const { data, ...rest } = useFetch('landing_company', { | ||
payload: { landing_company: settings_data?.country_code || '' }, | ||
options: { enabled: Boolean(settings_data?.country_code) }, | ||
}); | ||
|
||
// Add additional information to the landing company response. | ||
const modified_landing_company = useMemo(() => { | ||
if (!data?.landing_company) return; | ||
|
||
return { ...data.landing_company }; | ||
}, [data?.landing_company]); | ||
|
||
return { | ||
/** The landing company response. */ | ||
data: modified_landing_company, | ||
...rest, | ||
}; | ||
}; | ||
|
||
export default useLandingCompany; |
Oops, something went wrong.