-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adrienne / Added search functionality for list of blocked advertisers (…
…#6005) * Added search functionality * Refactored code changes * Refactored code changes * Renamed BlockedAdvertisersList to BlockUserList * Fixed issues with block advertiser list table height * Fixed issue with search box not loading * Fixed an issue where the profile header is not fully width * Reduced margin bottom height for tabs and stats height due to flex
- Loading branch information
1 parent
753ac40
commit bf02178
Showing
10 changed files
with
173 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
packages/p2p/src/components/my-profile/block-user/block-user.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React from 'react'; | ||
import { observer } from 'mobx-react-lite'; | ||
import { useStores } from 'Stores'; | ||
import { DesktopWrapper, MobileFullPageModal, MobileWrapper } from '@deriv/components'; | ||
import BlockUserModal from 'Components/block-user/block-user-modal'; | ||
import BlockUserTable from 'Components/my-profile/block-user/block-user-table/block-user-table'; | ||
import SearchBox from 'Components/search-box'; | ||
import { my_profile_tabs } from 'Constants/my-profile-tabs'; | ||
import debounce from 'lodash.debounce'; | ||
import { localize } from 'Components/i18next'; | ||
|
||
const BlockUserList = observer(() => { | ||
const { my_profile_store } = useStores(); | ||
|
||
const loadBlockedAdvertisers = debounce(search => { | ||
my_profile_store.setSearchTerm(search.trim()); | ||
my_profile_store.loadMoreBlockedAdvertisers(); | ||
}, 200); | ||
|
||
const onSearch = search => { | ||
// Ensures that blocked advertisers list is not reloaded if search term entered is the same | ||
if (my_profile_store.search_term !== search.trim()) { | ||
my_profile_store.setIsLoading(true); | ||
loadBlockedAdvertisers(search); | ||
} | ||
}; | ||
|
||
const onClear = () => { | ||
my_profile_store.setSearchTerm(''); | ||
my_profile_store.setSearchResults([]); | ||
}; | ||
|
||
return ( | ||
<div className='block-user__list'> | ||
{my_profile_store.blocked_advertisers_list.length > 0 && ( | ||
<SearchBox onClear={onClear} onSearch={onSearch} placeholder={localize('Search')} /> | ||
)} | ||
<BlockUserTable /> | ||
</div> | ||
); | ||
}); | ||
|
||
const BlockUser = () => { | ||
const { general_store, my_profile_store } = useStores(); | ||
|
||
return ( | ||
<React.Fragment> | ||
<BlockUserModal | ||
advertiser_name={my_profile_store.selected_blocked_user.name} | ||
is_advertiser_blocked | ||
is_block_user_modal_open={general_store.is_block_user_modal_open} | ||
onCancel={() => general_store.setIsBlockUserModalOpen(false)} | ||
onSubmit={my_profile_store.onSubmit} | ||
/> | ||
<DesktopWrapper> | ||
<BlockUserList /> | ||
</DesktopWrapper> | ||
<MobileWrapper> | ||
<MobileFullPageModal | ||
body_className='block-user__modal' | ||
height_offset='80px' | ||
is_flex | ||
is_modal_open | ||
page_header_className='buy-sell__modal-header' | ||
page_header_text={localize('Blocked advertisers')} | ||
pageHeaderReturnFn={() => my_profile_store.setActiveTab(my_profile_tabs.MY_STATS)} | ||
> | ||
<BlockUserList /> | ||
</MobileFullPageModal> | ||
</MobileWrapper> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export default observer(BlockUser); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import BlockUser from './block-user'; | ||
|
||
export default BlockUser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
...components/my-profile/my-profile-stats/my-profile-stats-table/my-profile-stats-table.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/p2p/src/components/my-profile/my-profile-stats/my-profile-stats.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
.my-profile-stats { | ||
&-separator { | ||
margin: 1.6rem 0; | ||
|
||
@include mobile { | ||
margin: 1.6rem -1.6rem; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters