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

Display Trustpilot Review Notification Based on Backend Status #17139

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
5 changes: 5 additions & 0 deletions packages/core/src/Stores/client-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ export default class ClientStore extends BaseStore {
setTradersHubTracking: action.bound,
account_time_of_closure: computed,
is_account_to_be_closed_by_residence: computed,
should_show_trustpilot_notification: computed,
});

reaction(
Expand Down Expand Up @@ -2929,4 +2930,8 @@ export default class ClientStore extends BaseStore {
get is_account_to_be_closed_by_residence() {
return this.account_time_of_closure && this.residence && this.residence === 'sn';
}

get should_show_trustpilot_notification() {
return this.account_status?.status?.includes('customer_review_eligible');
}
}
19 changes: 7 additions & 12 deletions packages/core/src/Stores/notification-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { action, computed, makeObservable, observable, reaction } from 'mobx';
import { StaticUrl } from '@deriv/components';
import {
checkServerMaintenance,
daysSince,
extractInfoFromShortcode,
formatDate,
formatMoney,
Expand Down Expand Up @@ -315,7 +314,6 @@ export default class NotificationStore extends BaseStore {
account_list,
account_settings,
account_status,
account_open_date,
accounts,
isAccountOfType,
is_eu,
Expand Down Expand Up @@ -346,8 +344,7 @@ export default class NotificationStore extends BaseStore {
const { current_language, selected_contract_type } = this.root_store.common;
const malta_account = landing_company_shortcode === 'maltainvest';
const cr_account = landing_company_shortcode === 'svg';
const is_website_up = website_status.site_status === 'up';
const has_trustpilot = LocalStore.getObject('notification_messages')[loginid]?.includes(
const has_trustpilot = LocalStore.getObject('marked_notifications').includes(
this.client_notifications.trustpilot?.key
);
const is_next_email_attempt_timer_running = shouldShowPhoneVerificationNotification(
Expand Down Expand Up @@ -457,6 +454,10 @@ export default class NotificationStore extends BaseStore {
});
}

if (!has_trustpilot && this.root_store.client.should_show_trustpilot_notification) {
this.addNotificationMessage(this.client_notifications.trustpilot);
}

const client = accounts[loginid];
if (client && !client.is_virtual) {
if (isEmptyObject(account_status)) return;
Expand Down Expand Up @@ -623,9 +624,6 @@ export default class NotificationStore extends BaseStore {
} else {
this.removeNotificationMessageByKey({ key: this.client_notifications.dp2p?.key });
}
if (is_website_up && !has_trustpilot && daysSince(account_open_date) > 7) {
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
this.addNotificationMessage(this.client_notifications.trustpilot);
}
has_missing_required_field = hasMissingRequiredField(account_settings, client, isAccountOfType);
if (has_missing_required_field) {
this.addNotificationMessage(
Expand Down Expand Up @@ -838,18 +836,15 @@ export default class NotificationStore extends BaseStore {
action: {
onClick: () => {
window.open('https://www.trustpilot.com/evaluate/deriv.com', '_blank');
this.removeNotificationByKey({ key: this.client_notifications.trustpilot.key });
this.removeNotificationMessage({
key: this.client_notifications.trustpilot.key,
should_show_again: false,
});
this.markNotificationMessage({ key: this.client_notifications.trustpilot.key });
},
text: localize('Go to Trustpilot'),
},
img_src: getUrlBase('/public/images/common/trustpilot_banner.png'),
img_alt: 'Trustpilot',
className: 'trustpilot',
type: 'trustpilot',
should_show_again: false,
likhith-deriv marked this conversation as resolved.
Show resolved Hide resolved
},
currency: {
key: 'currency',
Expand Down
1 change: 1 addition & 0 deletions packages/stores/src/mockStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ const mock = (): TStores & { is_mock: boolean } => {
setTradersHubTracking: jest.fn(),
account_time_of_closure: undefined,
is_account_to_be_closed_by_residence: false,
should_show_trustpilot_notification: false,
},
common: {
error: common_store_error,
Expand Down
1 change: 1 addition & 0 deletions packages/stores/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ export type TClientStore = {
setTradersHubTracking: (value: boolean) => void;
account_time_of_closure?: number;
is_account_to_be_closed_by_residence: boolean;
should_show_trustpilot_notification: boolean;
};

type TCommonStoreError = {
Expand Down
Loading