-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6cc6bd6
commit 4befbc6
Showing
3 changed files
with
129 additions
and
104 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/pages/TrueSightV2/components/TokenFilter/WatchlistSelect.tsx
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,48 @@ | ||
import { t } from '@lingui/macro' | ||
import { useMemo, useState } from 'react' | ||
import { CSSProperties } from 'styled-components' | ||
|
||
import { SelectOption } from 'components/Select' | ||
import { ActiveSelectItem, StyledSelect } from 'pages/TrueSightV2/components/TokenFilter' | ||
import { ManageListModal } from 'pages/TrueSightV2/components/WatchlistButton' | ||
import { useGetWatchlistInformationQuery } from 'pages/TrueSightV2/hooks/useKyberAIData' | ||
|
||
const WatchlistSelect = ({ | ||
menuStyle, | ||
onChangeFilter, | ||
value, | ||
}: { | ||
menuStyle: CSSProperties | ||
onChangeFilter: (key: string, value: string) => void | ||
value: string | ||
}) => { | ||
const [isOpen, setIsOpen] = useState(false) | ||
const { data: dataWatchList } = useGetWatchlistInformationQuery() | ||
const watchlistesOptions = useMemo(() => { | ||
let total = 0 | ||
const opts: SelectOption[] = | ||
dataWatchList?.watchlists?.map(e => { | ||
total += e.assetNumber | ||
return { value: e.id + '', label: `${e.name} (${e.assetNumber})` } | ||
}) || [] | ||
opts.unshift({ label: t`All Tokens (${total})`, value: '' }) | ||
opts.push({ label: t`Manage Lists`, onSelect: () => setIsOpen(true) }) // todo danh: update like desgin | ||
return opts | ||
}, [dataWatchList]) | ||
|
||
return ( | ||
<> | ||
<StyledSelect | ||
value={value} | ||
key={'watchlist'} | ||
activeRender={item => <ActiveSelectItem name={t`Watchlist`} label={item?.label} />} | ||
options={watchlistesOptions} | ||
onChange={value => onChangeFilter('watchlist', value)} | ||
optionStyle={{ fontSize: '14px' }} | ||
menuStyle={menuStyle} | ||
/> | ||
<ManageListModal isOpen={isOpen} setIsOpen={setIsOpen} /> | ||
</> | ||
) | ||
} | ||
export default WatchlistSelect |
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