From ab53c794b0c7362ef78aadca2b164350fcd20135 Mon Sep 17 00:00:00 2001 From: utkarsha-deriv Date: Thu, 10 Oct 2024 12:21:21 +0400 Subject: [PATCH 1/5] chore: update trustpilot notification criteria --- packages/core/src/Stores/client-store.js | 7 ++++++ .../core/src/Stores/notification-store.js | 22 +++++++++++-------- packages/stores/src/mockStore.ts | 1 + packages/stores/types.ts | 1 + 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/packages/core/src/Stores/client-store.js b/packages/core/src/Stores/client-store.js index 5e1061559d92..83b76cb31cc3 100644 --- a/packages/core/src/Stores/client-store.js +++ b/packages/core/src/Stores/client-store.js @@ -170,6 +170,8 @@ export default class ClientStore extends BaseStore { subscriptions = {}; exchange_rates = {}; + should_show_trustpilot_notification = false; + constructor(root_store) { const local_storage_properties = ['device_data']; super({ root_store, local_storage_properties, store_name }); @@ -247,6 +249,7 @@ export default class ClientStore extends BaseStore { is_phone_number_verification_enabled: observable, passkeys_list: observable, should_show_passkey_notification: observable, + should_show_trustpilot_notification: observable, balance: computed, account_open_date: computed, is_svg: computed, @@ -2929,4 +2932,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'); + } } diff --git a/packages/core/src/Stores/notification-store.js b/packages/core/src/Stores/notification-store.js index fded03fba4c9..ef2b5d47301c 100644 --- a/packages/core/src/Stores/notification-store.js +++ b/packages/core/src/Stores/notification-store.js @@ -4,7 +4,7 @@ import { action, computed, makeObservable, observable, reaction } from 'mobx'; import { StaticUrl } from '@deriv/components'; import { checkServerMaintenance, - daysSince, + // daysSince, extractInfoFromShortcode, formatDate, formatMoney, @@ -315,7 +315,7 @@ export default class NotificationStore extends BaseStore { account_list, account_settings, account_status, - account_open_date, + // account_open_date, accounts, isAccountOfType, is_eu, @@ -346,10 +346,10 @@ 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( - this.client_notifications.trustpilot?.key - ); + // const is_website_up = website_status.site_status === 'up'; + // const has_trustpilot = LocalStore.getObject('notification_messages')[loginid]?.includes( + // this.client_notifications.trustpilot?.key + // ); const is_next_email_attempt_timer_running = shouldShowPhoneVerificationNotification( account_settings?.phone_number_verification?.next_email_attempt, current_time @@ -457,6 +457,10 @@ export default class NotificationStore extends BaseStore { }); } + if (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; @@ -623,9 +627,9 @@ 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) { - this.addNotificationMessage(this.client_notifications.trustpilot); - } + // if (is_website_up && !has_trustpilot && daysSince(account_open_date) > 7) { + // this.addNotificationMessage(this.client_notifications.trustpilot); + // } has_missing_required_field = hasMissingRequiredField(account_settings, client, isAccountOfType); if (has_missing_required_field) { this.addNotificationMessage( diff --git a/packages/stores/src/mockStore.ts b/packages/stores/src/mockStore.ts index da18e6b5c700..11e4287a0b4e 100644 --- a/packages/stores/src/mockStore.ts +++ b/packages/stores/src/mockStore.ts @@ -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, diff --git a/packages/stores/types.ts b/packages/stores/types.ts index 50dc2696623b..9da7e47c6fa5 100644 --- a/packages/stores/types.ts +++ b/packages/stores/types.ts @@ -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 = { From 252fc5453278a1c23b827882819c99e1816ad728 Mon Sep 17 00:00:00 2001 From: utkarsha-deriv Date: Thu, 10 Oct 2024 16:22:55 +0400 Subject: [PATCH 2/5] chore: remove comments, add marked notif --- packages/core/src/Stores/client-store.js | 4 +--- packages/core/src/Stores/notification-store.js | 16 +++++----------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/packages/core/src/Stores/client-store.js b/packages/core/src/Stores/client-store.js index 83b76cb31cc3..b148df640701 100644 --- a/packages/core/src/Stores/client-store.js +++ b/packages/core/src/Stores/client-store.js @@ -170,8 +170,6 @@ export default class ClientStore extends BaseStore { subscriptions = {}; exchange_rates = {}; - should_show_trustpilot_notification = false; - constructor(root_store) { const local_storage_properties = ['device_data']; super({ root_store, local_storage_properties, store_name }); @@ -249,7 +247,6 @@ export default class ClientStore extends BaseStore { is_phone_number_verification_enabled: observable, passkeys_list: observable, should_show_passkey_notification: observable, - should_show_trustpilot_notification: observable, balance: computed, account_open_date: computed, is_svg: computed, @@ -436,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( diff --git a/packages/core/src/Stores/notification-store.js b/packages/core/src/Stores/notification-store.js index ef2b5d47301c..d952df9359eb 100644 --- a/packages/core/src/Stores/notification-store.js +++ b/packages/core/src/Stores/notification-store.js @@ -4,7 +4,6 @@ import { action, computed, makeObservable, observable, reaction } from 'mobx'; import { StaticUrl } from '@deriv/components'; import { checkServerMaintenance, - // daysSince, extractInfoFromShortcode, formatDate, formatMoney, @@ -315,7 +314,6 @@ export default class NotificationStore extends BaseStore { account_list, account_settings, account_status, - // account_open_date, accounts, isAccountOfType, is_eu, @@ -346,10 +344,9 @@ 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( - // this.client_notifications.trustpilot?.key - // ); + const has_trustpilot = LocalStore.getObject('marked_notifications').includes( + this.client_notifications.trustpilot?.key + ); const is_next_email_attempt_timer_running = shouldShowPhoneVerificationNotification( account_settings?.phone_number_verification?.next_email_attempt, current_time @@ -457,7 +454,7 @@ export default class NotificationStore extends BaseStore { }); } - if (this.root_store.client.should_show_trustpilot_notification) { + if (!has_trustpilot && this.root_store.client.should_show_trustpilot_notification) { this.addNotificationMessage(this.client_notifications.trustpilot); } @@ -627,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) { - // this.addNotificationMessage(this.client_notifications.trustpilot); - // } has_missing_required_field = hasMissingRequiredField(account_settings, client, isAccountOfType); if (has_missing_required_field) { this.addNotificationMessage( @@ -842,7 +836,7 @@ 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.markNotificationMessage({ key: this.client_notifications.trustpilot.key }); this.removeNotificationMessage({ key: this.client_notifications.trustpilot.key, should_show_again: false, From f9e59a4372c748c1e384c5fe3576c60bdea6b51e Mon Sep 17 00:00:00 2001 From: utkarsha-deriv Date: Thu, 10 Oct 2024 17:10:56 +0400 Subject: [PATCH 3/5] fix: fix --- packages/core/src/Stores/notification-store.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/core/src/Stores/notification-store.js b/packages/core/src/Stores/notification-store.js index d952df9359eb..67a09faf9c01 100644 --- a/packages/core/src/Stores/notification-store.js +++ b/packages/core/src/Stores/notification-store.js @@ -837,10 +837,6 @@ export default class NotificationStore extends BaseStore { onClick: () => { window.open('https://www.trustpilot.com/evaluate/deriv.com', '_blank'); this.markNotificationMessage({ key: this.client_notifications.trustpilot.key }); - this.removeNotificationMessage({ - key: this.client_notifications.trustpilot.key, - should_show_again: false, - }); }, text: localize('Go to Trustpilot'), }, @@ -848,6 +844,7 @@ export default class NotificationStore extends BaseStore { img_alt: 'Trustpilot', className: 'trustpilot', type: 'trustpilot', + should_show_again: false, }, currency: { key: 'currency', From f53fd2df8e6df5acdad78df36e9fca627e2c57fe Mon Sep 17 00:00:00 2001 From: utkarsha-deriv Date: Fri, 11 Oct 2024 13:18:40 +0400 Subject: [PATCH 4/5] fix: fix remove notif array --- packages/core/src/Stores/notification-store.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/core/src/Stores/notification-store.js b/packages/core/src/Stores/notification-store.js index 67a09faf9c01..358586205e3a 100644 --- a/packages/core/src/Stores/notification-store.js +++ b/packages/core/src/Stores/notification-store.js @@ -837,6 +837,13 @@ export default class NotificationStore extends BaseStore { onClick: () => { window.open('https://www.trustpilot.com/evaluate/deriv.com', '_blank'); this.markNotificationMessage({ key: this.client_notifications.trustpilot.key }); + this.removeNotificationByKey({ + key: this.client_notifications.trustpilot.key, + }); + this.removeNotificationMessage({ + key: this.client_notifications.trustpilot.key, + should_show_again: false, + }); }, text: localize('Go to Trustpilot'), }, From b35399646a969a12dd5509e72ec684d4957320d7 Mon Sep 17 00:00:00 2001 From: utkarsha-deriv Date: Fri, 11 Oct 2024 13:19:39 +0400 Subject: [PATCH 5/5] fix: fix remove notif array --- packages/core/src/Stores/notification-store.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/src/Stores/notification-store.js b/packages/core/src/Stores/notification-store.js index 358586205e3a..6d53803b6df4 100644 --- a/packages/core/src/Stores/notification-store.js +++ b/packages/core/src/Stores/notification-store.js @@ -851,7 +851,6 @@ export default class NotificationStore extends BaseStore { img_alt: 'Trustpilot', className: 'trustpilot', type: 'trustpilot', - should_show_again: false, }, currency: { key: 'currency',