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

Mahdiyeh/Feature: add social unlinking #4854

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
d6f1ffb
add wrong typo part to the sent-email-modal and add live chat
mahdiyeh-deriv Feb 13, 2022
3fa1bff
change Password to Emails and passwords
mahdiyeh-deriv Feb 13, 2022
d2feaee
add change email component to Emails and passwors
mahdiyeh-deriv Feb 16, 2022
6d1300e
add email reset modal
mahdiyeh-deriv Feb 16, 2022
c8c8bb8
Merge branch 'master' of github.com:binary-com/deriv-app into unlinki…
mahdiyeh-deriv Feb 20, 2022
d388a6d
fix_conflicts in password.jsx
mahdiyeh-deriv Feb 22, 2022
6a8d395
add reset email modal
mahdiyeh-deriv Feb 22, 2022
03f3854
add success email modal
mahdiyeh-deriv Feb 22, 2022
41147b0
add redirection of social_email_change modal
mahdiyeh-deriv Feb 28, 2022
e86df1f
Merge branch 'master' of github.com:binary-com/deriv-app into unlinki…
mahdiyeh-deriv Mar 6, 2022
15953c8
fix responsive mode
mahdiyeh-deriv Mar 6, 2022
a17bd16
fix sendEmailModal
mahdiyeh-deriv Mar 6, 2022
b4ecc85
add verification_code for social_emil_change
mahdiyeh-deriv Mar 7, 2022
ca60aff
get email from url
mahdiyeh-deriv Mar 7, 2022
4171919
add condition for change email part for social and non-social account
mahdiyeh-deriv Mar 7, 2022
508f3b7
fix change_email modal when get invalidToken error
mahdiyeh-deriv Mar 8, 2022
3c138eb
Merge branch 'master' of github.com:binary-com/deriv-app into unlinki…
mahdiyeh-deriv Mar 9, 2022
fcbadcf
add change_email_actions to ignore list of invalidToken error handling
mahdiyeh-deriv Mar 10, 2022
c2b5178
add email success modal
mahdiyeh-deriv Mar 10, 2022
683083f
Merge branch 'master' of github.com:binary-com/deriv-app into unlinki…
mahdiyeh-deriv Mar 14, 2022
8facf76
automate email change for non social accounts
mahdiyeh-deriv Mar 14, 2022
c388b9e
Merge branch 'master' of github.com:binary-com/deriv-app into automat…
mahdiyeh-deriv Mar 15, 2022
52fc031
remove unnecessary changes
mahdiyeh-deriv Mar 15, 2022
f564c20
fix invalidToken error for change_email
mahdiyeh-deriv Mar 15, 2022
b251a24
Merge branch 'master' of github.com:binary-com/deriv-app into automat…
mahdiyeh-deriv Mar 17, 2022
b2a6427
fix typos and naming and minify the svg
mahdiyeh-deriv Mar 17, 2022
d1944a9
Merge branch 'master' of github.com:binary-com/deriv-app into unlinki…
mahdiyeh-deriv Mar 27, 2022
06f3329
Merge branch 'master' of github.com:binary-com/deriv-app into automat…
mahdiyeh-deriv Mar 29, 2022
6d1e04e
fix typo
mahdiyeh-deriv Mar 29, 2022
2361c6b
remove successEmailModal and clean the code
mahdiyeh-deriv Mar 29, 2022
0616d0a
fix logging out the user, email_modal size on mobile and remove succe…
mahdiyeh-deriv Mar 30, 2022
d0882b1
fix conflicts with automation
mahdiyeh-deriv Mar 31, 2022
e96b04a
fix icons color
mahdiyeh-deriv Mar 31, 2022
6d8ea57
fix redirecting to the trade page
mahdiyeh-deriv Apr 3, 2022
a766579
fix success modal content
mahdiyeh-deriv Apr 4, 2022
1538a83
remove email part from personalDetails page
mahdiyeh-deriv Apr 4, 2022
2f82741
fix email and passwords name when it is social account
mahdiyeh-deriv Apr 4, 2022
714780c
show email box in personalDetails for social accounts
mahdiyeh-deriv Apr 5, 2022
3cd9bf1
Merge branch 'master' of github.com:binary-com/deriv-app into unlinki…
mahdiyeh-deriv Apr 5, 2022
428295d
Merge branch 'automate_email_change_for_non_social' of github.com:mah…
mahdiyeh-deriv Apr 5, 2022
735b858
sync changes with automation email
mahdiyeh-deriv Apr 6, 2022
90e524e
change px to rem
mahdiyeh-deriv Apr 10, 2022
aa19d15
add <br/> to the success message to the email update modal
mahdiyeh-deriv Apr 10, 2022
6cd0a90
fix typo
mahdiyeh-deriv Apr 13, 2022
9ac4973
chnage the behaviour for apple id when click on the unlink button
mahdiyeh-deriv Apr 14, 2022
8c51749
fix verification_code error
mahdiyeh-deriv Apr 16, 2022
986cd61
fix conflicts
mahdiyeh-deriv Apr 24, 2022
a4b33bf
fix email and passord name for all social and non social emails
mahdiyeh-deriv Apr 24, 2022
008adf4
remove UnlinkModal from deriv-password
mahdiyeh-deriv Apr 24, 2022
6e394fe
Merge branch 'master' into unlinking_social_account
mahdiyeh-deriv May 16, 2022
d717a2b
Merge branch 'master' of github.com:binary-com/deriv-app into unlinki…
mahdiyeh-deriv May 17, 2022
b2e76c4
update with master
mahdiyeh-deriv May 17, 2022
efdfb3a
Merge branch 'master' of github.com:binary-com/deriv-app into unlinki…
mahdiyeh-deriv May 23, 2022
08660c4
update branch
mahdiyeh-deriv May 23, 2022
4abd83a
Merge branch 'master' into unlinking_social_account
mahdiyeh-deriv May 24, 2022
9fd977d
Merge branch 'master' of github.com:binary-com/deriv-app into unlinki…
mahdiyeh-deriv Oct 16, 2022
5f6253f
Merge branch 'master' of github.com:binary-com/deriv-app into unlinki…
mahdiyeh-deriv Oct 20, 2022
eeb5454
Merge branch 'unlinking_social_account' of github.com:mahdiyeh-fs/der…
mahdiyeh-deriv Oct 23, 2022
a144072
fix apple icon
mahdiyeh-deriv Oct 23, 2022
024089b
Merge branch 'master' of github.com:binary-com/deriv-app into unlinki…
mahdiyeh-deriv Nov 2, 2022
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
105,148 changes: 27,671 additions & 77,477 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions packages/account/src/Components/Routes/binary-link.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import { NavLink } from 'react-router-dom';
import { PlatformContext } from '@deriv/shared';
import getRoutesConfig from 'Constants/routes-config';
import { findRouteByPath, normalizePath } from './helpers';
import { connect } from 'Stores/connect';

const BinaryLink = ({ active_class, to, children, is_social_signup, ...props }) => {
const BinaryLink = ({ active_class, to, children, ...props }) => {
const { is_appstore } = React.useContext(PlatformContext);
const path = normalizePath(to);
const route = findRouteByPath(path, getRoutesConfig({ is_appstore }, is_social_signup));
const route = findRouteByPath(path, getRoutesConfig({ is_appstore }));

if (!route) {
throw new Error(`Route not found: ${to}`);
Expand All @@ -31,6 +30,4 @@ BinaryLink.propTypes = {
to: PropTypes.string,
};

export default connect(({ client }) => ({
is_social_signup: client.is_social_signup,
}))(BinaryLink);
export default BinaryLink;
8 changes: 2 additions & 6 deletions packages/account/src/Components/Routes/binary-routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { Switch } from 'react-router-dom';
import { Localize, PlatformContext } from '@deriv/shared';
import getRoutesConfig from 'Constants/routes-config';
import RouteWithSubRoutes from './route-with-sub-routes.jsx';
import { connect } from 'Stores/connect';

const BinaryRoutes = props => {
const { is_appstore } = React.useContext(PlatformContext);
const { is_social_signup } = props;
return (
<React.Suspense
fallback={() => {
Expand All @@ -19,14 +17,12 @@ const BinaryRoutes = props => {
}}
>
<Switch>
{getRoutesConfig({ is_appstore }, is_social_signup).map((route, idx) => (
{getRoutesConfig({ is_appstore }).map((route, idx) => (
<RouteWithSubRoutes key={idx} {...route} {...props} />
))}
</Switch>
</React.Suspense>
);
};

export default connect(({ client }) => ({
is_social_signup: client.is_social_signup,
}))(BinaryRoutes);
export default BinaryRoutes;
3 changes: 3 additions & 0 deletions packages/account/src/Components/unlink-account-modal/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import UnlinkAccountModal from './unlink-account-modal.jsx';

export default UnlinkAccountModal;
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Button, Modal, Text, Icon } from '@deriv/components';
import { localize, Localize } from '@deriv/translations';

const UnlinkAccountModal = ({ onClose, is_open, identifier_title, onClickSendEmail }) => {
const onClickUnlinkButton = () => {
onClose();
onClickSendEmail();
};

return (
<Modal className={'unlink-account__modal'} is_open={is_open} has_close_icon toggleModal={onClose} width='440px'>
<Modal.Body>
<div onClick={onClose} className='unlink-account__modal-close'>
<Icon icon='IcCross' />
</div>
<div className='unlink-account__modal-icon'>
<Icon icon='IcEmailChanged' size={128} />
</div>
<div className='unlink-account__modal-content'>
<Text className='unlink-account__modal-title' weight='bold' size='s'>
<Localize i18n_default_text='Change your login email' />
</Text>
<Text className='unlink-account__modal-description' size='xs'>
<Localize
i18n_default_text="To change your email address, you'll first need to unlink your email address from your {{identifier_title}} account."
values={{ identifier_title }}
/>
</Text>
</div>
</Modal.Body>
<Modal.Footer className='unlink-account__footer'>
<Button onClick={onClose} has_effect text={localize('Cancel')} secondary large />
<Button onClick={onClickUnlinkButton} has_effect primary large>
<Localize i18n_default_text='Unlink from {{identifier_title}}' values={{ identifier_title }} />
</Button>
</Modal.Footer>
</Modal>
);
};

UnlinkAccountModal.prototypes = {
onClose: PropTypes.func,
is_open: PropTypes.bool,
identifier_title: PropTypes.string,
onClickSendEmail: PropTypes.func,
};

export default UnlinkAccountModal;

This file was deleted.

3 changes: 0 additions & 3 deletions packages/account/src/Components/unlink-modal/index.js

This file was deleted.

32 changes: 0 additions & 32 deletions packages/account/src/Components/unlink-modal/unlink-modal.jsx

This file was deleted.

12 changes: 7 additions & 5 deletions packages/account/src/Constants/routes-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
const Page404 = React.lazy(() => moduleLoader(() => import(/* webpackChunkName: "404" */ 'Modules/Page404')));

// Order matters
const initRoutesConfig = ({ is_appstore }, is_social_signup) => [
const initRoutesConfig = ({ is_appstore }) => [
{
path: routes.account_closed,
component: AccountClosed,
Expand Down Expand Up @@ -83,7 +83,7 @@ const initRoutesConfig = ({ is_appstore }, is_social_signup) => [
{
path: routes.passwords,
component: Passwords,
getTitle: () => (is_social_signup ? localize('Passwords') : localize('Email and passwords')),
getTitle: () => localize('Email and passwords'),
},
{
path: routes.self_exclusion,
Expand Down Expand Up @@ -147,9 +147,11 @@ let routesConfig;
// For default page route if page/path is not found, must be kept at the end of routes_config array
const route_default = { component: Page404, getTitle: () => localize('Error 404') };

const getRoutesConfig = ({ is_appstore }, is_social_signup) => {
routesConfig = initRoutesConfig({ is_appstore }, is_social_signup);
routesConfig.push(route_default);
const getRoutesConfig = ({ is_appstore }) => {
if (!routesConfig) {
routesConfig = initRoutesConfig({ is_appstore });
routesConfig.push(route_default);
}
return routesConfig;
};

Expand Down
28 changes: 24 additions & 4 deletions packages/account/src/Sections/Security/Passwords/deriv-email.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Formik } from 'formik';
import { WS } from '@deriv/shared';
import { WS, toTitleCase } from '@deriv/shared';
import { Localize, localize } from '@deriv/translations';
import { Button, Text, Input } from '@deriv/components';
import FormSubHeader from 'Components/form-sub-header';
import SentEmailModal from 'Components/sent-email-modal';
import UnlinkAccountModal from 'Components/unlink-account-modal';

const DerivEmail = ({ email }) => {
const DerivEmail = ({ email, social_identity_provider, is_social_signup }) => {
const [is_unlink_account_modal_open, setIsUnlinkAccountModalOpen] = React.useState(false);
const [is_send_email_modal_open, setIsSendEmailModalOpen] = React.useState(false);

const onClickChangeEmail = () => {
// Todo: will add the condition to check if it's social account and wants to be unlinked
if (is_social_signup) {
setIsUnlinkAccountModalOpen(true);
} else {
WS.verifyEmail(email, 'request_email');
setIsSendEmailModalOpen(true);
}
};

const onClickSendEmail = () => {
WS.verifyEmail(email, 'request_email');
setIsUnlinkAccountModalOpen(false);
setIsSendEmailModalOpen(true);
};

Expand All @@ -38,7 +49,7 @@ const DerivEmail = ({ email }) => {
type='text'
name='email'
id={'email'}
label={localize('Email address')}
label={localize('Email address*')}
value={email}
disabled={true}
/>
Expand All @@ -56,6 +67,12 @@ const DerivEmail = ({ email }) => {
primary
/>
</div>
<UnlinkAccountModal
is_open={is_unlink_account_modal_open}
onClose={() => setIsUnlinkAccountModalOpen(false)}
identifier_title={toTitleCase(social_identity_provider)}
onClickSendEmail={onClickSendEmail}
/>
<SentEmailModal
is_open={is_send_email_modal_open}
onClose={() => setIsSendEmailModalOpen(false)}
Expand All @@ -71,6 +88,9 @@ const DerivEmail = ({ email }) => {

DerivEmail.propTypes = {
email: PropTypes.string,
is_dark_mode_on: PropTypes.bool,
is_social_signup: PropTypes.bool,
social_identity_provider: PropTypes.string,
};

export default DerivEmail;
55 changes: 13 additions & 42 deletions packages/account/src/Sections/Security/Passwords/deriv-password.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ import { getBrandWebsiteName, getPlatformSettings, toTitleCase, WS } from '@deri
import { Localize, localize } from '@deriv/translations';
import FormSubHeader from 'Components/form-sub-header';
import SentEmailModal from 'Components/sent-email-modal';
import UnlinkModal from 'Components/unlink-modal';
import DerivComLogo from 'Assets/ic-brand-deriv-red.svg';
import DerivGoLight from 'Assets/ic-brand-deriv-go-light.svg';
import DerivGoDark from 'Assets/ic-brand-deriv-go-dark.svg';

const DerivPassword = ({ email, is_dark_mode_on, is_social_signup, social_identity_provider }) => {
const [is_unlink_modal_open, setIsUnlinkModalOpen] = React.useState(false);
const [is_sent_email_modal_open, setIsSentEmailModalOpen] = React.useState(false);

const onClickSendEmail = () => {
WS.verifyEmail(email, 'reset_password');
setIsUnlinkModalOpen(false);
if (social_identity_provider === 'apple') {
WS.verifyEmail(email, 'request_email');
} else {
WS.verifyEmail(email, 'reset_password');
}
setIsSentEmailModalOpen(true);
};

Expand Down Expand Up @@ -46,7 +47,10 @@ const DerivPassword = ({ email, is_dark_mode_on, is_social_signup, social_identi
/>
</Text>
<Text as='p' className='passwords-platform__desc' color='prominent' size='xs' weight='lighter'>
<Localize i18n_default_text='Apps you can use with your Deriv login:' />
<Localize
i18n_default_text='Apps you have linked to your <0>Deriv password:</0>'
components={[<strong key={0} />]}
/>
</Text>
<div className='passwords-platform__logo-container'>
<DerivComLogo className='passwords-platform__single-icon' />
Expand All @@ -72,46 +76,22 @@ const DerivPassword = ({ email, is_dark_mode_on, is_social_signup, social_identi
{is_social_signup ? (
<React.Fragment>
<div className='account__passwords-item passwords-social-buttons'>
<div className='passwords-social-buttons__desc'>
<Text
as='p'
className='passwords-platform__desc'
color='prominent'
size='xs'
weight='lighter'
>
<Localize
i18n_default_text="You're using your {{identifier_title}} account to log in to your Deriv account. To change your login method into using a username and password, click the <0>Unlink</0> button."
components={[<strong key={0} />]}
values={{ identifier_title: capitalized_identifier }}
/>
</Text>
</div>
<div className='account__passwords-linked'>
<div className='account__passwords-linked' onClick={onClickSendEmail}>
{social_identity_provider ? (
<React.Fragment>
<Icon icon={`IcStock${capitalized_identifier}`} size={16} />
<Text size='xs'>
<Localize
i18n_default_text='Linked with {{identifier_title}}'
i18n_default_text='Unlink from {{identifier_title}}'
values={{ identifier_title: capitalized_identifier }}
/>
</Text>
<Icon icon='IcChevronRight' size={16} />
</React.Fragment>
) : (
''
)}
</div>
<Button
onClick={() => {
setIsUnlinkModalOpen(true);
setIsSentEmailModalOpen(true);
}}
type='button'
text={localize('Unlink')}
tertiary
large
/>
</div>
</React.Fragment>
) : (
Expand All @@ -133,17 +113,8 @@ const DerivPassword = ({ email, is_dark_mode_on, is_social_signup, social_identi
/>
</div>
)}
<UnlinkModal
is_open={is_unlink_modal_open}
onClose={() => {
setIsUnlinkModalOpen(false);
setIsSentEmailModalOpen(false);
}}
identifier_title={capitalized_identifier}
onClickSendEmail={onClickSendEmail}
/>
<SentEmailModal
is_open={is_sent_email_modal_open && !is_unlink_modal_open}
is_open={is_sent_email_modal_open}
onClose={() => setIsSentEmailModalOpen(false)}
identifier_title={capitalized_identifier}
onClickSendEmail={onClickSendEmail}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ const Passwords = ({

return (
<div className='account__passwords'>
{/* Todo: remove the condition after unlinking the email with social account is fully functional */}
{!is_social_signup && <DerivEmail email={email} />}
<DerivEmail
email={email}
social_identity_provider={social_identity_provider}
is_social_signup={is_social_signup}
/>
<DerivPassword
email={email}
is_dark_mode_on={is_dark_mode_on}
Expand Down
Loading