Skip to content

Commit e11c36c

Browse files
Merge 6f6db5c into 3ab799e
2 parents 3ab799e + 6f6db5c commit e11c36c

File tree

11 files changed

+127
-36
lines changed

11 files changed

+127
-36
lines changed

packages/tradershub/src/flows/RealAccountSIgnup/SignupWizard/Actions/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ import { Button } from '@deriv-com/ui';
66
import { useSignupWizardContext } from '../../../../providers/SignupWizardProvider';
77

88
type TActions = {
9-
canGoNext?: boolean;
9+
submitDisabled?: boolean;
1010
};
1111

1212
/**
1313
* @name Actions
1414
* @description The Actions component is used to navigate between steps in the SignupWizard component.
1515
* Intended to be used as a child component of the Formik component.
1616
* @param {Object} props - React props object
17-
* @param {boolean} [props.canGoNext] - A boolean that determines whether the Next button is disabled
17+
* @param {boolean} [props.submitDisabled] - A boolean that determines whether the Next button is disabled
1818
* @example
1919
* return (
20-
* <Actions canGoNext />
20+
* <Actions submitDisabled />
2121
* );
2222
*/
2323

24-
const Actions = ({ canGoNext = true }: TActions) => {
24+
const Actions = ({ submitDisabled = false }: TActions) => {
2525
const {
2626
helpers: { canGoToNextStep, canGoToPrevStep, goToPrevStep },
2727
} = useSignupWizardContext();
@@ -44,7 +44,7 @@ const Actions = ({ canGoNext = true }: TActions) => {
4444
)}
4545
<Button
4646
className='bg-solid-coral-700'
47-
disabled={!canGoNext}
47+
disabled={submitDisabled}
4848
isFullWidth={isMobile}
4949
onClick={() => handleSubmit()}
5050
size={isMobile ? 'lg' : 'md'}

packages/tradershub/src/screens/CurrencySelector/CurrencySelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const CurrencySelector = () => {
3333
<hr className='opacity-100 my-1200' />
3434
<Currencies type={CURRENCY_TYPES.CRYPTO} />
3535
</div>
36-
<Actions canGoNext={!!values.currency} />
36+
<Actions submitDisabled={!values.currency} />
3737
</Form>
3838
)}
3939
</Formik>

packages/tradershub/src/screens/PersonalDetails/PersonalDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const PersonalDetails = () => {
2323

2424
const initialValues = {
2525
accountOpeningReason: state.accountOpeningReason ?? '',
26+
confirmation: false,
2627
dateOfBirth: state.dateOfBirth ?? '',
2728
firstName: state.firstName ?? '',
2829
lastName: state.lastName ?? '',
@@ -31,7 +32,6 @@ const PersonalDetails = () => {
3132
taxIdentificationNumber: state.taxIdentificationNumber ?? '',
3233
taxResidence: state.taxResidence ?? '',
3334
};
34-
3535
return (
3636
<WizardScreenWrapper heading='Complete your personal details'>
3737
<Formik

packages/tradershub/src/screens/PersonalDetails/Sections/AdditionalInformation.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const AdditionalInformation = () => {
6161
text: residence.text,
6262
value: residence.value ?? '',
6363
}))}
64+
listHeight='sm'
6465
name='placeOfBirth'
6566
onSelect={selectedItem => {
6667
setFieldValue('placeOfBirth', selectedItem);
@@ -76,6 +77,7 @@ const AdditionalInformation = () => {
7677
text: residence.text,
7778
value: residence.value ?? '',
7879
}))}
80+
listHeight='sm'
7981
name='taxResidence'
8082
onSelect={selectedItem => {
8183
setFieldValue('taxResidence', selectedItem);
@@ -102,6 +104,7 @@ const AdditionalInformation = () => {
102104
errorMessage={touched.accountOpeningReason && errors.accountOpeningReason}
103105
label='Account opening reason*'
104106
list={AccountOpeningReasonList}
107+
listHeight='sm'
105108
name='accountOpeningReason'
106109
onSelect={selectedItem => {
107110
setFieldValue('accountOpeningReason', selectedItem);

packages/tradershub/src/screens/PersonalDetails/Sections/Details.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React, { Fragment, lazy, Suspense } from 'react';
22
import { useFormikContext } from 'formik';
33
import { useBreakpoint } from '@deriv/quill-design';
4-
import { Checkbox, InlineMessage, Input, Loader, Text } from '@deriv-com/ui';
4+
import { InlineMessage, Input, Loader, Text } from '@deriv-com/ui';
5+
import DetailsConfirmation from './DetailsConfirmation';
56

67
const ExampleImage = lazy(() => import('@/assets/svgs/personal-details-example.svg'));
78

@@ -86,7 +87,7 @@ const Details = () => {
8687
</div>
8788
</div>
8889
<div className='mt-800'>
89-
<Checkbox label='I confirm that the name and date of birth above match my chosen identity document.' />
90+
<DetailsConfirmation />
9091
</div>
9192
</div>
9293
</Fragment>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from 'react';
2+
import { Field, FieldProps, useFormikContext } from 'formik';
3+
import { Checkbox } from '@deriv-com/ui';
4+
5+
const DetailsConfirmation = () => {
6+
const { errors, values } = useFormikContext<{
7+
confirmation: boolean;
8+
dateOfBirth: string;
9+
firstName: string;
10+
lastName: string;
11+
}>();
12+
13+
const isDisabled = Boolean(
14+
!values.firstName ||
15+
!values.lastName ||
16+
!values.dateOfBirth ||
17+
errors.firstName ||
18+
errors.lastName ||
19+
errors.dateOfBirth
20+
);
21+
22+
return (
23+
<Field name='confirmation' type='checkbox'>
24+
{({ field, meta }: FieldProps) => (
25+
<Checkbox
26+
disabled={isDisabled}
27+
error={Boolean(meta.error && meta.touched)}
28+
label='I confirm that the name and date of birth above match my chosen identity document.'
29+
{...field}
30+
/>
31+
)}
32+
</Field>
33+
);
34+
};
35+
36+
export default DetailsConfirmation;

packages/tradershub/src/screens/TermsOfUse/TermsOfUse.tsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
2-
import { Form, Formik, FormikValues } from 'formik';
2+
import { Form, Formik } from 'formik';
3+
import { termsOfUse } from '@/utils';
34
import { Text } from '@deriv-com/ui';
45
import Actions from '../../flows/RealAccountSIgnup/SignupWizard/Actions';
56
import WizardScreenWrapper from '../../flows/RealAccountSIgnup/SignupWizard/WizardScreenWrapper';
@@ -17,22 +18,27 @@ const Divider = () => <hr className=' bg-system-light-primary-background' />;
1718
* @returns {React.ReactNode}
1819
*/
1920
const TermsOfUse = () => {
20-
const { dispatch } = useSignupWizardContext();
21+
const { dispatch, helpers, setIsWizardOpen } = useSignupWizardContext();
2122

2223
// Temporary function to handle form submission till we have the validations in place
23-
const handleSubmit = (values: FormikValues) => {
24-
dispatch({ payload: { firstName: values.firstName }, type: ACTION_TYPES.SET_PERSONAL_DETAILS });
24+
const handleSubmit = () => {
25+
dispatch({ type: ACTION_TYPES.RESET });
26+
setIsWizardOpen(false);
27+
helpers.setStep(1);
2528
};
29+
2630
return (
2731
<WizardScreenWrapper heading='Terms of Use'>
2832
<Formik
29-
// Temporary initial values
3033
initialValues={{
31-
firstName: '',
34+
fatcaDeclaration: '',
35+
pepConfirmation: false,
36+
termsAndCondition: false,
3237
}}
3338
onSubmit={handleSubmit}
39+
validationSchema={termsOfUse}
3440
>
35-
{() => (
41+
{({ isValid, values }) => (
3642
<Form className='flex flex-col flex-grow w-full overflow-y-auto'>
3743
<div className='flex-1 overflow-y-auto p-1200'>
3844
<div className='flex flex-col gap-800'>
@@ -61,7 +67,14 @@ const TermsOfUse = () => {
6167
<PEPs />
6268
</div>
6369
</div>
64-
<Actions />
70+
<Actions
71+
submitDisabled={
72+
!values.pepConfirmation ||
73+
!values.termsAndCondition ||
74+
!values.fatcaDeclaration ||
75+
!isValid
76+
}
77+
/>
6578
</Form>
6679
)}
6780
</Formik>

packages/tradershub/src/screens/TermsOfUse/TermsOfUseSections/FatcaDeclaration.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const fatcaDeclaration = [
1313
];
1414

1515
const FatcaDeclaration = () => {
16-
const { setFieldValue, values } = useFormikContext<{
16+
const { errors, setFieldValue, touched, values } = useFormikContext<{
1717
fatcaDeclaration: string;
1818
}>();
1919
return (
@@ -35,6 +35,7 @@ const FatcaDeclaration = () => {
3535
<div>
3636
<Dropdown
3737
dropdownIcon={<LabelPairedChevronDownMdRegularIcon />}
38+
errorMessage={touched.fatcaDeclaration && errors.fatcaDeclaration}
3839
label='Please select*'
3940
list={[
4041
{ text: 'Yes', value: 'yes' },
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React, { Fragment } from 'react';
2+
import { Field, FieldProps } from 'formik';
3+
import { Checkbox, Text } from '@deriv-com/ui';
4+
5+
const PEPConfirmation = () => (
6+
<Fragment>
7+
<Field name='pepConfirmation' type='checkbox'>
8+
{({ field, meta }: FieldProps) => (
9+
<Checkbox
10+
label='I am not a PEP and never have been a PEP.'
11+
{...field}
12+
error={Boolean(meta.touched && meta.error)}
13+
id='pepConfirmation'
14+
/>
15+
)}
16+
</Field>
17+
<Field name='termsAndCondition' type='checkbox'>
18+
{({ field, meta }: FieldProps) => (
19+
<Checkbox
20+
label={
21+
<Text color={meta.error && meta.touched ? 'error' : 'general'} size='sm'>
22+
I agree to the{' '}
23+
<a
24+
className='font-bold text-brand-coral hover:underline'
25+
href='/terms-and-conditions'
26+
rel='noopener noreferrer'
27+
target='_blank'
28+
>
29+
terms and conditions.
30+
</a>
31+
</Text>
32+
}
33+
{...field}
34+
error={Boolean(meta.touched && meta.error)}
35+
id='termsAndCondition'
36+
/>
37+
)}
38+
</Field>
39+
</Fragment>
40+
);
41+
42+
export default PEPConfirmation;

packages/tradershub/src/screens/TermsOfUse/TermsOfUseSections/PEPs.tsx

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Fragment } from 'react';
2-
import { getStaticUrl } from '@/helpers';
3-
import { Checkbox, Text } from '@deriv-com/ui';
2+
import { Text } from '@deriv-com/ui';
3+
import PEPConfirmation from './PEPConfirmation';
44

55
const PEPs = () => (
66
<Fragment>
@@ -11,22 +11,7 @@ const PEPs = () => (
1111
A politically exposed person (PEP) is someone appointed with a prominent public position. Close associates
1212
and family members of a PEP are also considered to be PEPs.
1313
</Text>
14-
<Checkbox label='I am not a PEP and never have been a PEP.' />
15-
<Checkbox
16-
label={
17-
<Text size='sm'>
18-
I agree to the{' '}
19-
<a
20-
className='font-bold text-brand-coral hover:underline'
21-
href={getStaticUrl('/terms-and-conditions')}
22-
rel='noopener noreferrer'
23-
target='_blank'
24-
>
25-
terms and conditions.
26-
</a>
27-
</Text>
28-
}
29-
/>
14+
<PEPConfirmation />
3015
</Fragment>
3116
);
3217

0 commit comments

Comments
 (0)