diff --git a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/getBioEntitiesIdsFromReaction.ts b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/getBioEntitiesIdsFromReaction.ts deleted file mode 100644 index 05a446750e483ef9ffd148a5d3192acba219538e..0000000000000000000000000000000000000000 --- a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/getBioEntitiesIdsFromReaction.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { NewReaction } from '@/types/models'; - -export const getBioEntitiesIdsFromReaction = (reaction: NewReaction): string[] => { - const { products, reactants, modifiers } = reaction; - const productsIds = products.map(p => p.element); - const reactantsIds = reactants.map(r => r.element); - const modifiersIds = modifiers.map(m => m.element); - return [...productsIds, ...reactantsIds, ...modifiersIds].map(identifier => String(identifier)); -}; diff --git a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts index e326806c7278d206a711965ea8204c257fdab1a5..963fc428dadfd5066eb64c9cf20298c281657117 100644 --- a/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts +++ b/src/components/Map/MapViewer/utils/listeners/mapSingleClick/handleReactionResults.ts @@ -11,8 +11,8 @@ import { apiPath } from '@/redux/apiPath'; import { validateDataUsingZodSchema } from '@/utils/validateDataUsingZodSchema'; import { getMultiBioEntityByIds } from '@/redux/bioEntity/thunks/getMultiBioEntity'; import { newReactionSchema } from '@/models/newReactionSchema'; +import getModelElementsIdsFromReaction from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction'; import { handleReactionSearchClickFailure } from './handleReactionSearchClickFailure'; -import { getBioEntitiesIdsFromReaction } from './getBioEntitiesIdsFromReaction'; import { findClosestReactionPoint } from './findClosestReactionPoint'; type SearchConfig = { @@ -35,7 +35,7 @@ export const handleReactionResults = } const reaction = payload.data[FIRST_ARRAY_ELEMENT]; - const bioEntitiesIds = getBioEntitiesIdsFromReaction(reaction); + const bioEntitiesIds = getModelElementsIdsFromReaction(reaction); if (searchConfig && searchConfig.searchDistance) { const { maxZoom, point, searchDistance, zoom, isResultDrawerOpen } = searchConfig; @@ -64,7 +64,7 @@ export const handleReactionResults = getMultiBioEntityByIds({ elementsToFetch: bioEntitiesIds.map((bioEntityId) => { return { - elementId: parseInt(bioEntityId, 10), + elementId: bioEntityId, modelId, type: 'ALIAS' }; diff --git a/src/redux/bioEntity/thunks/getMultiBioEntity.ts b/src/redux/bioEntity/thunks/getMultiBioEntity.ts index dad84c23999040857bbf4cae0cce37a6a6c923bb..2b84e65ab0a67b57e4e9843150a806812d0cfa88 100644 --- a/src/redux/bioEntity/thunks/getMultiBioEntity.ts +++ b/src/redux/bioEntity/thunks/getMultiBioEntity.ts @@ -44,8 +44,11 @@ export const getMultiBioEntity = createAsyncThunk< dispatch: dispatch as AppDispatch, getState: getState as typeof store.getState, }); + const bioEntitiesStringIds = bioEntitiesIds.map(id => String(id)); if (bioEntitiesIds.length > ZERO) { - await dispatch(getMultiBioEntity({ searchQueries: bioEntitiesIds, isPerfectMatch: true })); + await dispatch( + getMultiBioEntity({ searchQueries: bioEntitiesStringIds, isPerfectMatch: true }), + ); } return bioEntityContents; @@ -90,7 +93,8 @@ export const getMultiBioEntityByIds = createAsyncThunk< getState: getState as typeof store.getState, }); if (bioEntitiesIds.length > ZERO) { - await dispatch(getMultiBioEntity({ searchQueries: bioEntitiesIds, isPerfectMatch: true })); + const searchQueries = bioEntitiesIds.map(id => String(id)); + await dispatch(getMultiBioEntity({ searchQueries, isPerfectMatch: true })); } return bioEntities; diff --git a/src/redux/bioEntity/thunks/utils/fetchReactionsAndGetBioEntitiesIds.ts b/src/redux/bioEntity/thunks/utils/fetchReactionsAndGetBioEntitiesIds.ts index 7859a427d82bd7011f2576316d76c0508dba7115..cae4025d558e37db7152454cedd14d1a4358dfe6 100644 --- a/src/redux/bioEntity/thunks/utils/fetchReactionsAndGetBioEntitiesIds.ts +++ b/src/redux/bioEntity/thunks/utils/fetchReactionsAndGetBioEntitiesIds.ts @@ -1,4 +1,3 @@ -import { getBioEntitiesIdsFromReaction } from '@/components/Map/MapViewer/utils/listeners/mapSingleClick/getBioEntitiesIdsFromReaction'; import { FIRST_ARRAY_ELEMENT, SIZE_OF_EMPTY_ARRAY } from '@/constants/common'; import { openReactionDrawerById, selectTab } from '@/redux/drawer/drawer.slice'; import { openMapAndOrSetActiveIfSelected } from '@/redux/map/map.slice'; @@ -6,6 +5,7 @@ import { modelsNameMapSelector } from '@/redux/models/models.selectors'; import { getReactionsByIds } from '@/redux/reactions/reactions.thunks'; import type { AppDispatch, store } from '@/redux/store'; import type { BioEntityContent, NewReaction } from '@/types/models'; +import getModelElementsIdsFromReaction from '@/components/Map/MapViewer/MapViewerVector/listeners/mouseClick/getModelElementsIdsFromReaction'; interface Args { bioEntityContents: BioEntityContent[]; @@ -73,7 +73,7 @@ const handleReactionShowInfoAndOpenMap = async ( ); }; -export const fetchReactionsAndGetBioEntitiesIds = async (args: Args): Promise<string[]> => { +export const fetchReactionsAndGetBioEntitiesIds = async (args: Args): Promise<number[]> => { const { dispatch, bioEntityContents } = args; const bioEntityReactionsIds = getReactionsIdsFromBioEntities(bioEntityContents || []); @@ -86,7 +86,9 @@ export const fetchReactionsAndGetBioEntitiesIds = async (args: Args): Promise<st return []; } - const bioEntitiesIds = reactions.map(reaction => getBioEntitiesIdsFromReaction(reaction)).flat(); + const bioEntitiesIds = reactions + .map(reaction => getModelElementsIdsFromReaction(reaction)) + .flat(); const firstReaction = reactions[FIRST_ARRAY_ELEMENT]; if (firstReaction) { handleReactionShowInfoAndOpenMap(args, firstReaction);