Mp 2227 assetselect search (#782)

* feat: split perps into active and non active positions

* fix: fixed the search of assets selector

* fix: according to feedback
This commit is contained in:
Linkie Link 2024-02-09 08:42:37 +01:00 committed by GitHub
parent 6ac7708ca5
commit 413f8c43c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -87,18 +87,16 @@ export default function AssetOverlay(props: Props) {
)
const [activePerpsPositions, availablePerpsMarkets] = useMemo(() => {
const activePerpsPositions =
account?.perps.length === 0
? []
: props.buyAssets.filter((assets) =>
account?.perps.find((perp) => perp.denom === assets.denom),
)
const availablePerpsMarkets = props.buyAssets.filter(
if (!account) return [[], []]
const activePerpsPositions = assets.filter((assets) =>
account?.perps.find((perp) => perp.denom === assets.denom),
)
const availablePerpsMarkets = assets.filter(
(assets) => !activePerpsPositions.find((perp) => perp.denom === assets.denom),
)
return [activePerpsPositions, availablePerpsMarkets]
}, [props.buyAssets, account])
}, [assets, account])
return (
<Overlay