UNPKG

@ledgerhq/live-common

Version:
32 lines 1.61 kB
import React, { useMemo } from "react"; import { useMarketByCurrencies } from "../../../dada-client/hooks/useMarketByCurrencies"; import counterValueFormatter from "../../../market/utils/countervalueFormatter"; const createMarketPriceItem = ({ price, percent, MarketPriceIndicator, }) => React.createElement(MarketPriceIndicator, { percent: percent, price: price }); export const useRightMarketTrendModule = ({ currencies, useBalanceDeps, MarketPriceIndicator, }) => { const marketByCurrencies = useMarketByCurrencies(currencies); const { counterValueCurrency, locale } = useBalanceDeps(); return useMemo(() => { return currencies.map(currency => { const currencyMarket = marketByCurrencies[currency.id]; if (!currencyMarket || currencyMarket.priceChangePercentage24h === undefined || currencyMarket.price === undefined) { return currency; } const priceFormatted = counterValueFormatter({ value: currencyMarket.price, currency: counterValueCurrency.ticker, locale, }); return { ...currency, rightElement: createMarketPriceItem({ percent: currencyMarket.priceChangePercentage24h, price: priceFormatted, MarketPriceIndicator, }), }; }); }, [currencies, marketByCurrencies, counterValueCurrency.ticker, locale, MarketPriceIndicator]); }; //# sourceMappingURL=useRightMarketTrendModule.js.map