-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added FATCA declaration section (#12490)
* feat: added FATCA declaration section * feat: added testcases * chore: rebuild * chore: rebuild * chore: rebuild * chore: rebuild * chore: rebuild 2 * chore: rebuild 3 * fix: incorporated review comments * chore: made the field mandatory * fix: added required field * fix: failing testcase * chore: setting fatca declaration value in DIEL * fix: added testcase
- Loading branch information
1 parent
4df45d6
commit 9e78e2d
Showing
8 changed files
with
217 additions
and
13 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
59 changes: 59 additions & 0 deletions
59
packages/account/src/Components/terms-of-use/fatca-declaration.tsx
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,59 @@ | ||
import React from 'react'; | ||
import { FieldInputProps } from 'formik'; | ||
import { Text, Dropdown } from '@deriv/components'; | ||
import { isDesktop } from '@deriv/shared'; | ||
import { Localize, localize } from '@deriv/translations'; | ||
import { getFatcaDeclaration, getAgreementOptions } from '../../Constants/fatca-declaration'; | ||
import './terms-of-use.scss'; | ||
|
||
type TFATCADeclarationProps = { | ||
field: FieldInputProps<'0' | '1'>; | ||
is_disabled: boolean; | ||
} & React.ComponentPropsWithoutRef<typeof Dropdown>; | ||
|
||
/** | ||
* Component that displays the FATCA declaration and a dropdown to select yes or no | ||
* @name FatcaDeclaration | ||
* @param field - Formik FieldInputProps | ||
* @returns React Component | ||
*/ | ||
const FatcaDeclaration = ({ field: { value, onChange, name }, ...props }: TFATCADeclarationProps) => ( | ||
<React.Fragment> | ||
<Text as='h4' size='xs' weight='bold'> | ||
<Localize i18n_default_text='FATCA declaration' /> | ||
</Text> | ||
<div className='fatca-declaration__layout'> | ||
<ol> | ||
{getFatcaDeclaration().map((item, idx) => ( | ||
<Text | ||
as='li' | ||
key={`point_${idx}`} | ||
size={isDesktop() ? 'xs' : 'xxs'} | ||
className='fatca-declaration__points' | ||
> | ||
{idx + 1}. {item} | ||
</Text> | ||
))} | ||
</ol> | ||
<Text as='p' size={isDesktop() ? 'xs' : 'xxs'} className='fatca-declaration__points'> | ||
<Localize | ||
i18n_default_text='If any of the above applies to you, select <0>Yes.</0> Otherwise, select <0>No.</0>' | ||
components={[<strong key={0} />]} | ||
/> | ||
</Text> | ||
<Dropdown | ||
{...props} | ||
is_align_text_left | ||
name={name} | ||
placeholder={localize('Please select*')} | ||
value={value} | ||
list={getAgreementOptions()} | ||
className='fatca-declaration__agreement' | ||
onChange={onChange} | ||
disabled={props.is_disabled} | ||
/> | ||
</div> | ||
</React.Fragment> | ||
); | ||
|
||
export default FatcaDeclaration; |
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
36 changes: 36 additions & 0 deletions
36
packages/account/src/Configs/__test__/terms-of-use-config.spec.ts
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,36 @@ | ||
import termsOfUseConfig from '../terms-of-use-config'; | ||
|
||
jest.mock('@deriv/shared', () => ({ | ||
...jest.requireActual('@deriv/shared'), | ||
getDefaultFields: jest.fn(), | ||
})); | ||
|
||
describe('terms-of-use-config', () => { | ||
const MockComponent = jest.fn(); | ||
|
||
it('should set the is_multi_account value to true', () => { | ||
const account_settings = { | ||
fatca_declaration: 0, | ||
}; | ||
const config = termsOfUseConfig( | ||
{ | ||
real_account_signup_target: 'maltainvest', | ||
account_settings, | ||
}, | ||
MockComponent | ||
); | ||
expect(config.props.is_multi_account).toBeTruthy(); | ||
}); | ||
|
||
it('should set the is_multi_account value to false', () => { | ||
const account_settings = {}; | ||
const config = termsOfUseConfig( | ||
{ | ||
real_account_signup_target: 'maltainvest', | ||
account_settings, | ||
}, | ||
MockComponent | ||
); | ||
expect(config.props.is_multi_account).toBeFalsy(); | ||
}); | ||
}); |
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 React from 'react'; | ||
import { Localize, localize } from '@deriv/translations'; | ||
|
||
export const getFatcaDeclaration = () => [ | ||
<Localize i18n_default_text='US citizenship or lawful permanent resident (green card) status' key='1' />, | ||
<Localize i18n_default_text='A US birthplace' key='2' />, | ||
<Localize | ||
i18n_default_text='A US residence address or a US correspondence address (including a US PO box)' | ||
key='3' | ||
/>, | ||
<Localize | ||
i18n_default_text='Standing instructions to transfer funds to an account maintained in the United States, or directions regularly received from a US address' | ||
key='4' | ||
/>, | ||
<Localize | ||
i18n_default_text='An “in care of” address or a “hold mail” address that is the sole address with respect to the client' | ||
key='5' | ||
/>, | ||
<Localize | ||
i18n_default_text='A power of attorney or signatory authority granted to a person with a US address.' | ||
key='6' | ||
/>, | ||
]; | ||
|
||
export const getAgreementOptions = () => [ | ||
{ text: localize('Yes'), value: '1' }, | ||
{ text: localize('No'), value: '0' }, | ||
]; |