Skip to content

Commit

Permalink
fix: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre committed Jan 28, 2025
1 parent d076f53 commit 5791fe5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
40 changes: 24 additions & 16 deletions src/components/AssetSelectModal/AssetSelectModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { isNft } from 'lib/utils'
import type { Asset } from 'types/Asset'

import { AssetList } from './AssetList'
import type { ChainRow } from './ChainButton'
import { ChainButton } from './ChainButton'
import { filterAssetsBySearchTerm } from './helpers/filterAssetsBySearchTerm'

Expand All @@ -28,9 +27,15 @@ type AssetSelectModalProps = {
onClick: (asset: Asset) => void
}

type NetworkItem = {
chainId: ChainId
icon: string
name: string
}

export const AssetSelectModal: React.FC<AssetSelectModalProps> = ({ isOpen, onClose, onClick }) => {
const [searchQuery, setSearchQuery] = useState('')
const assets = useMemo(() => Object.values(AssetData), [])
const assets = useMemo(() => Object.values(AssetData) as Asset[], [])
const [activeChain, setActiveChain] = useState<ChainId | 'All'>('All')
const [searchTermAssets, setSearchTermAssets] = useState<Asset[]>([])
const iniitalRef = useRef(null)
Expand Down Expand Up @@ -82,21 +87,24 @@ export const AssetSelectModal: React.FC<AssetSelectModalProps> = ({ isOpen, onCl

const listAssets = searching ? searchTermAssets : filteredAssets

const uniqueChainIds: ChainRow[] = assets.reduce((accumulator, currentAsset: Asset) => {
const existingEntry = accumulator.find(
(entry: ChainRow) => entry.chainId === currentAsset.chainId,
)

if (!existingEntry) {
accumulator.push({
chainId: currentAsset.chainId,
icon: currentAsset.networkIcon ?? currentAsset.icon,
name: currentAsset.networkName ?? currentAsset.name,
})
}
const uniqueChainIds: NetworkItem[] = assets.reduce<NetworkItem[]>(
(accumulator, currentAsset) => {
const existingEntry = accumulator.find(
(entry: NetworkItem) => entry.chainId === currentAsset.chainId,
)

return accumulator
}, [])
if (!existingEntry) {
accumulator.push({
chainId: currentAsset.chainId,
icon: currentAsset.networkIcon || currentAsset.icon,
name: currentAsset.networkName || currentAsset.name,
})
}

return accumulator
},
[],
)

const renderRows = useMemo(() => {
return <AssetList assets={listAssets} handleClick={handleClick} />
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useLocaleFormatter/useLocaleFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const getParts = (locale: string, fiatType = 'USD') => {
style: 'currency',
useGrouping: true,
})
const parts = groupFormatter.formatToParts(1234567.1234567890123456789)
const parts = groupFormatter.formatToParts(1234567)
const groups = parts.filter(p => p.type === 'integer')

// @TODO: Do we want to support non-arabic numerals?
Expand Down

0 comments on commit 5791fe5

Please sign in to comment.