Skip to content

Commit

Permalink
chore: setting fatca declaration value in DIEL
Browse files Browse the repository at this point in the history
  • Loading branch information
likhith-deriv committed Jan 5, 2024
1 parent e8b30d0 commit 42eee36
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import './terms-of-use.scss';

type TFATCADeclarationProps = {
field: FieldInputProps<'0' | '1'>;
is_disabled: boolean;
} & React.ComponentPropsWithoutRef<typeof Dropdown>;

/**
Expand Down Expand Up @@ -49,6 +50,7 @@ const FatcaDeclaration = ({ field: { value, onChange, name }, ...props }: TFATCA
list={getAgreementOptions()}
className='fatca-declaration__agreement'
onChange={onChange}
disabled={props.is_disabled}
/>
</div>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type TTermsOfUseProps = {
value: TTermsOfUseFormProps;
real_account_signup_target: TBrokerCodes;
form_error?: string;
is_multi_account: boolean;
};

/**
Expand Down Expand Up @@ -96,7 +97,11 @@ const TermsOfUse = ({
<div className={className('details-form__elements', 'terms-of-use')}>
<BrokerSpecificMessage target={real_account_signup_target} />
<Hr />
<Field component={FatcaDeclaration} name='fatca_declaration' />
<Field
component={FatcaDeclaration}
name='fatca_declaration'
is_disabled={props.is_multi_account}
/>
<Hr />
<SharedMessage />
<Hr />
Expand Down
20 changes: 14 additions & 6 deletions packages/account/src/Configs/terms-of-use-config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from 'react';
import { getDefaultFields, isDesktop, TSchema } from '@deriv/shared';
import { getDefaultFields, isDesktop } from '@deriv/shared';
import { localize } from '@deriv/translations';
import { GetSettings } from '@deriv/api-types';

const terms_of_use_config: TSchema = {
type TTermsOfConfigSettings = GetSettings & { fatca_declaration: 0 | 1 };

const getTermsOfUseConfig = (account_settings: TTermsOfConfigSettings) => ({
agreed_tos: {
supported_in: ['svg', 'maltainvest'],
default_value: false,
Expand All @@ -13,24 +16,29 @@ const terms_of_use_config: TSchema = {
},
fatca_declaration: {
supported_in: ['svg', 'maltainvest'],
default_value: '',
default_value: String(account_settings?.fatca_declaration ?? ''),
},
};
});

const termsOfUseConfig = (
{ real_account_signup_target }: { real_account_signup_target: string },
{
real_account_signup_target,
account_settings,
}: { real_account_signup_target: string; account_settings: TTermsOfConfigSettings },
TermsOfUse: React.Component
) => {
const active_title = localize('Terms of use');

return {
header: {
active_title: isDesktop() ? active_title : null,
title: active_title,
},
body: TermsOfUse,
form_value: getDefaultFields(real_account_signup_target, terms_of_use_config),
form_value: getDefaultFields(real_account_signup_target, getTermsOfUseConfig(account_settings)),
props: {
real_account_signup_target,
is_multi_account: Boolean(String(account_settings?.fatca_declaration ?? '')),
},
icon: 'IcDashboardTermsOfUse',
};
Expand Down

0 comments on commit 42eee36

Please sign in to comment.