Skip to content

Commit 274c4d9

Browse files
authored
Update Publications.tsx
refactor: generate id dynamically in filteredPublications map, remove manual id maintenance
1 parent 4d1a6c5 commit 274c4d9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/pages/Publications.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,8 @@ const Publications: React.FC = () => {
416416
}
417417
]
418418

419-
const filteredPublications = publications.filter(pub => {
419+
const filteredPublications = publications
420+
.filter(pub => {
420421
const matchesSearch = pub.title.toLowerCase().includes(searchTerm.toLowerCase()) ||
421422
pub.authors.some(author => author.toLowerCase().includes(searchTerm.toLowerCase())) ||
422423
pub.journal.toLowerCase().includes(searchTerm.toLowerCase())
@@ -426,6 +427,7 @@ const Publications: React.FC = () => {
426427

427428
return matchesSearch && matchesType && matchesYear
428429
})
430+
.map((pub, idx) => ({ ...pub, id: idx + 1 }));
429431

430432
const years = [...new Set(publications.map(pub => pub.year))].sort((a, b) => b - a)
431433
const stats = {

0 commit comments

Comments
 (0)