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

carol/ P2P: Email verification for orders #6299

Merged
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
1eba58b
Merge branch 'master' of github.com:binary-com/deriv-app
Apr 14, 2022
086058c
Merge branch 'master' of github.com:binary-com/deriv-app
Apr 20, 2022
ba5e87e
Merge branch 'master' of github.com:binary-com/deriv-app
Apr 22, 2022
95b8ec8
Merge branch 'master' of github.com:binary-com/deriv-app
May 27, 2022
a12090f
Merge branch 'master' of github.com:binary-com/deriv-app
Jun 8, 2022
d7d17cc
Merge branch 'master' of github.com:binary-com/deriv-app
Jun 9, 2022
be7c7bb
Merge branch 'master' of github.com:binary-com/deriv-app
Jun 10, 2022
f60d6c2
Merge branch 'master' of github.com:binary-com/deriv-app
Jun 16, 2022
f28f08d
Merge branch 'master' of github.com:binary-com/deriv-app
Jun 21, 2022
da2aaf6
Merge branch 'master' of github.com:binary-com/deriv-app
Jun 22, 2022
6d9113c
Merge branch 'master' of github.com:binary-com/deriv-app
Jun 27, 2022
4244c91
Merge branch 'master' of github.com:binary-com/deriv-app
Jul 4, 2022
b3f8906
Merge branch 'master' of github.com:binary-com/deriv-app
Jul 7, 2022
6f3aea9
Merge branch 'master' of github.com:binary-com/deriv-app
Jul 12, 2022
cb70bf6
Merge branch 'master' of github.com:binary-com/deriv-app
Aug 1, 2022
b39bc60
Merge branch 'master' of github.com:binary-com/deriv-app
Aug 11, 2022
7947c41
pull master
Aug 11, 2022
47b96e9
Merge branch 'p2p-2fa-feature' of github.com:binary-com/deriv-app int…
Aug 17, 2022
aa2fa7a
fix: quotes
Aug 18, 2022
ee369b5
add: email verification
Aug 25, 2022
b1ec2e0
fix: conflicts (finalllyyyyyyyyy)
Aug 26, 2022
c6ab1d3
cleanup
Aug 26, 2022
a970958
don't kill me
Aug 26, 2022
ffbd0fb
add response checks
Aug 29, 2022
39e65a4
add comment
Aug 29, 2022
b71d0a1
add: amount + currency
Aug 31, 2022
258eed8
fixed loading of order details and chat
farrah-deriv Aug 31, 2022
86a1edd
fixed design on responsive
farrah-deriv Aug 31, 2022
f876093
fix: conflicts
Sep 1, 2022
b61c49c
Merge pull request #60 from farrah-deriv/order-chat-fix
carolsachdeva Sep 1, 2022
8b1eebb
Merge pull request #61 from farrah-deriv/verification-modal-responsive
carolsachdeva Sep 1, 2022
ae5fbe0
fixed verification modal in responsive
farrah-deriv Sep 1, 2022
b2e6e16
Merge pull request #62 from farrah-deriv/scrollable-verification-modal
carolsachdeva Sep 1, 2022
b00ea45
show modal if error
Sep 1, 2022
0d76901
Merge branch 'email-verification' of github.com:carol-binary/deriv-ap…
Sep 1, 2022
22c616f
fix
Sep 1, 2022
7b6a28a
fixed truncated modal in ios
farrah-deriv Sep 1, 2022
59aa866
Merge pull request #63 from farrah-deriv/email-verification-modal
carolsachdeva Sep 1, 2022
d7fd8d0
fix time
Sep 2, 2022
78e1062
fix invalid verification modal
Sep 2, 2022
4c52cfc
Merge branch 'email-verification' of github.com:carol-binary/deriv-ap…
Sep 2, 2022
2fc9896
fix
Sep 2, 2022
e6d6f03
fix
Sep 2, 2022
feb224f
fixed verification modal in desktop
farrah-deriv Sep 2, 2022
27b55a1
Merge pull request #64 from farrah-deriv/verification-modal-desktop
carolsachdeva Sep 2, 2022
368d364
Merge branch 'email-verification' of github.com:carol-binary/deriv-ap…
Sep 2, 2022
d0c04c3
fix responsive +logged out user
Sep 2, 2022
531c055
fixed a lot of stuff that broke lol
Sep 5, 2022
8b6c4a6
fix: design for seller
Sep 5, 2022
3453a68
the solution to all my problems
Sep 5, 2022
2c117fc
fix: modal
Sep 6, 2022
0ebded0
fix logout + modal
Sep 6, 2022
04f4d0e
hide extra modal
Sep 6, 2022
28dfc51
i got 99 problems and 2fa is all of em
Sep 6, 2022
fb5cd3e
fix
Sep 6, 2022
1a23f9f
fix
Sep 7, 2022
0d3b576
fix: amount
Sep 7, 2022
9d48faa
fix: amount
Sep 7, 2022
0eeac0e
fix: add modal
Sep 7, 2022
1b106a4
fix: rating modal
Sep 7, 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
27 changes: 21 additions & 6 deletions packages/cashier/src/pages/p2p-cashier/p2p-cashier.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ const P2PCashier = ({
setOnRemount,
}) => {
const [order_id, setOrderId] = React.useState(null);
const [action_param, setActionParam] = React.useState();
const [code_param, setCodeParam] = React.useState();

const server_time = {
get,
init,
Expand All @@ -42,7 +45,16 @@ const P2PCashier = ({

React.useEffect(() => {
const url_params = new URLSearchParams(location.search);
const passed_order_id = url_params.get('order');
let passed_order_id;

setActionParam(url_params.get('action'));
setCodeParam(url_params.get('code'));

if (url_params.has('order_id')) {
passed_order_id = url_params.get('order_id');
} else if (url_params.has('order')) {
passed_order_id = url_params.get('order');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between order and order_id? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different email links give us different verification_code, for this one it's order_id and it's what works for mobile.

}

if (passed_order_id) {
setQueryOrder(passed_order_id);
Expand All @@ -55,8 +67,9 @@ const P2PCashier = ({
input_order_id => {
const current_query_params = new URLSearchParams(location.search);

if (current_query_params.has('order')) {
if (current_query_params.has('order_id') || current_query_params.has('order')) {
current_query_params.delete('order');
current_query_params.delete('order_id');
}

if (input_order_id) {
Expand Down Expand Up @@ -91,8 +104,9 @@ const P2PCashier = ({
return (
<P2P
addNotificationMessage={addNotificationMessage}
client={{ currency, local_currency_config, is_virtual, residence, loginid }}
balance={balance}
client={{ currency, local_currency_config, is_virtual, residence, loginid }}
current_focus={current_focus}
filterNotificationMessages={filterNotificationMessages}
history={history}
is_dark_mode_on={is_dark_mode_on}
Expand All @@ -107,13 +121,14 @@ const P2PCashier = ({
removeNotificationByKey={removeNotificationByKey}
removeNotificationMessage={removeNotificationMessage}
server_time={server_time}
setCurrentFocus={setCurrentFocus}
setNotificationCount={setNotificationCount}
setOnRemount={setOnRemount}
setOrderId={setQueryOrder}
setOnRemount={setOnRemount}
should_show_verification={/verification/.test(location.hash)}
verification_action={action_param}
verification_code={code_param}
websocket_api={WS}
current_focus={current_focus}
setCurrentFocus={setCurrentFocus}
/>
);
};
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/App/Containers/Redirect/redirect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ const Redirect = ({
redirected_to_route = true;
break;
}
case 'p2p_order_confirm': {
history.push({
pathname: routes.cashier_p2p,
search: url_query_string,
});
redirected_to_route = true;
break;
}

default:
break;
Expand Down
2 changes: 1 addition & 1 deletion packages/p2p/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
'/crowdin/',
// TODO: Update the test files once the major features are done
// This is a temporary change, I hope
'/src/components/order-details/',
'/src/components/order*',
],
coveragePathIgnorePatterns: [
'<rootDir>/.eslintrc.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import { Icon, Modal, Text } from '@deriv/components';
import { Localize } from 'Components/i18next';

const EmailLinkBlockedModal = ({
blocked_for_minutes,
// TODO: Uncomment when time is available in BE response
// blocked_for_minutes,
email_link_blocked_modal_error_message,
is_email_link_blocked_modal_open,
setIsEmailLinkBlockedModalOpen,
}) => {
return (
<Modal
has_close_icon
is_open={is_email_link_blocked_modal_open}
title=''
renderTitle={() => <></>}
toggleModal={() => setIsEmailLinkBlockedModalOpen(false)}
width='440px'
>
Expand All @@ -22,18 +24,17 @@ const EmailLinkBlockedModal = ({
<Localize i18n_default_text='Too many failed attempts' />
</Text>
<Text align='center' color='prominent' size='s'>
<Localize
i18n_default_text='We have temporarily blocked your request after too many failed attempts. Please try again after {{blocked_for_minutes}} minutes.'
values={{ blocked_for_minutes }}
/>
{email_link_blocked_modal_error_message}
</Text>
</Modal.Body>
</Modal>
);
};

EmailLinkBlockedModal.propTypes = {
blocked_for_minutes: PropTypes.number,
// TODO: Uncomment when time is available in BE response
// blocked_for_minutes: PropTypes.number,
email_link_blocked_modal_error_message: PropTypes.string,
is_email_link_blocked_modal_open: PropTypes.bool,
setIsEmailLinkBlockedModalOpen: PropTypes.func,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { Localize } from 'Components/i18next';
const EmailLinkVerifiedModal = ({
amount,
currency,
is_email_verified_modal_open,
is_email_link_verified_modal_open,
onClickConfirm,
setIsEmailLinkVerifiedModalOpen,
}) => {
return (
<Modal
has_close_icon
is_open={is_email_verified_modal_open}
title=''
is_open={is_email_link_verified_modal_open}
renderTitle={() => <></>}
toggleModal={() => setIsEmailLinkVerifiedModalOpen(false)}
width='440px'
>
Expand All @@ -31,7 +31,14 @@ const EmailLinkVerifiedModal = ({
</Text>
</Modal.Body>
<Modal.Footer className='email-verified-modal--footer'>
<Button large primary onClick={onClickConfirm}>
<Button
large
primary
onClick={() => {
setIsEmailLinkVerifiedModalOpen(false);
onClickConfirm();
}}
>
<Localize i18n_default_text='Confirm' />
</Button>
</Modal.Footer>
Expand All @@ -42,7 +49,7 @@ const EmailLinkVerifiedModal = ({
EmailLinkVerifiedModal.propTypes = {
amount: PropTypes.number,
currency: PropTypes.string,
is_email_verified_modal_open: PropTypes.bool,
is_email_link_verified_modal_open: PropTypes.bool,
onClickConfirm: PropTypes.func,
setIsEmailLinkVerifiedModalOpen: PropTypes.func,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Button, Icon, Loading, Modal, Text } from '@deriv/components';
import { Button, Icon, Modal, Text } from '@deriv/components';
import { Localize } from 'Components/i18next';

const EmailVerificationModal = ({
email_address,
is_email_verification_modal_open,
is_verifying = false,
onClickResendEmailButton,
remaining_time,
setIsEmailVerificationModalOpen,
should_show_resend_email_button = false,
verification_link_expiry_time,
should_show_resend_email_button = true,
// TODO: Uncomment when time is available in BE response
// remaining_time,
// verification_link_expiry_time,
}) => {
const [should_show_reasons_if_no_email, setShouldShowReasonsIfNoEmail] = React.useState(false);

if (is_verifying) {
return (
<Modal has_close_icon={false} small width='440px'>
<Loading is_fullscreen={false} />
</Modal>
);
}

return (
<Modal
has_close_icon
is_open={is_email_verification_modal_open}
title=''
renderTitle={() => <></>}
toggleModal={() => setIsEmailVerificationModalOpen(false)}
width='440px'
>
Expand All @@ -47,10 +39,8 @@ const EmailVerificationModal = ({
/>
</Text>
<Text color='prominent' size='s'>
<Localize
i18n_default_text='The verification link expires in {{verification_link_expiry_time}} minutes'
values={{ verification_link_expiry_time }}
/>
{/* TODO: Uncomment when time is available in BE response */}
<Localize i18n_default_text='The verification link expires in 10 minutes' />
</Text>
<Text
className='email-verification-modal--receive_email_text'
Expand Down Expand Up @@ -84,16 +74,18 @@ const EmailVerificationModal = ({
<div className='email-verification-modal--reason'>
<Icon icon='IcEmailFirewall' size={36} />
<Text className='email-verification-modal--reason__text' color='prominent' size='xxs'>
<Localize i18n_default_text='We cant deliver the email to this address (usually because of firewalls or filtering).' />
<Localize i18n_default_text="We can't deliver the email to this address (usually because of firewalls or filtering)." />
</Text>
</div>
</React.Fragment>
)}
</Modal.Body>
{should_show_resend_email_button && (
{should_show_resend_email_button && should_show_reasons_if_no_email && (
<Modal.Footer>
<Button large primary onClick={onClickResendEmailButton}>
<Localize i18n_default_text='Resend email {{remaining_time}}' values={{ remaining_time }} />
<Localize i18n_default_text='Resend email' />
{/* TODO: Uncomment when time is available in BE response
<Localize i18n_default_text='Resend email {{remaining_time}}' values={{ remaining_time }} /> */}
</Button>
</Modal.Footer>
)}
Expand All @@ -106,10 +98,12 @@ EmailVerificationModal.propTypes = {
is_email_verification_modal_open: PropTypes.bool,
is_verifying: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also remove is_verifying here

onClickResendEmailButton: PropTypes.func,
remaining_time: PropTypes.string,
// TODO: Uncomment when time is available in BE response
// remaining_time: PropTypes.string,
setIsEmailVerificationModalOpen: PropTypes.func,
should_show_resend_email_button: PropTypes.bool,
verification_link_expiry_time: PropTypes.number,
// TODO: Uncomment when time is available in BE response
// verification_link_expiry_time: PropTypes.number,
};

export default EmailVerificationModal;
24 changes: 24 additions & 0 deletions packages/p2p/src/components/error-modal/error-modal.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Button, Modal } from '@deriv/components';
import { Localize } from 'Components/i18next';

const ErrorModal = ({ error_message, error_modal_title, is_error_modal_open, setIsErrorModalOpen }) => {
return (
<Modal is_open={is_error_modal_open} title={error_modal_title}>
<Modal.Body>{error_message}</Modal.Body>
<Modal.Footer>
<Button large primary onClick={() => setIsErrorModalOpen(false)}>
<Localize i18n_default_text='Ok' />
</Button>
</Modal.Footer>
</Modal>
);
};

ErrorModal.propTypes = {
error_message: PropTypes.string,
error_modal_title: PropTypes.string,
is_error_modal_open: PropTypes.bool,
setIsErrorModalOpen: PropTypes.func,
};
3 changes: 3 additions & 0 deletions packages/p2p/src/components/error-modal/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ErrorModal from './error-modal.jsx';

export default ErrorModal;
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import { Button, Icon, Modal, Text } from '@deriv/components';
import { Localize } from 'Components/i18next';

const InvalidVerificationLinkModal = ({
invalid_verification_link_error_message,
is_invalid_verification_link_modal_open,
onClickGetNewLinkButton,
setIsInvalidVerificationLinkModalOpen,
verification_link_expiry_time,
// TODO: Uncomment when time is available in BE response
// verification_link_expiry_time,
}) => {
return (
<Modal
has_close_icon
is_open={is_invalid_verification_link_modal_open}
title=''
renderTitle={() => <></>}
toggleModal={() => setIsInvalidVerificationLinkModalOpen(false)}
width='440px'
>
Expand All @@ -23,14 +25,18 @@ const InvalidVerificationLinkModal = ({
<Localize i18n_default_text='Invalid verification link' />
</Text>
<Text align='center' color='prominent' size='s'>
<Localize
i18n_default_text='The verification link becomes invalid after {{verification_link_expiry_time}} minutes. Hit the button below to request a new one.'
values={{ verification_link_expiry_time }}
/>
{invalid_verification_link_error_message}
</Text>
</Modal.Body>
<Modal.Footer className='invalid-verification-link-modal--footer'>
<Button large primary onClick={onClickGetNewLinkButton}>
<Button
large
primary
onClick={() => {
setIsInvalidVerificationLinkModalOpen(false);
onClickGetNewLinkButton();
}}
>
<Localize i18n_default_text='Get new link' />
</Button>
</Modal.Footer>
Expand All @@ -39,10 +45,12 @@ const InvalidVerificationLinkModal = ({
};

InvalidVerificationLinkModal.propTypes = {
invalid_verification_link_error_message: PropTypes.string,
is_invalid_verification_link_modal_open: PropTypes.bool,
onClickGetNewLinkButton: PropTypes.func,
setIsInvalidVerificationLinkModalOpen: PropTypes.func,
verification_link_expiry_time: PropTypes.number,
// TODO: Uncomment when time is available in BE response
// verification_link_expiry_time: PropTypes.number,
};

export default InvalidVerificationLinkModal;
3 changes: 3 additions & 0 deletions packages/p2p/src/components/loading-modal/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import LoadingModal from './loading-modal.jsx';

export default LoadingModal;
17 changes: 17 additions & 0 deletions packages/p2p/src/components/loading-modal/loading-modal.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Loading, Modal } from '@deriv/components';

const LoadingModal = ({ is_loading_modal_open }) => {
return (
<Modal has_close_icon={false} is_open={is_loading_modal_open} small width='440px'>
<Loading is_fullscreen={false} />
</Modal>
);
};

LoadingModal.propTypes = {
is_loading_modal_open: PropTypes.bool,
};

export default LoadingModal;
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,8 @@ const OrderDetailsConfirmModal = ({
large
onClick={() => {
hideConfirmOrderModal();
order_store.confirmOrderRequest(id);
if (!is_buy_order_for_user) {
clearTimeout(wait);

const wait = setTimeout(() => {
order_store.setIsRatingModalOpen(true);
}, 250);
}
setIsCheckboxChecked(false);
order_store.confirmOrderRequest(id, is_buy_order_for_user);
}}
>
{is_buy_order_for_user ? (
Expand Down
Loading