import { Balances } from '@/lib/balances' import { cn, formatCurrency } from '@/lib/utils' import { Participant } from '@prisma/client' import { useLocale } from 'next-intl' type Props = { balances: Balances participants: Participant[] currency: string } export function BalancesList({ balances, participants, currency }: Props) { const locale = useLocale() const maxBalance = Math.max( ...Object.values(balances).map((b) => Math.abs(b.total)), ) return (
{participants.map((participant) => { const balance = balances[participant.id]?.total ?? 0 const isLeft = balance >= 0 return (
{participant.name}
{formatCurrency(currency, balance, locale)}
{balance !== 0 && (
)}
) })}
) }