import { useTranslations } from 'next-intl' import { formatBigIntToString } from '@utils/bigint/format' import { Token } from '@types' const ReceivedTokenSection = ({ withdrawQuote, poolTokens, chainId, }: { withdrawQuote: any poolTokens: Token[] chainId: number }) => { const t = useTranslations('Pools') // If withdrawQuote or outputs in withdrawQuote is undefined, return null if (!withdrawQuote || !withdrawQuote.outputs) return null // Cannot handle nativeTokens currently without state reworking to make accessible the pools object // const tokensArray = poolTokens ? poolTokens : pool.nativeTokens; // Using the appropriate tokens array const tokensArray = poolTokens // If the "ALL" key exists, use its array. Otherwise, convert the outputs object into an array const outputsArray = withdrawQuote.outputs.ALL ? withdrawQuote.outputs.ALL : Object.values(withdrawQuote.outputs) return (

{t('You will receive')}

{tokensArray && outputsArray .filter((output) => tokensArray[output.index]) // Using the output's index to filter the tokens .map((output) => { const token = tokensArray[output.index] // Using the output's index to fetch the corresponding token return ( // Added a key for mapped elements
{formatBigIntToString( output.value, // Adjusted to use output.value directly token.decimals[chainId], 6 )} {token.symbol}
) })}
) } export default ReceivedTokenSection