forked from binary-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.
Merge branch 'master' of github.com:binary-com/deriv-app into P2PS-67…
…5-share-my-posted-ads
- Loading branch information
Showing
27 changed files
with
1,124 additions
and
743 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,37 @@ | ||
import { useMemo } from 'react'; | ||
import useActiveWalletAccounts from './useActiveWalletAccounts'; | ||
import useFetch from '../useFetch'; | ||
|
||
/** A custom hook that gets the list created MT5 accounts of the user. */ | ||
const useMT5LoginList = () => { | ||
const { data: wallet } = useActiveWalletAccounts(); | ||
|
||
const { data: mt5_accounts, ...mt5_accounts_rest } = useFetch('mt5_login_list'); | ||
|
||
/** | ||
* @description The list of created MT5 accounts | ||
*/ | ||
const modified_mt5_accounts = useMemo(() => { | ||
/** Adding the neccesary properties to the response */ | ||
const getAccountInfo = (login?: string) => { | ||
return { | ||
platform: wallet?.linked_to?.find(linked => linked.loginid === login)?.platform, | ||
display_login: login?.replace(/^(MT[DR]?)/, ''), | ||
}; | ||
}; | ||
|
||
return mt5_accounts?.mt5_login_list?.map(account => ({ | ||
...account, | ||
...getAccountInfo(account.login), | ||
loginid: account.login, | ||
})); | ||
}, [mt5_accounts?.mt5_login_list, wallet?.linked_to]); | ||
|
||
return { | ||
/** The list of created MT5 accounts */ | ||
data: modified_mt5_accounts, | ||
...mt5_accounts_rest, | ||
}; | ||
}; | ||
|
||
export default useMT5LoginList; |
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,32 @@ | ||
import { useCallback, useMemo } from 'react'; | ||
import useFetch from '../useFetch'; | ||
import useInvalidateQuery from '../useInvalidateQuery'; | ||
import useRequest from '../useRequest'; | ||
|
||
type TSetSettingsPayload = NonNullable< | ||
NonNullable<NonNullable<Parameters<ReturnType<typeof useRequest<'set_settings'>>['mutate']>>[0]>['payload'] | ||
>; | ||
|
||
/** A custom hook to get user settings (email, date of birth, address etc) */ | ||
const useSettings = () => { | ||
const { data, ...rest } = useFetch('get_settings'); | ||
const invalidate = useInvalidateQuery(); | ||
const { mutate, ...mutate_rest } = useRequest('set_settings', { | ||
onSuccess: () => invalidate('get_settings'), | ||
}); | ||
|
||
const update = useCallback((values: TSetSettingsPayload) => mutate({ payload: { ...values } }), [mutate]); | ||
|
||
const modified_data = useMemo(() => ({ ...data?.get_settings }), [data?.get_settings]); | ||
|
||
return { | ||
/** User information and settings */ | ||
data: modified_data, | ||
/** Function to update user settings */ | ||
update, | ||
mutation: mutate_rest, | ||
...rest, | ||
}; | ||
}; | ||
|
||
export default useSettings; |
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,48 @@ | ||
import { useMemo } from 'react'; | ||
import useFetch from '../useFetch'; | ||
|
||
/** A custom hook that gets the list of created other CFD accounts. */ | ||
const useTradingPlatformAccounts = () => { | ||
const { data: derivez_accounts, ...derivez_rest } = useFetch('trading_platform_accounts', { | ||
payload: { platform: 'derivez' }, | ||
}); | ||
const { data: dxtrade_accounts, ...dxtrade_rest } = useFetch('trading_platform_accounts', { | ||
payload: { platform: 'dxtrade' }, | ||
}); | ||
|
||
/** Adding neccesary properties to derivez accounts */ | ||
const modified_derivez_accounts = useMemo( | ||
() => | ||
derivez_accounts?.trading_platform_accounts?.map(account => ({ | ||
...account, | ||
loginid: account.login, | ||
})), | ||
[derivez_accounts?.trading_platform_accounts] | ||
); | ||
|
||
/** Adding neccesary properties to dxtrade accounts */ | ||
const modified_dxtrade_accounts = useMemo( | ||
() => | ||
dxtrade_accounts?.trading_platform_accounts?.map(account => ({ | ||
...account, | ||
loginid: account.account_id, | ||
})), | ||
[dxtrade_accounts?.trading_platform_accounts] | ||
); | ||
|
||
const data = useMemo( | ||
() => ({ | ||
dxtrade_accounts: modified_dxtrade_accounts || [], | ||
derivez_accounts: modified_derivez_accounts || [], | ||
}), | ||
[modified_dxtrade_accounts, modified_derivez_accounts] | ||
); | ||
|
||
return { | ||
/** List of all created other CFD accounts */ | ||
data, | ||
...{ ...derivez_rest, ...dxtrade_rest }, | ||
}; | ||
}; | ||
|
||
export default useTradingPlatformAccounts; |
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
Oops, something went wrong.