/* eslint-disable @typescript-eslint/indent */ import { Avatar, Box, Stack, Typography } from '@mui/material'; import { BN } from '@ocap/util'; import { useLocaleContext } from '@arcblock/ux/lib/Locale/context'; import DID from '@arcblock/ux/lib/DID'; import { formatBNStr, formatLinkWithLocale } from '../libs/util'; export interface TBeneficiary { name: string; address: string; avatar?: string; percent: number; amount?: string; url?: string; type?: 'user' | 'dapp'; } interface BenefitsProps { data: TBeneficiary[]; currency: { symbol: string; decimal: number; maximum_precision?: number; }; totalAmount?: string; } export default function PaymentBeneficiaries({ data, currency, totalAmount = '0' }: BenefitsProps) { const { t, locale } = useLocaleContext(); return ( {t('benefits.title', { count: data.length })} {data.map((item) => { const amount = item.amount || (totalAmount ? new BN(totalAmount) .mul(new BN(Number(item.percent))) .div(new BN(100)) .toString() : '0'); return ( { if (item.url) { window.open(formatLinkWithLocale(item.url, locale), '_blank'); } }} sx={{ cursor: item.url ? 'pointer' : 'default', '&:hover': { color: item.url ? 'text.link' : 'inherit', }, }}> {item.name} {formatBNStr(amount, currency.decimal, currency?.maximum_precision ?? 6)} {currency.symbol} {Number(item.percent)}% ); })} ); }