Skip to content

Commit

Permalink
chore: changed error message for blocking user who is banned
Browse files Browse the repository at this point in the history
  • Loading branch information
ameerul-deriv committed Feb 9, 2023
1 parent c6a5589 commit 011e868
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
17 changes: 15 additions & 2 deletions packages/p2p/src/components/advertiser-page/advertiser-page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { reaction } from 'mobx';
import { observer } from 'mobx-react-lite';
import { useStores } from 'Stores';
import { Localize, localize } from 'Components/i18next';
import { api_error_codes } from 'Constants/api-error-codes';
import { buy_sell } from 'Constants/buy-sell';
import { my_profile_tabs } from 'Constants/my-profile-tabs';
import RateChangeModal from 'Components/buy-sell/rate-change-modal.jsx';
Expand Down Expand Up @@ -90,8 +91,20 @@ const AdvertiserPage = () => {
>
<RateChangeModal onMount={advertiser_page_store.setShowAdPopup} />
<ErrorModal
error_message={general_store.block_unblock_user_error}
error_modal_title='Unable to block advertiser'
error_message={
general_store.error_code === api_error_codes.INVALID_ADVERTISER_ID
? localize("Blocking wasn't possible as {{name}} is not using Deriv P2P anymore.", {
name: advertiser_page_store.advertiser_details_name,
})
: general_store.block_unblock_user_error
}
error_modal_title={
general_store.error_code === api_error_codes.INVALID_ADVERTISER_ID
? localize('{{name}} is no longer on Deriv P2P', {
name: advertiser_page_store.advertiser_details_name,
})
: localize('Unable to block advertiser')
}
has_close_icon={false}
is_error_modal_open={is_error_modal_open}
setIsErrorModalOpen={is_open => {
Expand Down
17 changes: 15 additions & 2 deletions packages/p2p/src/components/my-profile/block-user/block-user.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { observer } from 'mobx-react-lite';
import { useStores } from 'Stores';
import { DesktopWrapper, MobileFullPageModal, MobileWrapper } from '@deriv/components';
import { isMobile } from '@deriv/shared';
import { api_error_codes } from 'Constants/api-error-codes';
import { my_profile_tabs } from 'Constants/my-profile-tabs';
import { localize } from 'Components/i18next';
import BlockUserModal from 'Components/block-user/block-user-modal';
Expand All @@ -24,8 +25,20 @@ const BlockUser = () => {
onSubmit={my_profile_store.onSubmit}
/>
<ErrorModal
error_message={general_store.block_unblock_user_error}
error_modal_title='Unable to block advertiser'
error_message={
general_store.error_code === api_error_codes.INVALID_ADVERTISER_ID
? localize("Blocking wasn't possible as {{name}} is not using Deriv P2P anymore.", {
name: my_profile_store.selected_trade_partner.name,
})
: general_store.block_unblock_user_error
}
error_modal_title={
general_store.error_code === api_error_codes.INVALID_ADVERTISER_ID
? localize('{{name}} is no longer on Deriv P2P', {
name: my_profile_store.selected_trade_partner.name,
})
: localize('Unable to block advertiser')
}
has_close_icon={false}
is_error_modal_open={general_store.block_unblock_user_error && !general_store.is_barred}
setIsErrorModalOpen={() => general_store.setBlockUnblockUserError('')}
Expand Down
1 change: 1 addition & 0 deletions packages/p2p/src/constants/api-error-codes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const api_error_codes = Object.freeze({
DUPLICATE_ADVERT: 'DuplicateAdvert',
EXCESSIVE_VERIFICATION_FAILURES: 'ExcessiveVerificationFailures',
EXCESSIVE_VERIFICATION_REQUESTS: 'ExcessiveVerificationRequests',
INVALID_ADVERTISER_ID: 'InvalidAdvertiserID',
INVALID_VERIFICATION_TOKEN: 'InvalidVerificationToken',
ORDER_EMAIL_VERIFICATION_REQUIRED: 'OrderEmailVerificationRequired',
ORDER_CREATE_FAIL_CLIENT_BALANCE: 'OrderCreateFailClientBalance',
Expand Down
6 changes: 3 additions & 3 deletions packages/p2p/src/stores/advertiser-page-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export default class AdvertiserPageStore extends BaseStore {
active_index = 0;
ad = null;
adverts = [];
api_error_message = '';
counterparty_advertiser_info = {};
counterparty_type = buy_sell.BUY;
api_error_message = '';
form_error_message = '';
has_more_adverts_to_load = false;
is_counterparty_advertiser_blocked = false;
Expand All @@ -27,14 +27,14 @@ export default class AdvertiserPageStore extends BaseStore {
active_index: observable,
ad: observable,
adverts: observable,
counterparty_type: observable,
api_error_message: observable,
counterparty_type: observable,
form_error_message: observable,
has_more_adverts_to_load: observable,
is_counterparty_advertiser_blocked: observable,
is_dropdown_menu_visible: observable,
is_loading: observable,
is_loading_adverts: observable,
is_loading: observable,
is_submit_disabled: observable,
show_ad_popup: observable,
submitForm: observable,
Expand Down
8 changes: 8 additions & 0 deletions packages/p2p/src/stores/general-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default class GeneralStore extends BaseStore {
balance;
cancels_remaining = null;
contact_info = '';
error_code = '';
feature_level = null;
inactive_notification_count = 0;
is_advertiser = false;
Expand Down Expand Up @@ -73,6 +74,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,
error_code: observable,
feature_level: observable,
inactive_notification_count: observable,
is_advertiser: observable,
Expand Down Expand Up @@ -127,6 +129,7 @@ export default class GeneralStore extends BaseStore {
setAdvertiserSellLimit: action.bound,
setAppProps: action.bound,
setAdvertiserRelationsResponse: action.bound, //TODO: Remove this when backend has fixed is_blocked flag issue
setErrorCode: action.bound,
setFeatureLevel: action.bound,
setInactiveNotificationCount: action.bound,
setIsAdvertiser: action.bound,
Expand Down Expand Up @@ -214,6 +217,7 @@ export default class GeneralStore extends BaseStore {
);
}
} else {
this.setErrorCode(response.error.code);
this.setBlockUnblockUserError(response.error.message);
}
}
Expand Down Expand Up @@ -609,6 +613,10 @@ export default class GeneralStore extends BaseStore {
this.default_advert_description = default_advert_description;
}

setErrorCode(error_code) {
this.error_code = error_code;
}

setFeatureLevel(feature_level) {
this.feature_level = feature_level;
}
Expand Down

0 comments on commit 011e868

Please sign in to comment.