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

Artsem / Disable popovers + change color if user is barred #5191

Merged
merged 6 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 24 additions & 23 deletions packages/p2p/src/components/my-ads/my-ads-row-renderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ const MyAdsRowRenderer = observer(({ row: advert, setAdvert }) => {
const amount_dealt = amount - remaining_amount;
const is_buy_advert = type === buy_sell.BUY;

const onClickActivateDeactivate = () => {
my_ads_store.onClickActivateDeactivate(id, is_advert_active, setIsAdvertActive);
const onClickAddPaymentMethod = () => {
if (!general_store.is_barred) {
setAdvert(advert);
my_ads_store.showQuickAddModal(advert);
}
};
const onClickDelete = () => !general_store.is_barred && my_ads_store.onClickDelete(id);
const onClickEdit = () => !general_store.is_barred && my_ads_store.onClickEdit(id);
const onClickActivateDeactivate = () =>
my_ads_store.onClickActivateDeactivate(id, is_advert_active, setIsAdvertActive);
const onClickDelete = () => my_ads_store.onClickDelete(id);
const onClickEdit = () => my_ads_store.onClickEdit(id);
const onMouseEnter = () => setIsPopoverActionsVisible(true);
const onMouseLeave = () => setIsPopoverActionsVisible(false);

Expand Down Expand Up @@ -159,15 +164,13 @@ const MyAdsRowRenderer = observer(({ row: advert, setAdvert }) => {
);
})
) : (
<div
className='p2p-my-ads__table-add'
onClick={() => {
setAdvert(advert);
my_ads_store.showQuickAddModal(advert);
}}
>
<Icon icon='IcAdd' />
<Text color='prominent' size='xxs' weight='bold'>
<div className='p2p-my-ads__table-add' onClick={onClickAddPaymentMethod}>
<Icon color={general_store.is_barred && 'disabled'} icon='IcAdd' />
<Text
color={general_store.is_barred ? 'less-prominent' : 'prominent'}
size='xxs'
weight='bold'
>
<Localize i18n_default_text='Add' />
</Text>
</div>
Expand Down Expand Up @@ -224,15 +227,13 @@ const MyAdsRowRenderer = observer(({ row: advert, setAdvert }) => {
);
})
) : (
<div
className='p2p-my-ads__table-add'
onClick={() => {
setAdvert(advert);
my_ads_store.showQuickAddModal(advert);
}}
>
<Icon icon='IcAdd' />
<Text color='prominent' size='xxs' weight='bold'>
<div className='p2p-my-ads__table-add' onClick={onClickAddPaymentMethod}>
<Icon color={general_store.is_barred && 'disabled'} icon='IcAdd' />
<Text
color={general_store.is_barred ? 'less-prominent' : 'prominent'}
size='xxs'
weight='bold'
>
<Localize i18n_default_text='Add' />
</Text>
</div>
Expand Down Expand Up @@ -281,7 +282,7 @@ const MyAdsRowRenderer = observer(({ row: advert, setAdvert }) => {
className='p2p-my-ads__table-popovers__edit'
message={localize('Edit')}
>
<Icon icon='IcEdit' size={16} />
<Icon icon='IcEdit' color={general_store.is_barred && 'disabled'} size={16} />
</Popover>
</div>
<div onClick={onClickDelete}>
Expand Down
32 changes: 19 additions & 13 deletions packages/p2p/src/stores/my-ads-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,16 @@ export default class MyAdsStore extends BaseStore {

@action.bound
onClickActivateDeactivate(id, is_ad_active, setIsAdvertActive) {
requestWS({ p2p_advert_update: 1, id, is_active: is_ad_active ? 0 : 1 }).then(response => {
if (response.error) {
this.setActivateDeactivateErrorMessage(response.error.message);
} else {
setIsAdvertActive(!!response.p2p_advert_update.is_active);
}
this.setSelectedAdId('');
});
if (!this.root_store.general_store.is_barred) {
requestWS({ p2p_advert_update: 1, id, is_active: is_ad_active ? 0 : 1 }).then(response => {
if (response.error) {
this.setActivateDeactivateErrorMessage(response.error.message);
} else {
setIsAdvertActive(!!response.p2p_advert_update.is_active);
}
this.setSelectedAdId('');
});
}
}

@action.bound
Expand Down Expand Up @@ -226,15 +228,19 @@ export default class MyAdsStore extends BaseStore {

@action.bound
onClickDelete(id) {
this.setSelectedAdId(id);
this.setIsDeleteModalOpen(true);
if (!this.root_store.general_store.is_barred) {
this.setSelectedAdId(id);
this.setIsDeleteModalOpen(true);
}
}

@action.bound
onClickEdit(id) {
this.setSelectedAdId(id);
this.setShowEditAdForm(true);
this.getAdvertInfo();
if (!this.root_store.general_store.is_barred) {
this.setSelectedAdId(id);
this.setShowEditAdForm(true);
this.getAdvertInfo();
}
}

@action.bound
Expand Down