From afe198f81883ac8ca6069e76477e66cd08d8457f Mon Sep 17 00:00:00 2001 From: ArtemHolikov Date: Thu, 21 Nov 2024 15:34:29 +0200 Subject: [PATCH] fixed two identical items displaying --- .../ProfessionalCategoryList.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/containers/edit-profile/professional-info-tab/professional-category-list/ProfessionalCategoryList.tsx b/src/containers/edit-profile/professional-info-tab/professional-category-list/ProfessionalCategoryList.tsx index 714043ef7..b8394702d 100644 --- a/src/containers/edit-profile/professional-info-tab/professional-category-list/ProfessionalCategoryList.tsx +++ b/src/containers/edit-profile/professional-info-tab/professional-category-list/ProfessionalCategoryList.tsx @@ -15,13 +15,18 @@ const ProfessionalCategoryList: FC = ({ openProfessionalCategoryModal, handleDeleteCategory }) => { - const professionalCategoryItems = items.map((item) => { + const uniqueItems = items.filter( + (item, index, array) => + array.findIndex((i) => i.category._id === item.category._id) === index + ) + + const professionalCategoryItems = uniqueItems.map((item) => { const handleDelete = () => handleDeleteCategory(item._id, item.category._id) return ( )