From ef08b72e4f5a96325625b9a41a7f9e7a0427892b Mon Sep 17 00:00:00 2001 From: NilsUeter Date: Wed, 10 May 2023 08:07:13 +0200 Subject: [PATCH] wound tracks should be unique --- src/Roster.jsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Roster.jsx b/src/Roster.jsx index f4e6e66..40f8e06 100644 --- a/src/Roster.jsx +++ b/src/Roster.jsx @@ -678,6 +678,12 @@ const Psyker = ({ psyker, index }) => { const WoundTracker = ({ woundTracker }) => { if (!woundTracker || woundTracker.length === 0) return null; + const uniqueWoundTracker = woundTracker.filter((woundTrack, index) => { + const firstIndex = woundTracker.findIndex( + (woundTrack2) => woundTrack2.name === woundTrack.name + ); + return firstIndex === index; + }); return (
@@ -699,13 +705,13 @@ const WoundTracker = ({ woundTracker }) => { color: "#fff", }} > - {[...woundTracker[0].table.keys()].map((key) => ( + {[...uniqueWoundTracker[0].table.keys()].map((key) => ( {key} ))} - {woundTracker.map((woundTrack, index) => ( + {uniqueWoundTracker.map((woundTrack, index) => ( {[...woundTrack.table.values()].map((entry) => (