From 8f020590626c37f1066fb8d9fab0b7176821f20d Mon Sep 17 00:00:00 2001 From: MahtabBukhari Date: Sun, 22 Sep 2024 00:06:06 +0500 Subject: [PATCH] fix(unique-node-types): node types in dropdown should be unique --- .../Body/AddEdgeNode/Title/ToNode/index.tsx | 3 ++- .../BlueprintModal/Body/Editor/index.tsx | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/ModalsContainer/BlueprintModal/Body/AddEdgeNode/Title/ToNode/index.tsx b/src/components/ModalsContainer/BlueprintModal/Body/AddEdgeNode/Title/ToNode/index.tsx index 911f29f2e..ebd97e721 100644 --- a/src/components/ModalsContainer/BlueprintModal/Body/AddEdgeNode/Title/ToNode/index.tsx +++ b/src/components/ModalsContainer/BlueprintModal/Body/AddEdgeNode/Title/ToNode/index.tsx @@ -49,13 +49,14 @@ export const ToNode: FC = ({ onSelect, dataTestId, edgeLink, hideSelectAl const schemaOptions = data.schemas .filter((schema) => !schema.is_deleted && schema.type) .map((schema) => - schema?.type === 'thing' + schema.type === 'thing' ? { label: 'No Parent', value: schema.type } : { label: capitalizeFirstLetter(schema.type), value: schema.type, }, ) + .filter((option, index, self) => index === self.findIndex((o) => o.value === option.value)) const allOption = { label: 'Select all', value: 'all' } diff --git a/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx b/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx index 794e6171b..8bdc1ca99 100644 --- a/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx +++ b/src/components/ModalsContainer/BlueprintModal/Body/Editor/index.tsx @@ -147,11 +147,13 @@ const fetchAndSetOptions = async ( (schema) => !schema.is_deleted && schema.type && (!filterFunc || filterFunc(schema)), ) - const options = filteredSchemas.map((schema) => - schema.type === 'thing' - ? { label: 'No Parent', value: schema.type } - : { label: capitalizeFirstLetter(schema.type), value: schema.type }, - ) + const options = filteredSchemas + .map((schema) => + schema.type === 'thing' + ? { label: 'No Parent', value: schema.type } + : { label: capitalizeFirstLetter(schema.type), value: schema.type }, + ) + .filter((option, index, self) => index === self.findIndex((o) => o.value === option.value)) setOptions(options) } catch (error) {