+
+ {message}
- )}
- toggleModal={() => setShouldShowPopup(false)}
- width={width}
- >
-
-
-
- {message}
-
-
-
- {({ field }) => (
-
- setFieldValue('need_confirmation', !values.need_confirmation)
- }
- defaultChecked={values.need_confirmation}
- label={localize("I've received {{amount}} {{currency}}.", {
- amount: order_information.amount * order_information.rate,
- currency: order_information.local_currency,
- })}
- classNameLabel='orders__popup-field_text'
- />
- )}
-
-
+
+
+ {({ field }) => (
+
+ setFieldValue('need_confirmation', !values.need_confirmation)
+ }
+ defaultChecked={values.need_confirmation}
+ label={localize("I've received {{amount}} {{currency}}.", {
+ amount: order_information.amount * order_information.rate,
+ currency: order_information.local_currency,
+ })}
+ classNameLabel='orders__popup-field_text'
+ />
+ )}
+
-
-
- {status?.error_message && }
-
- {has_cancel && (
-
- )}
-
+
+
+ {status?.error_message && }
+
+ {has_cancel && (
+
-
-
-
-
- )}
-
- );
- }
-);
+ )}
+
+
+
+
+
+ )}
+
+ );
+};
-const FormWithoutConfirmation = observer(
- ({
- cancel_text,
- className,
- confirm_text,
- has_cancel,
- message,
- onCancel,
- onClickConfirm,
- order_information,
- setShouldShowPopup,
- should_confirm_payment,
- should_show_popup,
- title,
- width,
- }) => {
- const [should_disable_confirm, setShouldDisableConfirm] = useSafeState(true);
- const [api_error_message, setApiErrorMessage] = useSafeState(null);
- const { general_store } = useStores();
+const FormWithoutConfirmation = ({
+ cancel_text,
+ className,
+ confirm_text,
+ has_cancel,
+ message,
+ onCancel,
+ onClickConfirm,
+ order_information,
+ setShouldShowPopup,
+ should_confirm_payment,
+ should_show_popup,
+ title,
+ width,
+}) => {
+ const [should_disable_confirm, setShouldDisableConfirm] = useSafeState(true);
+ const [api_error_message, setApiErrorMessage] = useSafeState(null);
- React.useEffect(() => {
- setApiErrorMessage(null);
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [should_show_popup]);
+ React.useEffect(() => {
+ setApiErrorMessage(null);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [should_show_popup]);
- return (
-
(
-
- {title}
+ return (
+ (
+
+ {title}
+
+ )}
+ toggleModal={() => setShouldShowPopup(false)}
+ width={width}
+ >
+
+
+
+ {message}
- )}
- toggleModal={() => setShouldShowPopup(false)}
- width={width}
- >
-
-
-
- {message}
-
- {should_confirm_payment && (
-
- setShouldDisableConfirm(!should_disable_confirm)}
- defaultChecked={!should_disable_confirm}
- label={localize('I have paid {{amount}} {{currency}}.', {
- amount: order_information.amount * order_information.rate,
- currency: order_information.local_currency,
- })}
- />
-
- )}
-
-
-
- {api_error_message?.error_message && }
-
- {has_cancel && (
-
- )}
-
+
+
+ {api_error_message?.error_message && }
+
+ {has_cancel && (
+
-
-
-
- );
- }
-);
+ )}
+
+
+
+
+ );
+};
const Popup = props => {
const { className, need_confirmation } = props;
diff --git a/packages/p2p/src/components/verification/verification.jsx b/packages/p2p/src/components/verification/verification.jsx
index abc3bbeb2c0e..e22da19d614b 100644
--- a/packages/p2p/src/components/verification/verification.jsx
+++ b/packages/p2p/src/components/verification/verification.jsx
@@ -47,7 +47,7 @@ const Verification = ({ should_wrap }) => {
general_store.poi_status === 'verified'
? () => {}
: () => {
- window.location.href = `${general_store.props.poi_url}?ext_platform_url=${routes.cashier_p2p}`;
+ window.location.href = `${routes.proof_of_identity}?ext_platform_url=${routes.cashier_p2p}`;
},
},
];
diff --git a/packages/p2p/src/stores/general-store.js b/packages/p2p/src/stores/general-store.js
index 222d1339377c..1ad4ea83a6c9 100644
--- a/packages/p2p/src/stores/general-store.js
+++ b/packages/p2p/src/stores/general-store.js
@@ -1,5 +1,6 @@
import React from 'react';
import { action, computed, observable, reaction, makeObservable } from 'mobx';
+import { get, init, timePromise } from '../../../cashier/src/utils/server_time';
import { isEmptyObject, isMobile, toMoment } from '@deriv/shared';
import BaseStore from 'Stores/base_store';
import { localize, Localize } from 'Components/i18next';
@@ -8,7 +9,7 @@ import { createExtendedOrderDetails } from 'Utils/orders';
import { init as WebsocketInit, requestWS, subscribeWS } from 'Utils/websocket';
import { order_list } from 'Constants/order-list';
import { buy_sell } from 'Constants/buy-sell';
-import { api_error_codes } from '../constants/api-error-codes';
+import { api_error_codes } from 'Constants/api-error-codes';
export default class GeneralStore extends BaseStore {
active_index = 0;
@@ -22,6 +23,7 @@ export default class GeneralStore extends BaseStore {
balance;
cancels_remaining = null;
contact_info = '';
+ external_stores = {};
feature_level = null;
formik_ref = null;
inactive_notification_count = 0;
@@ -38,13 +40,11 @@ export default class GeneralStore extends BaseStore {
is_restricted = false;
nickname = null;
nickname_error = '';
- notification_count = 0;
order_table_type = order_list.ACTIVE;
orders = [];
parameters = null;
payment_info = '';
poi_status = null;
- props = {};
review_period;
saved_form_state = null;
should_show_real_name = false;
@@ -62,6 +62,12 @@ export default class GeneralStore extends BaseStore {
ws_subscriptions = {};
service_token_timeout;
+ server_time = {
+ get,
+ init,
+ timePromise,
+ };
+
constructor(root_store) {
// TODO: [mobx-undecorate] verify the constructor arguments and the arguments of this automatically generated super call
super(root_store);
@@ -76,6 +82,7 @@ export default class GeneralStore extends BaseStore {
advertiser_relations_response: observable, //TODO: Remove this when backend has fixed is_blocked flag issue
block_unblock_user_error: observable,
balance: observable,
+ external_stores: observable,
feature_level: observable,
formik_ref: observable,
inactive_notification_count: observable,
@@ -90,12 +97,10 @@ export default class GeneralStore extends BaseStore {
is_restricted: observable,
nickname: observable,
nickname_error: observable,
- notification_count: observable,
order_table_type: observable,
orders: observable,
parameters: observable,
poi_status: observable,
- props: observable.ref,
review_period: observable,
saved_form_state: observable,
should_show_real_name: observable,
@@ -104,10 +109,6 @@ export default class GeneralStore extends BaseStore {
user_blocked_until: observable,
is_high_risk_fully_authed_without_fa: observable,
is_modal_open: observable,
- client: computed,
- current_focus: computed,
- form_state: computed,
- setCurrentFocus: computed,
blocked_until_date_time: computed,
is_active_tab: computed,
is_barred: computed,
@@ -132,8 +133,7 @@ export default class GeneralStore extends BaseStore {
setAdvertiserId: action.bound,
setAdvertiserBuyLimit: action.bound,
setAdvertiserSellLimit: action.bound,
- setAppProps: action.bound,
- setAdvertiserRelationsResponse: action.bound, //TODO: Remove this when backend has fixed is_blocked flag issue
+ setExternalStores: action.bound,
setFeatureLevel: action.bound,
setFormikRef: action.bound,
setSavedFormState: action.bound,
@@ -149,7 +149,6 @@ export default class GeneralStore extends BaseStore {
setIsModalOpen: action.bound,
setNickname: action.bound,
setNicknameError: action.bound,
- setNotificationCount: action.bound,
setOrderTableType: action.bound,
setP2PConfig: action.bound,
setP2pOrderList: action.bound,
@@ -171,22 +170,6 @@ export default class GeneralStore extends BaseStore {
});
}
- get client() {
- return { ...this.props?.client } || {};
- }
-
- get current_focus() {
- return this.props?.current_focus;
- }
-
- get form_state() {
- return this.formik_ref;
- }
-
- get setCurrentFocus() {
- return this.props?.setCurrentFocus;
- }
-
get blocked_until_date_time() {
return getFormattedDateString(new Date(convertToMillis(this.user_blocked_until)), false, true);
}
@@ -289,7 +272,7 @@ export default class GeneralStore extends BaseStore {
};
getLocalStorageSettingsForLoginId() {
- const local_storage_settings = this.getLocalStorageSettings()[this.client.loginid];
+ const local_storage_settings = this.getLocalStorageSettings()[this.external_stores.client.loginid];
if (isEmptyObject(local_storage_settings)) {
return { is_cached: false, notifications: [] };
@@ -314,11 +297,14 @@ export default class GeneralStore extends BaseStore {
handleNotifications(old_orders, new_orders) {
const { order_store } = this.root_store;
- const { client, props } = this;
const { is_cached, notifications } = this.getLocalStorageSettingsForLoginId();
new_orders.forEach(new_order => {
- const order_info = createExtendedOrderDetails(new_order, client.loginid, props.server_time);
+ const order_info = createExtendedOrderDetails(
+ new_order,
+ this.external_stores.client.loginid,
+ this.server_time
+ );
const notification = notifications.find(n => n.order_id === new_order.id);
const old_order = old_orders.find(o => o.id === new_order.id);
const is_current_order = new_order.id === order_store.order_id;
@@ -341,14 +327,14 @@ export default class GeneralStore extends BaseStore {
if (
type === buy_sell.BUY &&
status === 'completed' &&
- client_details.loginid === client.loginid
+ client_details.loginid === this.external_stores.client.loginid
)
this.showCompletedOrderNotification(advertiser_details.name, id);
if (
type === buy_sell.SELL &&
status === 'completed' &&
- advertiser_details.loginid === client.loginid
+ advertiser_details.loginid === this.external_stores.client.loginid
)
this.showCompletedOrderNotification(client_details.name, id);
} else {
@@ -390,9 +376,9 @@ export default class GeneralStore extends BaseStore {
const notification_key = `order-${order_id}`;
// we need to refresh notifications in notifications-store in the case of a bug when user closes the notification, the notification count is not synced up with the closed notification
- this.props.refreshNotifications();
+ this.external_stores?.notifications.refreshNotifications();
- this.props.addNotificationMessage({
+ this.external_stores?.notifications.addNotificationMessage({
action: {
onClick: () => {
if (order_store.order_id === order_id) {
@@ -418,13 +404,10 @@ export default class GeneralStore extends BaseStore {
showDailyLimitIncreaseNotification() {
const { upgradable_daily_limits } = this.advertiser_info;
const { max_daily_buy, max_daily_sell } = upgradable_daily_limits;
+ const { client, notifications } = this.external_stores;
- this.props.addNotificationMessage(
- this.props.client_notifications.p2p_daily_limit_increase(
- this.client.currency,
- max_daily_buy,
- max_daily_sell
- )
+ notifications.addNotificationMessage(
+ notifications.client_notifications.p2p_daily_limit_increase(client.currency, max_daily_buy, max_daily_sell)
);
}
@@ -443,7 +426,7 @@ export default class GeneralStore extends BaseStore {
() => this.user_blocked_until,
blocked_until => {
if (typeof blocked_until === 'number') {
- const server_time = this.props.server_time.get();
+ const server_time = this.server_time.get();
const blocked_until_moment = toMoment(blocked_until);
// Need isAfter instead of setTimeout as setTimeout has a max delay of 24.8 days
@@ -518,11 +501,11 @@ export default class GeneralStore extends BaseStore {
exchange_rate_subscription: subscribeWS(
{
exchange_rates: 1,
- base_currency: this.client.currency,
+ base_currency: this.external_stores.client.currency,
subscribe: 1,
target_currency:
this.root_store.buy_sell_store.selected_local_currency ??
- this.client.local_currency_config?.currency,
+ this.external_stores.client.local_currency_config?.currency,
},
[this.root_store.floating_rate_store.fetchExchangeRate]
),
@@ -539,7 +522,7 @@ export default class GeneralStore extends BaseStore {
this.setIsLoading(false);
}
- this.props.setP2PRedirectTo({
+ this.external_stores.notifications.setP2PRedirectTo({
redirectTo: this.redirectTo,
});
});
@@ -547,13 +530,13 @@ export default class GeneralStore extends BaseStore {
subscribeToLocalCurrency() {
const { floating_rate_store, buy_sell_store } = this.root_store;
- const client_currency = this.client.local_currency_config?.currency;
+ const client_currency = this.external_stores.client.local_currency_config?.currency;
this.ws_subscriptions?.exchange_rate_subscription?.unsubscribe?.();
this.ws_subscriptions.exchange_rate_subscription = subscribeWS(
{
exchange_rates: 1,
- base_currency: this.client.currency,
+ base_currency: this.external_stores.client.currency,
subscribe: 1,
target_currency:
this.active_index > 0 ? client_currency : buy_sell_store.local_currency ?? client_currency,
@@ -577,8 +560,8 @@ export default class GeneralStore extends BaseStore {
}
this.setActiveIndex(0);
- this.props.refreshNotifications();
- this.props.filterNotificationMessages();
+ this.external_stores?.notifications.refreshNotifications();
+ this.external_stores?.notifications.filterNotificationMessages();
}
onNicknamePopupClose() {
@@ -633,10 +616,6 @@ export default class GeneralStore extends BaseStore {
this.advertiser_sell_limit = advertiser_sell_limit;
}
- setAppProps(props) {
- this.props = props;
- }
-
//TODO: Remove this when backend has fixed is_blocked flag issue
setAdvertiserRelationsResponse(advertiser_relations_response) {
this.advertiser_relations_response = advertiser_relations_response;
@@ -654,6 +633,10 @@ export default class GeneralStore extends BaseStore {
this.default_advert_description = default_advert_description;
}
+ setExternalStores(external_stores) {
+ this.external_stores = external_stores;
+ }
+
setFeatureLevel(feature_level) {
this.feature_level = feature_level;
}
@@ -722,10 +705,6 @@ export default class GeneralStore extends BaseStore {
this.nickname_error = nickname_error;
}
- setNotificationCount(notification_count) {
- this.notification_count = notification_count;
- }
-
setOrderTableType(order_table_type) {
const { order_store } = this.root_store;
order_store.setIsLoading(true);
@@ -908,18 +887,13 @@ export default class GeneralStore extends BaseStore {
user_settings.notifications = notifications;
const p2p_settings = this.getLocalStorageSettings();
- p2p_settings[this.client.loginid] = user_settings;
+ p2p_settings[this.external_stores.client.loginid] = user_settings;
localStorage.setItem('p2p_settings', JSON.stringify(p2p_settings));
window.dispatchEvent(new Event('storage'));
- this.setNotificationCount(notification_count);
this.setActiveNotificationCount(active_notification_count);
this.setInactiveNotificationCount(inactive_notification_count);
-
- if (typeof this.props?.setNotificationCount === 'function') {
- this.props.setNotificationCount(notification_count);
- }
}
validatePopup = values => {
diff --git a/packages/p2p/src/stores/index.js b/packages/p2p/src/stores/index.js
index 805c441d10dd..bfcc986d90f8 100644
--- a/packages/p2p/src/stores/index.js
+++ b/packages/p2p/src/stores/index.js
@@ -9,7 +9,7 @@ import OrderStore from './order-store';
import OrderDetailsStore from './order-details-store';
import SendbirdStore from './sendbird-store';
-class RootStore {
+export default class RootStore {
constructor() {
this.general_store = new GeneralStore(this); // Leave at the top!
this.advertiser_page_store = new AdvertiserPageStore(this);
diff --git a/packages/p2p/src/stores/my-ads-store.js b/packages/p2p/src/stores/my-ads-store.js
index 5cb2448f2824..9f8b0f1cdb33 100644
--- a/packages/p2p/src/stores/my-ads-store.js
+++ b/packages/p2p/src/stores/my-ads-store.js
@@ -626,7 +626,7 @@ export default class MyAdsStore extends BaseStore {
v =>
v > 0 &&
decimalValidator(v) &&
- countDecimalPlaces(v) <= getDecimalPlaces(general_store.client.currency),
+ countDecimalPlaces(v) <= getDecimalPlaces(general_store.external_stores.client.currency),
v => (values.offer_amount ? +v <= values.offer_amount : true),
v => (values.min_transaction ? +v >= values.min_transaction : true),
],
@@ -636,7 +636,7 @@ export default class MyAdsStore extends BaseStore {
v =>
v > 0 &&
decimalValidator(v) &&
- countDecimalPlaces(v) <= getDecimalPlaces(general_store.client.currency),
+ countDecimalPlaces(v) <= getDecimalPlaces(general_store.external_stores.client.currency),
v => (values.offer_amount ? +v <= values.offer_amount : true),
v => (values.max_transaction ? +v <= values.max_transaction : true),
],
@@ -646,7 +646,7 @@ export default class MyAdsStore extends BaseStore {
v =>
v > 0 &&
decimalValidator(v) &&
- countDecimalPlaces(v) <= getDecimalPlaces(general_store.client.currency),
+ countDecimalPlaces(v) <= getDecimalPlaces(general_store.external_stores.client.currency),
v => (values.min_transaction ? +v >= values.min_transaction : true),
v => (values.max_transaction ? +v >= values.max_transaction : true),
],
@@ -657,7 +657,8 @@ export default class MyAdsStore extends BaseStore {
floating_rate_store.rate_type === ad_type.FIXED
? v > 0 &&
decimalValidator(v) &&
- countDecimalPlaces(v) <= general_store.client.local_currency_config.decimal_places
+ countDecimalPlaces(v) <=
+ general_store.external_stores.client.local_currency_config.decimal_places
: true,
v =>
floating_rate_store.rate_type === ad_type.FLOAT
@@ -782,7 +783,7 @@ export default class MyAdsStore extends BaseStore {
v =>
v > 0 &&
decimalValidator(v) &&
- countDecimalPlaces(v) <= getDecimalPlaces(general_store.client.currency),
+ countDecimalPlaces(v) <= getDecimalPlaces(general_store.external_stores.client.currency),
v => (values.offer_amount ? +v <= values.offer_amount : true),
v => (values.min_transaction ? +v >= values.min_transaction : true),
],
@@ -792,7 +793,7 @@ export default class MyAdsStore extends BaseStore {
v =>
v > 0 &&
decimalValidator(v) &&
- countDecimalPlaces(v) <= getDecimalPlaces(general_store.client.currency),
+ countDecimalPlaces(v) <= getDecimalPlaces(general_store.external_stores.client.currency),
v => (values.offer_amount ? +v <= values.offer_amount : true),
v => (values.max_transaction ? +v <= values.max_transaction : true),
],
@@ -803,7 +804,8 @@ export default class MyAdsStore extends BaseStore {
this.required_ad_type === ad_type.FIXED
? v > 0 &&
decimalValidator(v) &&
- countDecimalPlaces(v) <= general_store.client.local_currency_config.decimal_places
+ countDecimalPlaces(v) <=
+ general_store.external_stores.client.local_currency_config.decimal_places
: true,
v =>
this.required_ad_type === ad_type.FLOAT
diff --git a/packages/p2p/src/stores/my-profile-store.js b/packages/p2p/src/stores/my-profile-store.js
index 7e4ecc58201f..f1f2339d02f6 100644
--- a/packages/p2p/src/stores/my-profile-store.js
+++ b/packages/p2p/src/stores/my-profile-store.js
@@ -912,12 +912,12 @@ export default class MyProfileStore extends BaseStore {
if (response.error) this.setIsErrorModalOpen(true);
else this.setIsDailyLimitSuccessModalOpen(true);
- general_store.props.removeNotificationByKey({
+ general_store.external_stores.notifications.removeNotificationByKey({
key: 'p2p_daily_limit_increase',
should_show_again: false,
});
- general_store.client.setP2pAdvertiserInfo(false);
+ general_store.external_stores.client.setP2pAdvertiserInfo(false);
}
});
}
diff --git a/packages/p2p/src/stores/order-store.js b/packages/p2p/src/stores/order-store.js
index 839f320aa33e..1542f34ccc65 100644
--- a/packages/p2p/src/stores/order-store.js
+++ b/packages/p2p/src/stores/order-store.js
@@ -359,8 +359,8 @@ export default class OrderStore {
const { general_store } = this.root_store;
const order_information = createExtendedOrderDetails(
input_order,
- general_store.client.loginid,
- general_store.props.server_time
+ general_store.external_stores.client.loginid,
+ general_store.server_time
);
this.setOrderId(order_information.id); // Sets the id in URL
if (order_information.is_active_order) {
@@ -420,8 +420,8 @@ export default class OrderStore {
const get_order_status = createExtendedOrderDetails(
p2p_order_info,
- general_store.client.loginid,
- general_store.props.server_time
+ general_store.external_stores.client.loginid,
+ general_store.server_time
);
const order_idx = this.orders.findIndex(order => order.id === p2p_order_info.id);
@@ -451,8 +451,8 @@ export default class OrderStore {
if (get_order_status.is_completed_order && !get_order_status.is_reviewable) {
// Remove notification once order review period is finished
const notification_key = `order-${p2p_order_info.id}`;
- general_store.props.removeNotificationMessage({ key: notification_key });
- general_store.props.removeNotificationByKey({ key: notification_key });
+ general_store.external_stores?.notifications.removeNotificationMessage({ key: notification_key });
+ general_store.external_stores?.notifications.removeNotificationByKey({ key: notification_key });
}
}
@@ -563,12 +563,6 @@ export default class OrderStore {
setOrderId(order_id) {
this.order_id = order_id;
-
- const { general_store } = this.root_store;
-
- if (typeof general_store.props.setOrderId === 'function') {
- general_store.props.setOrderId(order_id);
- }
}
setOrderPaymentMethodDetails(order_payment_method_details) {
diff --git a/packages/p2p/src/stores/sendbird-store.js b/packages/p2p/src/stores/sendbird-store.js
index 450c720f88cd..7ccbc313bf3d 100644
--- a/packages/p2p/src/stores/sendbird-store.js
+++ b/packages/p2p/src/stores/sendbird-store.js
@@ -1,5 +1,5 @@
import SendBird from 'sendbird';
-import { epochToMoment } from '@deriv/shared';
+import { epochToMoment, toMoment } from '@deriv/shared';
import { action, computed, observable, reaction, makeObservable } from 'mobx';
import BaseStore from 'Stores/base_store';
import ChatMessage, { convertFromChannelMessage } from 'Utils/chat-message';
@@ -188,7 +188,7 @@ export default class SendbirdStore extends BaseStore {
const custom_type = '';
this.active_chat_channel.getPreviousMessagesByTimestamp(
- timestamp || this.root_store.general_store.props.server_time.get().utc().valueOf(),
+ timestamp || toMoment(this.root_store.general_store.server_time.get()).utc().valueOf(),
is_inclusive_of_timestamp,
result_size,
reverse_results,
@@ -213,7 +213,7 @@ export default class SendbirdStore extends BaseStore {
requestWS({ service: 'sendbird', service_token: 1 }).then(service_token_response => {
if (service_token_response.error) return;
- const { server_time } = this.root_store.general_store.props;
+ const { server_time } = this.root_store.general_store;
const { service_token } = service_token_response;
this.setChatInfo({
@@ -225,7 +225,7 @@ export default class SendbirdStore extends BaseStore {
// Refresh chat token ±1 hour before it expires (BE will refresh the token
// when we request within 2 hours of the token expiring)
const expiry_moment = epochToMoment(service_token.sendbird.expiry_time);
- const delay_ms = expiry_moment.diff(server_time.get().clone().subtract(1, 'hour'));
+ const delay_ms = expiry_moment.diff(toMoment(server_time.get()).clone().subtract(1, 'hour'));
this.service_token_timeout = setTimeout(() => getSendbirdServiceToken(), delay_ms);
});
@@ -386,7 +386,7 @@ export default class SendbirdStore extends BaseStore {
// Add a placeholder message with a pending indicator
const placeholder_msg_options = {
- created_at: this.root_store.general_store.props.server_time.get().utc(),
+ created_at: toMoment(this.root_store.general_store.server_time.get()).utc(),
chat_channel_url: this.active_chat_channel.url,
message,
id: msg_identifier,
diff --git a/packages/p2p/src/utils/orders.js b/packages/p2p/src/utils/orders.js
index 8d1965713348..b8e03db4a10f 100644
--- a/packages/p2p/src/utils/orders.js
+++ b/packages/p2p/src/utils/orders.js
@@ -115,7 +115,7 @@ export default class ExtendedOrderDetails {
// orders as active when they're actually expired. This boolean is used
// as an extra check to ensure orders look expired on FE.
get has_timer_expired() {
- const server_time_moment = this.server_time.get();
+ const server_time_moment = toMoment(this.server_time.get());
const expiry_time_moment = toMoment(this.order_details.expiry_time);
return server_time_moment.isAfter(expiry_time_moment);
}
diff --git a/packages/p2p/src/utils/server-time.js b/packages/p2p/src/utils/server-time.js
index b573a66fffd6..cb73b00c57ab 100644
--- a/packages/p2p/src/utils/server-time.js
+++ b/packages/p2p/src/utils/server-time.js
@@ -1,4 +1,5 @@
import { convertToMillis } from 'Utils/date-time';
+import { toMoment } from '@deriv/shared';
let server_time;
@@ -6,7 +7,7 @@ const init = server_time_payload => {
server_time = server_time_payload;
};
-const get = () => (server_time ? convertToMillis(server_time.get().utc().unix()) : server_time);
+const get = () => (server_time ? convertToMillis(toMoment(server_time.get()).unix()) : server_time);
const getDistanceToServerTime = compare_millis_time => {
const now_millis = get();
diff --git a/packages/p2p/webpack.config.js b/packages/p2p/webpack.config.js
index f901d211ca7d..0648ab3b4c7e 100644
--- a/packages/p2p/webpack.config.js
+++ b/packages/p2p/webpack.config.js
@@ -146,6 +146,7 @@ module.exports = function (env) {
{
react: 'react',
'react-dom': 'react-dom',
+ 'react-router-dom': 'react-router-dom',
'prop-types': 'prop-types',
...(is_publishing ? {} : { 'lodash.debounce': 'lodash.debounce', formik: 'formik' }),
...publisher_utils.getLocalDerivPackageExternals(__dirname, is_publishing),