Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: implement new changes to the singup modal #7955

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
06c7465
chore: implement new changes to the singup modal
aizad-deriv Mar 19, 2023
48f5046
Merge branch 'master' into aizad/91073/account-signup-modal
aizad-deriv Mar 20, 2023
3bbc06b
fix: updated changes based on comments and updated stylings aswell
aizad-deriv Mar 20, 2023
a1170ff
Merge branch 'master' into aizad/91073/account-signup-modal
aizad-deriv Mar 20, 2023
9bf7657
fix: made changes based on comments
aizad-deriv Mar 20, 2023
3b76fc1
Merge branch 'aizad/91073/account-signup-modal' of github.com:aizad-d…
aizad-deriv Mar 20, 2023
b88374a
fix: remove react.fragment
aizad-deriv Mar 20, 2023
328bad1
fix: updated changes based on the comments and suggestions
aizad-deriv Mar 20, 2023
bd6b846
fix: remove gap between fields based on comments
aizad-deriv Mar 20, 2023
efae3ff
fix: made code improvements based on suggestions
aizad-deriv Mar 20, 2023
bb07298
fix: make changes based on recommendations
aizad-deriv Mar 20, 2023
c217a77
fix: make changes based on comments
aizad-deriv Mar 20, 2023
72d0f34
Merge branch 'master' into aizad/91073/account-signup-modal
yashim-deriv Mar 22, 2023
00592f0
Merge branch 'master' into aizad/91073/account-signup-modal
aizad-deriv Mar 24, 2023
eafc160
chore: updated captions for the fields and shorten code
aizad-deriv Mar 24, 2023
84fde1d
fix: update the caption for residence
aizad-deriv Mar 24, 2023
88b966a
fix: updated copywrite and fix password modal
aizad-deriv Mar 24, 2023
ca2bd77
fix: updated description for citizenship
aizad-deriv Mar 24, 2023
20d5e7b
Merge branch 'master' into aizad/91073/account-signup-modal
aizad-deriv Mar 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import classNames from 'classnames';
import { Formik, Form } from 'formik';
import PropTypes from 'prop-types';
import React from 'react';
import { Button, Dialog, Loading } from '@deriv/components';
import { Button, Dialog, Loading, Text } from '@deriv/components';
import { getLocation, PlatformContext } from '@deriv/shared';
import { localize } from '@deriv/translations';
import { WS } from 'Services';
import { connect } from 'Stores/connect';
import SameCitizenshipModal from '../CitizenshipModal/same-citizenship-modal.jsx';
import PasswordSelectionModal from '../PasswordSelectionModal/password-selection-modal.jsx';
import ResidenceForm from '../SetResidenceModal/set-residence-form.jsx';
import CitizenshipForm from '../CitizenshipModal/set-citizenship-form.jsx';
Expand All @@ -24,21 +23,15 @@ const AccountSignup = ({ enableApp, isModalVisible, clients_country, onSignup, r
const [pw_input, setPWInput] = React.useState('');
const [selected_residence, setSelectedResidence] = React.useState('');
const [selected_citizenship, setSelectedCitizenship] = React.useState('');
const [is_citizenship_modal, setIsCitizenshipModal] = React.useState(false);
const [is_same_citizenship_modal, setIsSameCitizenshipModal] = React.useState(false);
const [is_pasword_modal, setIsPasswordModal] = React.useState(false);

const updatePassword = new_password => {
setPWInput(new_password);
};

const onResidenceSelection = residence => {
setSelectedResidence(residence);
setIsSameCitizenshipModal(true);
};

const onCitizenshipSelection = citizenship => {
const onFormSingup = (residence, citizenship) => {
setSelectedCitizenship(citizenship);
setSelectedResidence(residence);
setIsPasswordModal(true);
};

Expand Down Expand Up @@ -101,89 +94,72 @@ const AccountSignup = ({ enableApp, isModalVisible, clients_country, onSignup, r
touched,
}) => (
<Form>
{!selected_residence || !is_same_citizenship_modal ? (
<ResidenceForm
header_text={localize('Thanks for verifying your email')}
class_prefix='account-signup'
{(!selected_residence && !selected_citizenship) || !is_pasword_modal ? (
aizad-deriv marked this conversation as resolved.
Show resolved Hide resolved
<div className='account-signup__main'>
<Text as='h1' weight='bold' className='account-signup__heading'>
{localize('Select your country and citizenship:')}
</Text>
<div className='account-signup__body'>
<ResidenceForm
class_prefix='account-signup'
errors={errors}
touched={touched}
setFieldTouched={setFieldTouched}
setFieldValue={setFieldValue}
residence_list={residence_list}
default_value={country}
history_value={history_value.current}
/>
<CitizenshipForm
class_prefix='account-signup'
errors={errors}
touched={touched}
setFieldTouched={setFieldTouched}
setFieldValue={setFieldValue}
citizenship_list={residence_list}
/>
</div>
<div className='account-signup__footer'>
<Button
className={classNames('account-signup__btn', {
'account-signup__btn--disabled':
!values.residence ||
!!errors.residence ||
!values.citizenship ||
!!errors.citizenship,
yashim-deriv marked this conversation as resolved.
Show resolved Hide resolved
})}
type='button'
is_disabled={
!values.residence ||
!!errors.residence ||
!values.citizenship ||
!!errors.citizenship
aizad-deriv marked this conversation as resolved.
Show resolved Hide resolved
}
onClick={() => {
onFormSingup(values.residence, values.citizenship);
history_value.current = values.residence;
}}
primary
large
text={localize('Next')}
/>
</div>
</div>
) : (
<PasswordSelectionModal
api_error={api_error}
errors={errors}
handleBlur={handleBlur}
handleChange={handleChange}
is_appstore={is_appstore}
isModalVisible={isModalVisible}
isSubmitting={isSubmitting}
touched={touched}
pw_input={pw_input}
setFieldTouched={setFieldTouched}
setFieldValue={setFieldValue}
residence_list={residence_list}
default_value={country}
history_value={history_value.current}
>
<Button
className={classNames('account-signup__btn', {
'account-signup__btn--disabled': !values.residence || errors.residence,
})}
type='button'
is_disabled={!values.residence || !!errors.residence}
onClick={() => {
onResidenceSelection(values.residence);
history_value.current = values.residence;
}}
primary
large
text={localize('Next')}
/>
</ResidenceForm>
) : (
<>
{!is_pasword_modal && !is_citizenship_modal ? (
<SameCitizenshipModal
onCitizenshipSelection={onCitizenshipSelection}
residence={values.residence}
setFieldValue={setFieldValue}
setIsCitizenshipModal={setIsCitizenshipModal}
setIsPasswordModal={setIsPasswordModal}
setIsSameCitizenshipModal={setIsSameCitizenshipModal}
/>
) : (
<>
{selected_citizenship && is_pasword_modal ? (
<PasswordSelectionModal
api_error={api_error}
errors={errors}
handleBlur={handleBlur}
handleChange={handleChange}
is_appstore={is_appstore}
isModalVisible={isModalVisible}
isSubmitting={isSubmitting}
touched={touched}
pw_input={pw_input}
setFieldTouched={setFieldTouched}
updatePassword={updatePassword}
values={values}
/>
) : (
<CitizenshipForm
class_prefix='account-signup'
errors={errors}
touched={touched}
setFieldTouched={setFieldTouched}
setFieldValue={setFieldValue}
citizenship_list={residence_list}
>
<Button
className={classNames('account-signup__btn', {
'account-signup__btn--disabled':
!values.citizenship || errors.citizenship,
})}
type='button'
is_disabled={!values.citizenship || !!errors.citizenship}
onClick={() => {
onCitizenshipSelection(values.citizenship);
}}
primary
large
text={localize('Next')}
/>
</CitizenshipForm>
)}
</>
)}
</>
updatePassword={updatePassword}
values={values}
/>
)}
</Form>
)}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,10 @@ import { Field } from 'formik';
import PropTypes from 'prop-types';
import React from 'react';
import { Autocomplete, DesktopWrapper, MobileWrapper, SelectNative, Text } from '@deriv/components';
import { localize } from '@deriv/translations';
import { Localize, localize } from '@deriv/translations';

const SetCitizenshipForm = ({
class_prefix,
children,
errors,
touched,
setFieldTouched,
setFieldValue,
citizenship_list,
}) => (
const SetCitizenshipForm = ({ class_prefix, errors, touched, setFieldTouched, setFieldValue, citizenship_list }) => (
<div className={`${class_prefix}__residence-selection`}>
<Text as='p' align='center' weight='bold' className={`${class_prefix}__heading-citizen`}>
{localize('Choose your citizenship')}
</Text>
<Field name='citizenship'>
{({ field }) => (
<React.Fragment>
Expand Down Expand Up @@ -53,12 +42,13 @@ const SetCitizenshipForm = ({
</React.Fragment>
)}
</Field>
{children}
<Text as='p' size='xxs' className='account-signup__subtext' color='less-prominent'>
aizad-deriv marked this conversation as resolved.
Show resolved Hide resolved
<Localize i18n_default_text='Country of citizenship or nationality is the country that issues your passport or other national identity document.' />
</Text>
</div>
);

SetCitizenshipForm.propTypes = {
children: PropTypes.node,
class_prefix: PropTypes.string,
citizenship_list: PropTypes.arrayOf(PropTypes.object),
errors: PropTypes.object,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,19 @@ const PasswordSelectionModal = ({
</div>
</React.Fragment>
) : (
<Button
className={classNames('account-signup__btn', {
'account-signup__btn--disabled': !values.password || errors.password || isSubmitting,
})}
id='dt_core_account-signup-modal_submit-btn'
type='submit'
is_disabled={!values.password || !!errors.password || isSubmitting}
text={localize('Start trading')}
large
primary
/>
<div className='account-signup__footer'>
matin-deriv marked this conversation as resolved.
Show resolved Hide resolved
<Button
className={classNames('account-signup__btn', {
'account-signup__btn--disabled': !values.password || errors.password || isSubmitting,
})}
id='dt_core_account-signup-modal_submit-btn'
type='submit'
is_disabled={!values.password || !!errors.password || isSubmitting}
aizad-deriv marked this conversation as resolved.
Show resolved Hide resolved
text={localize('Start trading')}
large
primary
/>
</div>
)}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import { localize } from '@deriv/translations';

const SetResidenceForm = ({
class_prefix = 'set-residence',
children,
default_value,
history_value,
header_text,
errors,
touched,
setFieldTouched,
Expand All @@ -22,16 +20,9 @@ const SetResidenceForm = ({
setFieldValue('residence', default_value, true);
}
}, []); // eslint-disable-line react-hooks/exhaustive-deps

aizad-deriv marked this conversation as resolved.
Show resolved Hide resolved
return (
<div className={`${class_prefix}__residence-selection`}>
{!!header_text && (
<Text as='p' align='center' weight='bold' className={`${class_prefix}__heading`}>
{header_text}
</Text>
)}
<Text as='p' className={`${class_prefix}__${header_text ? 'text' : 'heading'}`}>
{localize('Where do you live?')}
</Text>
<Field name='residence'>
{({ field }) => (
<React.Fragment>
Expand Down Expand Up @@ -70,18 +61,22 @@ const SetResidenceForm = ({
</React.Fragment>
)}
</Field>
{children}
{!errors?.residence?.length > 0 ? (
<Text as='p' size='xxs' className='account-signup__subtext' color='less-prominent'>
{localize(
'Country of residence is where you currently live, work, pay taxes and receive government services.'
)}
</Text>
) : null}
aizad-deriv marked this conversation as resolved.
Show resolved Hide resolved
</div>
);
};

SetResidenceForm.propTypes = {
children: PropTypes.node,
aizad-deriv marked this conversation as resolved.
Show resolved Hide resolved
class_prefix: PropTypes.string,
default_value: PropTypes.string,
history_value: PropTypes.string,
errors: PropTypes.object,
header_text: PropTypes.string,
residence_list: PropTypes.arrayOf(PropTypes.object),
setFieldTouched: PropTypes.func,
setFieldValue: PropTypes.func,
Expand Down
Loading