Skip to content

Commit

Permalink
Merge branch 'master' of github.com:binary-com/deriv-app into Jim/WEB…
Browse files Browse the repository at this point in the history
…REL-890/p2p-chat-messages-are-disappearing-when-shifting-the-tabs-and-chat-page-is-breaking
  • Loading branch information
jim-deriv committed Aug 3, 2023
2 parents a1c61c2 + 7b2134d commit 7fdba2d
Show file tree
Hide file tree
Showing 33 changed files with 724 additions and 372 deletions.
3 changes: 1 addition & 2 deletions packages/components/src/components/u-i-loader/ui-loader.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from 'react';
import classNames from 'classnames';
import Loadable from 'react-loadable';

type TUILoader = {
className?: string;
classNameBlock?: string;
} & Loadable.LoadingComponentProps;
};

const UILoader = ({ className, classNameBlock }: TUILoader) => {
const block_class = classNames(classNameBlock, 'block-ui');
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/App/Containers/Modals/app-modals.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { useLocation } from 'react-router-dom';
import { ContentFlag, moduleLoader } from '@deriv/shared';
import { connect } from 'Stores/connect';
import MT5Notification from './mt5-notification';
import MT5AccountNeededModal from 'App/Components/Elements/Modals/mt5-account-needed-modal.jsx';
import RedirectNoticeModal from 'App/Components/Elements/Modals/RedirectNotice';
import CooldownWarningModal from './cooldown-warning-modal.jsx';
Expand All @@ -18,6 +19,7 @@ const AccountSignupModal = React.lazy(() =>
const AcuityDownloadModal = React.lazy(() =>
import(/* webpackChunkName: "acuity-download-modal" */ '../AcuityDownloadModal')
);

const CloseMxMltAccountModal = React.lazy(() =>
moduleLoader(() => import(/* webpackChunkName: "close-mx-mlt-account-modal" */ '../CloseMxMltAccountModal'))
);
Expand Down Expand Up @@ -73,6 +75,7 @@ const AppModals = ({
fetchFinancialAssessment,
setCFDScore,
content_flag,
is_mt5_notificaiton_modal_visible,
active_account_landing_company,
is_deriv_account_needed_modal_visible,
is_warning_scam_message_modal_visible,
Expand Down Expand Up @@ -148,6 +151,8 @@ const AppModals = ({
ComponentToLoad = <RealityCheckModal />;
} else if (should_show_cooldown_modal) {
ComponentToLoad = <CooldownWarningModal />;
} else if (is_mt5_notificaiton_modal_visible) {
ComponentToLoad = <MT5Notification />;
} else if (should_show_assessment_complete_modal) {
ComponentToLoad = <CompletedAssessmentModal />;
} else if (is_deriv_account_needed_modal_visible) {
Expand Down Expand Up @@ -184,6 +189,7 @@ export default connect(({ client, ui, traders_hub }) => ({
is_reality_check_visible: client.is_reality_check_visible,
has_maltainvest_account: client.has_maltainvest_account,
fetchFinancialAssessment: client.fetchFinancialAssessment,
is_mt5_notificaiton_modal_visible: traders_hub.is_mt5_notificaiton_modal_visible,
setCFDScore: client.setCFDScore,
setShouldShowVerifiedAccount: ui.setShouldShowVerifiedAccount,
should_show_cooldown_modal: ui.should_show_cooldown_modal,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import MT5Notification from './mt5-notification';
import './mt5-notification.scss';

export default MT5Notification;
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React from 'react';
import { Text } from '@deriv/components';
import { Localize } from '@deriv/translations';

const MT5NotificationDescription = () => {
return (
<div className={'mt5-notification-modal-description'}>
<Text as='p' size='xs'>
<Localize i18n_default_text='Follow these simple steps to fix it:' />
</Text>
<ol className='mt5-notification-list-container'>
<li className='mt5-notification-list-container-item'>
<Text as='p' size='xs'>
<Localize i18n_default_text='On your MT5 mobile app, delete your existing Deriv account:' />
</Text>
<ul>
<li className='mt5-notification-list'>
<Text as='p' size='xs'>
<Localize
i18n_default_text='- iOS: Swipe left on the account and tap <0>Delete</0>.'
components={[<strong key={0} />]}
/>
</Text>
</li>
<li className='mt5-notification-list'>
<Text as='p' size='xs'>
<Localize
i18n_default_text='- Android: Tap the account, open <0>Options</0>, and tap <0>Delete</0>.'
components={[<strong key={0} />]}
/>
</Text>
</li>
</ul>
</li>
<li className='mt5-notification-list-container-item'>
<Text as='p' size='xs'>
<Localize
i18n_default_text='Search for the broker <0>Deriv Holdings (Guernsey) Limited</0> and select it.'
components={[<strong key={0} />]}
/>
</Text>
</li>
<li className='mt5-notification-list-container-item'>
<Text as='p' size='xs'>
<Localize i18n_default_text='Re-add your MT5 account using the same log in credentials.' />
</Text>
</li>
</ol>
<Text as='p' size='xs'>
<Localize
i18n_default_text='If this doesn’t work, uninstall and re-install the MT5 app. Then redo steps <0>2</0> and <0>3</0>.'
components={[<strong key={0} />]}
/>
</Text>
<Text as='p' size='xs' className='mt5-notification-list-contact'>
<Localize i18n_default_text='Need more help? Contact us through live chat for assistance.' />
</Text>
</div>
);
};

export default MT5NotificationDescription;
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.mt5-notification-modal {
&-body {
border-top: 2px solid #f2f3f4;
}
@include mobile {
&-description {
margin: 2rem;
&--button {
display: flex;
width: 100%;
}
&--footer {
padding: 1rem 1.6rem;
}
}
}
}
.mt5-notification-list {
list-style: none;
&-container {
list-style: auto;
padding: 1.5rem;
font-size: 1.6rem;
color: var(--text-general);
&-item {
list-style: decimal;
}
}
&-contact {
margin-top: 1rem;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React from 'react';
import { observer, useStore } from '@deriv/stores';
import { Modal, DesktopWrapper, MobileDialog, MobileWrapper, UILoader, Button } from '@deriv/components';
import { localize } from '@deriv/translations';
import MT5NotificationDescription from './mt5-notification-description';

const MT5Notification = observer(() => {
const { traders_hub } = useStore();
const { setMT5NotificationModal, is_mt5_notificaiton_modal_visible } = traders_hub;
const clickHandler = () => {
setMT5NotificationModal(!is_mt5_notificaiton_modal_visible);
};

return (
<React.Suspense fallback={<UILoader />}>
<DesktopWrapper>
<Modal
has_close_icon={false}
is_open={is_mt5_notificaiton_modal_visible}
title={localize('Trouble accessing Deriv MT5 on your mobile?')}
toggleModal={clickHandler}
className='mt5-notification-modal'
height='455px'
width='510px'
>
<Modal.Body className='mt5-notification-modal-body'>
<MT5NotificationDescription />
</Modal.Body>
<Modal.Footer has_separator>
<Button
primary
onClick={() => {
setMT5NotificationModal(false);
}}
>
{localize('OK')}
</Button>
</Modal.Footer>
</Modal>
</DesktopWrapper>
<MobileWrapper>
<MobileDialog
portal_element_id='modal_root'
wrapper_classname='mt5-notification-modal-description'
title={localize('Trouble accessing Deriv MT5 on your mobile?')}
visible={is_mt5_notificaiton_modal_visible}
onClose={() => {
setMT5NotificationModal(false);
}}
has_full_height
has_close_icon={false}
footer={
<div className='mt5-notification-modal-description--footer'>
<Button
className='mt5-notification-modal-description--button'
primary
onClick={() => setMT5NotificationModal(false)}
>
{localize('OK')}
</Button>
</div>
}
>
<MT5NotificationDescription />
</MobileDialog>
</MobileWrapper>
</React.Suspense>
);
});

export default MT5Notification;
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ const AppNotificationMessages = ({
'tnc',
'trustpilot',
'unwelcome',
'mt5_notification',
].includes(message.key) || message.type === 'p2p_completed_order'
: true;

Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/Stores/Helpers/client-notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,10 @@ export const getCashierValidations = cashier_arr => {
// Notifications keys will not be added to localStorage and will appear again after user logout/login
export const excluded_notifications = ['contract_sold', 'switched_to_real', 'has_changed_two_fa'];

export const priority_toast_messages = ['svg', 'need_fa', 'p2p_daily_limit_increase', 'authenticate'];
export const priority_toast_messages = [
'svg',
'need_fa',
'p2p_daily_limit_increase',
'authenticate',
'mt5_notification',
];
16 changes: 16 additions & 0 deletions packages/core/src/Stores/notification-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,9 @@ export default class NotificationStore extends BaseStore {
this.addNotificationMessage(this.client_notifications.svg_poi_expired);
}
}
if (client && this.root_store.client.mt5_login_list.length > 0) {
this.addNotificationMessage(this.client_notifications.mt5_notification);
}
}

if (!is_eu && isMultiplierContract(selected_contract_type) && current_language === 'EN' && is_logged_in) {
Expand Down Expand Up @@ -704,6 +707,7 @@ export default class NotificationStore extends BaseStore {
setClientNotifications(client_data = {}) {
const { ui } = this.root_store;
const { has_enabled_two_fa, setTwoFAChangedStatus } = this.root_store.client;
const { setMT5NotificationModal } = this.root_store.traders_hub;
const two_fa_status = has_enabled_two_fa ? localize('enabled') : localize('disabled');
const mx_mlt_custom_header = this.custom_notifications.mx_mlt_notification.header();
const mx_mlt_custom_content = this.custom_notifications.mx_mlt_notification.main();
Expand Down Expand Up @@ -1482,6 +1486,18 @@ export default class NotificationStore extends BaseStore {
text: localize('Submit proof of identity'),
},
},
mt5_notification: {
key: 'mt5_notification',
header: localize('Trouble accessing Deriv MT5 on your mobile?'),
message: localize('Follow these simple instructions to fix it.'),
action: {
text: localize('Learn more'),
onClick: () => {
setMT5NotificationModal(true);
},
},
type: 'warning',
},
};

this.client_notifications = notifications;
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/Stores/traders-hub-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default class TradersHubStore extends BaseStore {
is_onboarding_visited = false;
is_failed_verification_modal_visible = false;
is_regulators_compare_modal_visible = false;
is_mt5_notificaiton_modal_visible = false;
is_tour_open = false;
is_account_type_modal_visible = false;
account_type_card = '';
Expand All @@ -43,6 +44,7 @@ export default class TradersHubStore extends BaseStore {
is_account_transfer_modal_open: observable,
is_account_type_modal_visible: observable,
is_regulators_compare_modal_visible: observable,
is_mt5_notificaiton_modal_visible: observable,
is_failed_verification_modal_visible: observable,
is_tour_open: observable,
modal_data: observable,
Expand Down Expand Up @@ -89,6 +91,7 @@ export default class TradersHubStore extends BaseStore {
closeAccountTransferModal: action.bound,
toggleAccountTypeModalVisibility: action.bound,
setIsOnboardingVisited: action.bound,
setMT5NotificationModal: action.bound,
toggleFailedVerificationModalVisibility: action.bound,
openFailedVerificationModal: action.bound,
toggleIsTourOpen: action.bound,
Expand Down Expand Up @@ -331,6 +334,10 @@ export default class TradersHubStore extends BaseStore {
this.is_regulators_compare_modal_visible = !this.is_regulators_compare_modal_visible;
}

setMT5NotificationModal(is_visible) {
this.is_mt5_notificaiton_modal_visible = is_visible;
}

get has_any_real_account() {
return this.selected_account_type === 'real' && this.root_store.client.has_active_real_account;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/p2p/src/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@
"-1717650468": "Онлайн",
"-510341549": "Я получил(а) меньше оговоренной суммы.",
"-650030360": "Я заплатил(а) больше оговоренной суммы.",
"-1192446042": "Если вашей проблемы нет в этом списке, свяжитесь с нашей Службой поддержки клиентов.",
"-1192446042": "Если вашей проблемы нет в этом списке, свяжитесь с нашей службой поддержки клиентов.",
"-573132778": "Жалоба",
"-792338456": "Что случилось?",
"-418870584": "Отменить ордер",
Expand Down
2 changes: 2 additions & 0 deletions packages/stores/src/mockStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ const mock = (): TStores & { is_mock: boolean } => {
setTogglePlatformType: jest.fn(),
toggleAccountTransferModal: jest.fn(),
selectAccountType: jest.fn(),
is_mt5_notificaiton_modal_visible: false,
setMT5NotificationModal: jest.fn(),
},
menu: {
attach: jest.fn(),
Expand Down
2 changes: 2 additions & 0 deletions packages/stores/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ type TTradersHubStore = {
platform_demo_balance: TBalance;
cfd_real_balance: TBalance;
selectAccountType: (account_type: string) => void;
is_mt5_notificaiton_modal_visible: boolean;
setMT5NotificationModal: (value: boolean) => void;
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const ChartSettingContainer = Loadable({
import(
/* webpackChunkName: "settings-chart", webpackPrefetch: true */ 'App/Containers/SettingsModal/settings-chart.jsx'
),
loading: UILoader,
loading: () => <UILoader />,
});

// const PurchaseSettings = Loadable({
Expand Down
2 changes: 1 addition & 1 deletion packages/translations/crowdin/messages.json

Large diffs are not rendered by default.

Loading

0 comments on commit 7fdba2d

Please sign in to comment.