Skip to content

Commit

Permalink
Maryia/used shortcode + updated mt5_new_account request (#23)
Browse files Browse the repository at this point in the history
* Maryia/using shortcode + mt5_new_account request + updated cfd personal account modal

* commented out personal details form tests temporarily

* revert personal details form

* revert tests for cfd personal detail form

* revert cfd personal details modal

* revert prop types

* prevent memory leak in cfd personal details modal
  • Loading branch information
maryia-deriv committed Jul 11, 2022
1 parent 87b86aa commit 31cb0b3
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 101 deletions.
1 change: 0 additions & 1 deletion packages/cfd/src/Containers/cfd-dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,6 @@ export default withRouter(
setCurrentAccount: modules.cfd.setCurrentAccount,
standpoint: client.standpoint,
toggleCompareAccounts: modules.cfd.toggleCompareAccountsModal,
toggleJurisdictionModal: modules.cfd.toggleJurisdictionModal,
toggleMT5TradeModal: modules.cfd.toggleMT5TradeModal,
is_accounts_switcher_on: ui.is_accounts_switcher_on,
openTopUpModal: ui.openTopUpModal,
Expand Down
13 changes: 7 additions & 6 deletions packages/cfd/src/Containers/cfd-personal-details-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ const CFDPersonalDetailsModal = ({
};

React.useEffect(() => {
setIsLoading(true);
initiatePersonalDetails().then(() => {
setIsLoading(false);
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
if (is_open) {
setIsLoading(true);
initiatePersonalDetails().then(() => {
setIsLoading(false);
});
}
}, [is_open]);

const transform = (value: string | undefined) => {
const [result] = residence_list.filter(item => item.value === value);
Expand Down
161 changes: 87 additions & 74 deletions packages/cfd/src/Containers/jurisdiction-modal-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type TAvailableAccountAPI = [

type TJurisdictionModalContent = {
account_type: string;
jurisdiction_selected_card: string;
setJurisdictionSelectedCard: (card_type: string) => void;
jurisdiction_selected_shortcode: string;
setJurisdictionSelectedShortcode: (card_type: string) => void;
synthetic_available_accounts: TAvailableAccountAPI;
financial_available_accounts: TAvailableAccountAPI;
poa_status: string;
Expand All @@ -41,31 +41,31 @@ type TJurisdictionModalContent = {
};

type TJurisdictionCard = {
jurisdiction_selected_card: string;
jurisdiction_selected_shortcode: string;
synthetic_available_accounts: TAvailableAccountAPI;
financial_available_accounts: TAvailableAccountAPI;
account_type: string;
poa_status: string;
poi_status: string;
is_fully_authenticated: boolean;
is_pending_authentication: boolean;
setJurisdictionSelectedCard: (card_type: string) => void;
setJurisdictionSelectedShortcode: (card_type: string) => void;
type_of_card: string;
disabled: boolean;
poa_failed: boolean;
poi_failed: boolean;
};

const JurisdictionCard = ({
jurisdiction_selected_card,
jurisdiction_selected_shortcode,
synthetic_available_accounts,
financial_available_accounts,
account_type,
poa_status,
poi_status,
is_fully_authenticated,
is_pending_authentication,
setJurisdictionSelectedCard,
setJurisdictionSelectedShortcode,
type_of_card,
disabled,
poa_failed,
Expand All @@ -86,10 +86,10 @@ const JurisdictionCard = ({
const poi_none = poi_status === PoaStatusCodes.none;

const cardSelection = (cardType: string) => {
if (jurisdiction_selected_card === cardType) {
setJurisdictionSelectedCard('');
if (jurisdiction_selected_shortcode === cardType) {
setJurisdictionSelectedShortcode('');
} else {
setJurisdictionSelectedCard(cardType);
setJurisdictionSelectedShortcode(cardType);
}
};

Expand Down Expand Up @@ -174,7 +174,7 @@ const JurisdictionCard = ({
<>
<div
className={classNames('cfd-jurisdiction-card', {
'cfd-jurisdiction-card--selected': jurisdiction_selected_card === type_of_card,
'cfd-jurisdiction-card--selected': jurisdiction_selected_shortcode === type_of_card,
})}
onClick={disabled ? () => undefined : () => cardSelection(`${type_of_card}`)}
style={OneOrTwoCards ? { width: '32em' } : { width: '27.6em' }}
Expand Down Expand Up @@ -225,9 +225,9 @@ const JurisdictionCard = ({
};

const JurisdictionModalContent = ({
jurisdiction_selected_card,
jurisdiction_selected_shortcode,
account_type,
setJurisdictionSelectedCard,
setJurisdictionSelectedShortcode,
synthetic_available_accounts,
financial_available_accounts,
poa_status,
Expand Down Expand Up @@ -267,7 +267,7 @@ const JurisdictionModalContent = ({
const ModalFootNote = () => {
return (
<>
{poa_none && poi_none && jurisdiction_selected_card !== 'svg' && jurisdiction_selected_card && (
{poa_none && poi_none && jurisdiction_selected_shortcode !== 'svg' && jurisdiction_selected_shortcode && (
<Text
as='p'
align='center'
Expand All @@ -279,77 +279,88 @@ const JurisdictionModalContent = ({
<Localize i18n_default_text='To create this account first we need your proof of identity and address.' />
</Text>
)}
{poi_failed && !poa_failed && jurisdiction_selected_card && jurisdiction_selected_card !== 'svg' && (
<Text
as='p'
align='center'
size='xs'
weight='bold'
line_height='xs'
className='cfd-jurisdiction-card__footnote'
>
<Localize i18n_default_text='To create this account first we need you to resubmit your proof of identity.' />
</Text>
)}
{poa_failed && !poi_failed && jurisdiction_selected_card && jurisdiction_selected_card !== 'svg' && (
<Text
as='p'
align='center'
size='xs'
weight='bold'
line_height='xs'
className='cfd-jurisdiction-card__footnote'
>
<Localize i18n_default_text='To create this account first we need you to resubmit your proof of address.' />
</Text>
)}
{poa_failed && poi_failed && jurisdiction_selected_card && jurisdiction_selected_card !== 'svg' && (
<Text
as='p'
align='center'
size='xs'
weight='bold'
line_height='xs'
className='cfd-jurisdiction-card__footnote'
>
<Localize i18n_default_text='To create this account first we need you to resubmit your proof of identity and address.' />
</Text>
)}
{jurisdiction_selected_card === 'svg' && (
{poi_failed &&
!poa_failed &&
jurisdiction_selected_shortcode &&
jurisdiction_selected_shortcode !== 'svg' && (
<Text
as='p'
align='center'
size='xs'
weight='bold'
line_height='xs'
className='cfd-jurisdiction-card__footnote'
>
<Localize i18n_default_text='To create this account first we need you to resubmit your proof of identity.' />
</Text>
)}
{poa_failed &&
!poi_failed &&
jurisdiction_selected_shortcode &&
jurisdiction_selected_shortcode !== 'svg' && (
<Text
as='p'
align='center'
size='xs'
weight='bold'
line_height='xs'
className='cfd-jurisdiction-card__footnote'
>
<Localize i18n_default_text='To create this account first we need you to resubmit your proof of address.' />
</Text>
)}
{poa_failed &&
poi_failed &&
jurisdiction_selected_shortcode &&
jurisdiction_selected_shortcode !== 'svg' && (
<Text
as='p'
align='center'
size='xs'
weight='bold'
line_height='xs'
className='cfd-jurisdiction-card__footnote'
>
<Localize i18n_default_text='To create this account first we need you to resubmit your proof of identity and address.' />
</Text>
)}
{jurisdiction_selected_shortcode === 'svg' && (
<div className='cfd-jurisdiction-card__footnote'>
<Text as='p' weight='bold' align='center' size='xs' line_height='xs'>
<Localize i18n_default_text='Add your DMT5 Synthetics account under Deriv (SVG) LLC (company no. 273 LLC 2020).' />
</Text>
</div>
)}
{is_fully_authenticated && jurisdiction_selected_card === 'bvi' && (
{is_fully_authenticated && jurisdiction_selected_shortcode === 'bvi' && (
<div className='cfd-jurisdiction-card__footnote'>
<Text as='p' weight='bold' align='center' size='xs' line_height='xs'>
<Localize i18n_default_text='Add your DMT5 Financial account under Deriv (BVI) Ltd, regulated by the British Virgin Islands Financial Services Commission (License no. SIBA/L/18/1114).' />
</Text>
</div>
)}
{is_fully_authenticated && jurisdiction_selected_card === 'vanuatu' && (
{is_fully_authenticated && jurisdiction_selected_shortcode === 'vanuatu' && (
<div className='cfd-jurisdiction-card__footnote'>
<Text as='p' weight='bold' align='center' size='xs' line_height='xs'>
<Localize i18n_default_text='Add Your DMT5 Financial account under Deriv (V) Ltd, regulated by the Vanuatu Financial Services Commission.' />
</Text>
</div>
)}
{is_fully_authenticated && jurisdiction_selected_card === 'labuan' && (
{is_fully_authenticated && jurisdiction_selected_shortcode === 'labuan' && (
<div className='cfd-jurisdiction-card__footnote'>
<Text as='p' weight='bold' align='center' size='xs' line_height='xs'>
<Localize i18n_default_text='Add your DMT5 Financial STP account under Deriv (FX) Ltd regulated by Labuan Financial Services Authority(licence no. MB/18/0024).' />
</Text>
</div>
)}
{is_pending_authentication && jurisdiction_selected_card !== 'svg' && jurisdiction_selected_card && (
<div className='cfd-jurisdiction-card__footnote--pending'>
<Text as='p' align='center' color='yellow' weight='bold' size='xs' line_height='xs'>
<Localize i18n_default_text='Your documents are being reviewed, we will notify you once this account is ready for you to create.' />
</Text>
</div>
)}
{is_pending_authentication &&
jurisdiction_selected_shortcode !== 'svg' &&
jurisdiction_selected_shortcode && (
<div className='cfd-jurisdiction-card__footnote--pending'>
<Text as='p' align='center' color='yellow' weight='bold' size='xs' line_height='xs'>
<Localize i18n_default_text='Your documents are being reviewed, we will notify you once this account is ready for you to create.' />
</Text>
</div>
)}
</>
);
};
Expand All @@ -375,15 +386,15 @@ const JurisdictionModalContent = ({
{cardsToBeShown('bvi') && (
<JurisdictionCard
type_of_card='bvi'
jurisdiction_selected_card={jurisdiction_selected_card}
jurisdiction_selected_shortcode={jurisdiction_selected_shortcode}
synthetic_available_accounts={synthetic_available_accounts}
financial_available_accounts={financial_available_accounts}
account_type={account_type}
is_fully_authenticated={is_fully_authenticated}
is_pending_authentication={is_pending_authentication}
poa_status={poa_status}
poi_status={poi_status}
setJurisdictionSelectedCard={setJurisdictionSelectedCard}
setJurisdictionSelectedShortcode={setJurisdictionSelectedShortcode}
disabled={disableCard('bvi')}
poa_failed={poa_failed}
poi_failed={poi_failed}
Expand All @@ -392,17 +403,17 @@ const JurisdictionModalContent = ({

{cardsToBeShown('maltainvest') && is_eu && (
<JurisdictionCard
type_of_card='mf'
jurisdiction_selected_card={jurisdiction_selected_card}
type_of_card='maltainvest'
jurisdiction_selected_shortcode={jurisdiction_selected_shortcode}
synthetic_available_accounts={synthetic_available_accounts}
financial_available_accounts={financial_available_accounts}
is_fully_authenticated={is_fully_authenticated}
is_pending_authentication={is_pending_authentication}
account_type={account_type}
poa_status={poa_status}
poi_status={poi_status}
setJurisdictionSelectedCard={setJurisdictionSelectedCard}
disabled={disableCard('mf')}
setJurisdictionSelectedShortcode={setJurisdictionSelectedShortcode}
disabled={disableCard('maltainvest')}
poa_failed={poa_failed}
poi_failed={poi_failed}
/>
Expand All @@ -411,15 +422,15 @@ const JurisdictionModalContent = ({
{cardsToBeShown('vanuatu') && (
<JurisdictionCard
type_of_card='vanuatu'
jurisdiction_selected_card={jurisdiction_selected_card}
jurisdiction_selected_shortcode={jurisdiction_selected_shortcode}
synthetic_available_accounts={synthetic_available_accounts}
financial_available_accounts={financial_available_accounts}
is_fully_authenticated={is_fully_authenticated}
is_pending_authentication={is_pending_authentication}
account_type={account_type}
poa_status={poa_status}
poi_status={poi_status}
setJurisdictionSelectedCard={setJurisdictionSelectedCard}
setJurisdictionSelectedShortcode={setJurisdictionSelectedShortcode}
disabled={disableCard('vanuatu')}
poa_failed={poa_failed}
poi_failed={poi_failed}
Expand All @@ -428,15 +439,15 @@ const JurisdictionModalContent = ({
{cardsToBeShown('labuan') && (
<JurisdictionCard
type_of_card='labuan'
jurisdiction_selected_card={jurisdiction_selected_card}
jurisdiction_selected_shortcode={jurisdiction_selected_shortcode}
synthetic_available_accounts={synthetic_available_accounts}
financial_available_accounts={financial_available_accounts}
is_fully_authenticated={is_fully_authenticated}
is_pending_authentication={is_pending_authentication}
account_type={account_type}
poa_status={poa_status}
poi_status={poi_status}
setJurisdictionSelectedCard={setJurisdictionSelectedCard}
setJurisdictionSelectedShortcode={setJurisdictionSelectedShortcode}
disabled={disableCard('labuan')}
poa_failed={poa_failed}
poi_failed={poi_failed}
Expand All @@ -446,15 +457,15 @@ const JurisdictionModalContent = ({
{cardsToBeShown('svg') && (
<JurisdictionCard
type_of_card='svg'
jurisdiction_selected_card={jurisdiction_selected_card}
jurisdiction_selected_shortcode={jurisdiction_selected_shortcode}
synthetic_available_accounts={synthetic_available_accounts}
financial_available_accounts={financial_available_accounts}
is_fully_authenticated={is_fully_authenticated}
is_pending_authentication={is_pending_authentication}
account_type={account_type}
poa_status={poa_status}
poi_status={poi_status}
setJurisdictionSelectedCard={setJurisdictionSelectedCard}
setJurisdictionSelectedShortcode={setJurisdictionSelectedShortcode}
disabled={disableCard('svg')}
poa_failed={poa_failed}
poi_failed={poi_failed}
Expand All @@ -464,8 +475,10 @@ const JurisdictionModalContent = ({
<ModalFootNote />
{is_fully_authenticated &&
poi_poa_verified &&
jurisdiction_selected_card &&
jurisdiction_selected_card !== 'svg' && <ModalCheckbox is_checked={checked} onCheck={setChecked} />}
jurisdiction_selected_shortcode &&
jurisdiction_selected_shortcode !== 'svg' && (
<ModalCheckbox is_checked={checked} onCheck={setChecked} />
)}
</>
);
};
Expand Down
Loading

0 comments on commit 31cb0b3

Please sign in to comment.