diff --git a/src/app/groups/[groupId]/balances-list.tsx b/src/app/groups/[groupId]/balances-list.tsx index c0cffa9..c0d48b9 100644 --- a/src/app/groups/[groupId]/balances-list.tsx +++ b/src/app/groups/[groupId]/balances-list.tsx @@ -40,21 +40,23 @@ export function BalancesList({ balances, participants, currency }: Props) {
{currency} {(balances[participant.id]?.total ?? 0).toFixed(2)}
-
0 - ? 'bg-green-200 left-0 rounded-r-lg border border-green-300' - : 'bg-red-200 right-0 rounded-l-lg border border-red-300', - )} - style={{ - width: - (Math.abs(balances[participant.id]?.total ?? 0) / - maxBalance) * - 100 + - '%', - }} - >
+ {balances[participant.id]?.total !== 0 && ( +
0 + ? 'bg-green-200 left-0 rounded-r-lg border border-green-300' + : 'bg-red-200 right-0 rounded-l-lg border border-red-300', + )} + style={{ + width: + (Math.abs(balances[participant.id]?.total ?? 0) / + maxBalance) * + 100 + + '%', + }} + >
+ )} ))} diff --git a/src/lib/balances.ts b/src/lib/balances.ts index a53bd01..20a83fb 100644 --- a/src/lib/balances.ts +++ b/src/lib/balances.ts @@ -50,9 +50,9 @@ function divide(total: number, count: number, isLast: boolean): number { export function getSuggestedReimbursements( balances: Balances, ): Reimbursement[] { - const balancesArray = Object.entries(balances).map( - ([participantId, { total }]) => ({ participantId, total }), - ) + const balancesArray = Object.entries(balances) + .map(([participantId, { total }]) => ({ participantId, total })) + .filter((b) => b.total !== 0) balancesArray.sort((b1, b2) => b2.total - b1.total) const reimbursements: Reimbursement[] = [] while (balancesArray.length > 1) {