Skip to content

Commit 37ac851

Browse files
authored
Merge pull request #494 from STAPLE-verse/483-duplicate-tags
fix duplicate issue
2 parents 5743efc + 5e0e1ca commit 37ac851

2 files changed

Lines changed: 36 additions & 14 deletions

File tree

src/tags/components/TagDisplay.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,24 @@ const TagDisplay = () => {
3131
})
3232

3333
// Flatten all tags into a single array
34-
const flattenedTags = allTags.map((tag) => ({
35-
id: tag.key,
36-
text: tag.value,
37-
className: "",
38-
}))
39-
40-
// Optional: Remove duplicates
41-
const uniqueTags = Array.from(new Map(flattenedTags.map((tag) => [tag.id, tag])).values())
34+
const seenText = new Set<string>()
35+
const uniqueTags = allTags
36+
.map((tag) => ({
37+
id: tag.key,
38+
text: tag.value.trim(),
39+
className: "",
40+
}))
41+
.filter((tag) => {
42+
const normalized = tag.text.toLowerCase()
43+
if (!normalized) {
44+
return false
45+
}
46+
if (seenText.has(normalized)) {
47+
return false
48+
}
49+
seenText.add(normalized)
50+
return true
51+
})
4252
// Sort tags alphabetically by their text value
4353
uniqueTags.sort((a, b) => a.text.localeCompare(b.text))
4454

src/tags/components/TagOverall.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ export const TagOverall = ({ people, tasks, milestones }: TagOverallProps) => {
8181
content="Number of individual contributors"
8282
className="z-[1099] ourtooltips"
8383
/>
84-
<GetIconDisplay number={numIndividuals} icon={UsersIcon} />
84+
{numIndividuals === 0 ? (
85+
<span>No contributors</span>
86+
) : (
87+
<GetIconDisplay number={numIndividuals} icon={UsersIcon} />
88+
)}
8589
</div>
8690

8791
<div className="stat w-1/3 place-items-center p-4">
@@ -93,7 +97,11 @@ export const TagOverall = ({ people, tasks, milestones }: TagOverallProps) => {
9397
content="Number of project teams"
9498
className="z-[1099] ourtooltips"
9599
/>
96-
<GetIconDisplay number={numTeams} icon={UserGroupIcon} />
100+
{numTeams === 0 ? (
101+
<span>No teams</span>
102+
) : (
103+
<GetIconDisplay number={numTeams} icon={UserGroupIcon} />
104+
)}
97105
</div>
98106

99107
<div className="stat w-1/3 place-items-center p-4">
@@ -108,7 +116,11 @@ export const TagOverall = ({ people, tasks, milestones }: TagOverallProps) => {
108116
content="Number of tagged milestones"
109117
className="z-[1099] ourtooltips"
110118
/>
111-
<GetIconDisplay number={numMilestones} icon={FlagIcon} />
119+
{numMilestones === 0 ? (
120+
<span>No milestones</span>
121+
) : (
122+
<GetIconDisplay number={numMilestones} icon={FlagIcon} />
123+
)}
112124
</div>
113125

114126
<div className="stat w-1/3 place-items-center p-4">
@@ -121,7 +133,7 @@ export const TagOverall = ({ people, tasks, milestones }: TagOverallProps) => {
121133
className="z-[1099] ourtooltips"
122134
/>
123135
{tasks.length === 0 ? (
124-
<>No tasks were found</>
136+
<>No tasks</>
125137
) : (
126138
<div className="w-20 h-20 m-2">
127139
<GetCircularProgressDisplay proportion={totalPercentComplete / 100} />
@@ -139,7 +151,7 @@ export const TagOverall = ({ people, tasks, milestones }: TagOverallProps) => {
139151
className="z-[1099] ourtooltips"
140152
/>
141153
{tasks.length === 0 ? (
142-
<>No tasks were found</>
154+
<>No tasks</>
143155
) : (
144156
<div className="w-20 h-20 m-2">
145157
<GetCircularProgressDisplay proportion={totalPercentApproved / 100} />
@@ -158,7 +170,7 @@ export const TagOverall = ({ people, tasks, milestones }: TagOverallProps) => {
158170
/>
159171
<div className="h-24 flex items-center justify-center">
160172
{totalFormAssignments === 0 ? (
161-
<span>No forms required</span>
173+
<span>No forms</span>
162174
) : (
163175
<div className="w-20 h-20 m-2">
164176
<GetCircularProgressDisplay proportion={percentFormsComplete / 100} />

0 commit comments

Comments
 (0)