From f17d1d2f42f1e62a4f71cf032a9813a05c2a4d62 Mon Sep 17 00:00:00 2001 From: ameerul-deriv <103412909+ameerul-deriv@users.noreply.github.com> Date: Tue, 9 Aug 2022 20:24:21 +0800 Subject: [PATCH] Ameerul /Task #65487 Dropdown Block User Feature (#5682) * added dropdown, menu dots icon, added function for users to block advertisers with block user modal * refactored code, and renamed dropdown component to advertiser-page-dropdown-menu * renamed variables and functions according to comments * refactored block user function in advertiser-page-store and block-user-modal * minor changes to the imports * merged with master and added changes * removed old blockUser and showModal functions from advertiser store * removed is_blocked from dropdown * refactored code with comments * moved showBlockUserModal function to the store * removed curly brackets in name * fixed gap in modal * fixed tooltip message and user cannot block themselves * fixed dropdown darkmode design and hid menu dots icon when user is blocked * changed dropdown hover colour * added useOnClickOutisde Hook to hide dropdown when clicked outside --- .../components/icon/common/ic-menu-dots.svg | 1 + .../components/src/components/icon/icons.js | 1 + packages/components/stories/icon/icons.js | 31 ++++----- .../advertiser-page-dropdown-menu.jsx | 66 +++++++++++++++++++ .../advertiser-page/advertiser-page.jsx | 35 ++++++---- .../advertiser-page/advertiser-page.scss | 65 ++++++++++++++++++ .../block-user/block-user-count.jsx | 16 +++-- .../block-user-overlay.scss | 2 +- .../block-user-modal/block-user-modal.jsx | 3 +- .../block-user-modal/block-user-modal.scss | 5 ++ .../block-user/block-user-modal/index.js | 1 + .../p2p/src/stores/advertiser-page-store.js | 31 +++++++++ 12 files changed, 221 insertions(+), 36 deletions(-) create mode 100644 packages/components/src/components/icon/common/ic-menu-dots.svg create mode 100644 packages/p2p/src/components/advertiser-page/advertiser-page-dropdown-menu.jsx create mode 100644 packages/p2p/src/components/block-user/block-user-modal/block-user-modal.scss diff --git a/packages/components/src/components/icon/common/ic-menu-dots.svg b/packages/components/src/components/icon/common/ic-menu-dots.svg new file mode 100644 index 000000000000..36f7407a70fc --- /dev/null +++ b/packages/components/src/components/icon/common/ic-menu-dots.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/components/src/components/icon/icons.js b/packages/components/src/components/icon/icons.js index 3077ecd22fb1..1e2c1b70eb89 100644 --- a/packages/components/src/components/icon/icons.js +++ b/packages/components/src/components/icon/icons.js @@ -283,6 +283,7 @@ import './common/ic-lookbacks.svg'; import './common/ic-loss.svg'; import './common/ic-macos-logo.svg'; import './common/ic-macos.svg'; +import './common/ic-menu-dots.svg'; import './common/ic-message-delivered.svg'; import './common/ic-message-errored.svg'; import './common/ic-message-pending.svg'; diff --git a/packages/components/stories/icon/icons.js b/packages/components/stories/icon/icons.js index 13efaa9f02f2..9596b32341e1 100644 --- a/packages/components/stories/icon/icons.js +++ b/packages/components/stories/icon/icons.js @@ -13,7 +13,7 @@ export const icons = 'IcBrandDmt5', 'IcBrandDtrader', 'IcBrandDxtrade', - 'IcBrandSmarttrader', + 'IcBrandSmarttrader' ], 'cashier': [ 'IcCashierAdd', @@ -141,7 +141,7 @@ export const icons = 'IcCashierXanpoolLight', 'IcCashierXanpoolSmallDark', 'IcCashierXanpoolSmallLight', - 'IcCashier', + 'IcCashier' ], 'common': [ 'IcAccountError', @@ -290,6 +290,7 @@ export const icons = 'IcLoss', 'IcMacosLogo', 'IcMacos', + 'IcMenuDots', 'IcMessageDelivered', 'IcMessageErrored', 'IcMessagePending', @@ -394,7 +395,7 @@ export const icons = 'IcWindows', 'IcWip', 'IcZoomIn', - 'IcZoomOut', + 'IcZoomOut' ], 'contract': [ 'IcContractBarrier', @@ -410,7 +411,7 @@ export const icons = 'IcContractSafeguard', 'IcContractStartTimeCircle', 'IcContractStartTime', - 'IcContractTarget', + 'IcContractTarget' ], 'currency': [ 'IcCurrencyAud', @@ -432,7 +433,7 @@ export const icons = 'IcCurrencyUsdc', 'IcCurrencyUsdk', 'IcCurrencyUst', - 'IcCurrencyVirtual', + 'IcCurrencyVirtual' ], 'dxtrade': [ 'IcDxtradeDeviceDesktopLight', @@ -447,7 +448,7 @@ export const icons = 'IcDxtradeFinancial', 'IcDxtradeOnePassword', 'IcDxtradeSyntheticPlatform', - 'IcDxtradeSynthetic', + 'IcDxtradeSynthetic' ], 'flag': [ 'IcFlagDe', @@ -463,7 +464,7 @@ export const icons = 'IcFlagUk', 'IcFlagVi', 'IcFlagZhCn', - 'IcFlagZhTw', + 'IcFlagZhTw' ], 'mt5': [ 'IcMt5CfdPlatform', @@ -490,7 +491,7 @@ export const icons = 'IcMt5SyntheticIndices', 'IcMt5SyntheticPlatform', 'IcMt5Synthetic', - 'IcMt5TradeTypes', + 'IcMt5TradeTypes' ], 'option': [ 'IcOptionCallPutReset', @@ -508,7 +509,7 @@ export const icons = 'IcOptionRaiseFall', 'IcOptionStayinGoesout', 'IcOptionTouchNotouch', - 'IcOptionUpDownAsian', + 'IcOptionUpDownAsian' ], 'stock': [ 'IcStockAdidasSalomon', @@ -558,7 +559,7 @@ export const icons = 'IcStockVisa', 'IcStockWallMart', 'IcStockWaltDisney', - 'IcStockZoom', + 'IcStockZoom' ], 'tradetype': [ 'IcTradetypeAsiand', @@ -593,7 +594,7 @@ export const icons = 'IcTradetypeRunlow', 'IcTradetypeTickhigh', 'IcTradetypeTicklow', - 'IcTradetypeUpordown', + 'IcTradetypeUpordown' ], 'underlying': [ 'IcUnderlying1HZ100V', @@ -750,7 +751,7 @@ export const icons = 'IcUnderlyingWLDEUR', 'IcUnderlyingWLDGBP', 'IcUnderlyingWLDUSD', - 'IcUnderlyingWLDXAU', + 'IcUnderlyingWLDXAU' ], 'wallet': [ 'IcWalletClearFunds', @@ -786,6 +787,6 @@ export const icons = 'IcWalletWebmoneyLight', 'IcWalletWebmoney', 'IcWalletZingpayDark', - 'IcWalletZingpayLight', - ], -} + 'IcWalletZingpayLight' + ] +} \ No newline at end of file diff --git a/packages/p2p/src/components/advertiser-page/advertiser-page-dropdown-menu.jsx b/packages/p2p/src/components/advertiser-page/advertiser-page-dropdown-menu.jsx new file mode 100644 index 000000000000..e978b95ca58a --- /dev/null +++ b/packages/p2p/src/components/advertiser-page/advertiser-page-dropdown-menu.jsx @@ -0,0 +1,66 @@ +import React from 'react'; +import { observer } from 'mobx-react-lite'; +import PropTypes from 'prop-types'; +import { Dropdown, Icon, Text } from '@deriv/components'; +import { Localize } from 'Components/i18next'; +import { useStores } from 'Stores'; +import { useOnClickOutside } from '../../../../components/src/hooks'; +import './advertiser-page.scss'; + +const AdvertiserPageDropdownMenu = ({ is_my_advert }) => { + const dropdown_menu_ref = React.useRef(); + const { advertiser_page_store } = useStores(); + + const onClickOutside = () => { + advertiser_page_store.setIsDropdownMenuVisible(false); + }; + + useOnClickOutside(dropdown_menu_ref, onClickOutside, () => advertiser_page_store.is_dropdown_menu_visible); + + return ( + !advertiser_page_store.is_counterparty_advertiser_blocked && ( +