Skip to content

Commit

Permalink
Merge pull request #26 from DoughFin/feature/df-107-debug-transaction…
Browse files Browse the repository at this point in the history
…s-duplicating

Reincorporate missing code from merge for finding unique transactions
  • Loading branch information
chisPmama authored Feb 26, 2024
2 parents 7a15da9 + 44b4f28 commit 14a685a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/TransactionsTable/TransactionsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ const TransactionsTable = ({ transactions }) => {
const sortedTransactions = transactions
? [...transactions].sort((a, b) => new Date(b.date) - new Date(a.date))
: [];

const transactionEntries = sortedTransactions.map((transaction) => {

const uniqueTransactions = [];
const transactionEntries = sortedTransactions.map((transaction) => {
if (!uniqueTransactions.some((t) => t.id === transaction.id)) {
uniqueTransactions.push(transaction);
let statusColor = transaction.status === 'credited' ? '#02B15A' : '#E41414';
return (
<tr className="transactions-tr" key={transaction.id}>
Expand All @@ -24,8 +27,9 @@ const TransactionsTable = ({ transactions }) => {
<td style={{ color: statusColor }} className="transactions-status-text">{titleize(transaction.status)}</td>
</tr>
);
});

}
});

return (
<section className="transactions">
<header className="transactions-header">
Expand Down

0 comments on commit 14a685a

Please sign in to comment.