Skip to content

Commit

Permalink
Merge pull request #5 from ali-hosseini-fs/poa-poi-notifications
Browse files Browse the repository at this point in the history
Ako/ Poa and Poi notifications
  • Loading branch information
Ali(Ako) Hosseini committed Nov 2, 2021
2 parents 6fd79ba + b33dbbd commit 1cac6c5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { EXPERIAN, getExperianResult } from './helpers/constants';
import { DialogHeading } from './helpers/dialog-heading.jsx';
import { DialogMessage } from './helpers/dialog-message.jsx';
import { DialogButtons } from './helpers/dialog-buttons.jsx';
import { populateVerificationStatus } from '@deriv/account';
import { clientNotifications } from '../../../Stores/Helpers/client-notifications';

const MainIcon = ({ currency }) => <Icon icon={`IcCurrency-${currency.toLowerCase()}`} size={120} />;
const Checkmark = ({ className }) => <Icon className={className} icon='IcCheckmarkCircle' color='green' size={24} />;
Expand All @@ -32,6 +34,8 @@ const StatusDialogContainer = ({
is_isle_of_man_residence,
landing_company_shortcode,
switchToVirtual,
account_status,
addNotificationMessage,
}) => {
const closeModalAndOpenCashier = () => {
closeModal();
Expand All @@ -47,6 +51,16 @@ const StatusDialogContainer = ({
closeModal();
history.push(routes.proof_of_address);
};
const closeModalAndAddProofsNotifications = () => {
const { has_poa, has_poi } = populateVerificationStatus(account_status);
if (!has_poi) {
addNotificationMessage(clientNotifications().verify_poi);
}
if (!has_poa) {
addNotificationMessage(clientNotifications().verify_poa);
}
closeModal();
};

/**
* Get the status for the current account
Expand Down Expand Up @@ -92,7 +106,7 @@ const StatusDialogContainer = ({
/>
</div>
<DialogButtons
closeModal={closeModal}
closeModal={closeModalAndAddProofsNotifications}
closeModalAndOpenPOI={closeModalAndOpenPOI}
closeModalAndOpenPOA={closeModalAndOpenPOA}
closeModalAndOpenCashier={closeModalAndOpenCashier}
Expand All @@ -118,7 +132,9 @@ StatusDialogContainer.propTypes = {
is_belgium_residence: PropTypes.bool,
};

export default connect(({ client }) => ({
export default connect(({ client, ui }) => ({
addNotificationMessage: ui.addNotificationMessage,
account_status: client.account_status,
country_standpoint: client.country_standpoint,
landing_company_shortcode: client.landing_company_shortcode,
is_fully_authenticated: client.is_fully_authenticated,
Expand Down
42 changes: 26 additions & 16 deletions packages/core/src/Stores/Helpers/client-notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { StaticUrl } from '@deriv/components';
import { localize, Localize } from '@deriv/translations';
import { BinaryLink } from 'App/Components/Routes';
import { WS } from 'Services';
import { populateVerificationStatus } from '@deriv/account';

// TODO: Update links to app_2 links when components are done.
/* eslint-disable react/jsx-no-target-blank */
Expand Down Expand Up @@ -129,17 +130,25 @@ export const clientNotifications = (ui = {}, client = {}) => {
type: 'warning',
};
},
authenticate: {
key: 'authenticate',
header: localize('Your account has not been verified'),
message: localize(
'Please submit your proof of identity and proof of address to verify your account in your account settings to access the cashier.'
),
verify_poi: {
key: 'verify_poi',
header: localize('Please verify your identity'),
message: localize('To continue trading with us, please confirm who you are.'),
action: {
route: routes.proof_of_identity,
text: localize('Go to my account settings'),
text: localize('Verify identity'),
},
type: 'warning',
type: 'danger',
},
verify_poa: {
key: 'verify_poa',
header: localize('Please verify your address'),
message: localize('To continue trading with us, please confirm where you live.'),
action: {
route: routes.proof_of_address,
text: localize('Verify address'),
},
type: 'danger',
},
withdrawal_locked_review: {
key: 'withdrawal_locked_review',
Expand Down Expand Up @@ -524,13 +533,8 @@ const checkAccountStatus = (
cashier_validation,
} = account_status;

const {
cashier_locked,
withdrawal_locked,
deposit_locked,
mt5_withdrawal_locked,
document_needs_action,
} = getStatusValidations(status);
const { cashier_locked, withdrawal_locked, deposit_locked, mt5_withdrawal_locked, document_needs_action } =
getStatusValidations(status);

const {
system_maintenance,
Expand Down Expand Up @@ -573,7 +577,13 @@ const checkAccountStatus = (
} else if (ASK_CURRENCY) {
addNotificationMessage(clientNotifications(ui_store).currency);
} else if (ASK_AUTHENTICATE) {
addNotificationMessage(clientNotifications().authenticate);
const { has_poi, has_poa } = populateVerificationStatus(account_status);
if (!has_poi) {
addNotificationMessage(clientNotifications().verify_poi);
}
if (!has_poa) {
addNotificationMessage(clientNotifications().verify_poa);
}
} else if (isAccountOfType('financial') && ASK_FINANCIAL_RISK_APPROVAL) {
addNotificationMessage(clientNotifications().ask_financial_risk_approval);
} else if (FinancialAssessmentRequired) {
Expand Down

0 comments on commit 1cac6c5

Please sign in to comment.