Skip to content
Snippets Groups Projects

feat: publications modal elements links + reaction search (MIN-241, MIN-229)

Files
2
import { getBioEntitiesIdsFromReaction } from '@/components/Map/MapViewer/utils/listeners/mapSingleClick/getBioEntitiesIdsFromReaction';
import { SIZE_OF_EMPTY_ARRAY, ZERO } from '@/constants/common';
import { bioEntityResponseSchema } from '@/models/bioEntityResponseSchema';
import { apiPath } from '@/redux/apiPath';
import { selectTab } from '@/redux/drawer/drawer.slice';
import { axiosInstanceNewAPI } from '@/services/api/utils/axiosInstance';
import { BioEntityContent, BioEntityResponse } from '@/types/models';
import { PerfectSearchParams } from '@/types/search';
@@ -11,9 +8,7 @@ import { getErrorMessage } from '@/utils/getErrorMessage';
import { validateDataUsingZodSchema } from '@/utils/validateDataUsingZodSchema';
import { createAsyncThunk } from '@reduxjs/toolkit';
import { addNumbersToEntityNumberData } from '../../entityNumber/entityNumber.slice';
import { getReactionsByIds } from '../../reactions/reactions.thunks';
import { BIO_ENTITY_FETCHING_ERROR_PREFIX } from '../bioEntity.constants';
import { getMultiBioEntity } from '../bioEntity.thunks';
type GetBioEntityProps = PerfectSearchParams;
@@ -37,38 +32,6 @@ export const getBioEntity = createAsyncThunk<
bioEntityResponseSchema,
);
const bioEntityReactionsIds = (response.data?.content || [])
.filter(c => c?.bioEntity?.idReaction)
.map(c => c?.bioEntity?.id)
.filter((id): id is number => typeof id === 'number');
if (bioEntityReactionsIds.length > ZERO) {
dispatch(
getReactionsByIds({
ids: bioEntityReactionsIds,
shouldConcat: true,
}),
).then(async result => {
if (typeof result.payload === 'string') return;
const reactions = result.payload?.data;
if (!reactions || reactions.length === SIZE_OF_EMPTY_ARRAY) return;
const bioEntitiesIds = reactions
.map(reaction => getBioEntitiesIdsFromReaction(reaction))
.flat();
// dispatch(openReactionDrawerById(reactions[FIRST_ARRAY_ELEMENT].id));
dispatch(selectTab(''));
await dispatch(
getMultiBioEntity({
searchQueries: bioEntitiesIds,
isPerfectMatch: true,
}),
);
});
}
if (addNumbersToEntityNumber && response.data.content) {
const bioEntityIds = response.data.content.map(b => b.bioEntity.elementId);
dispatch(addNumbersToEntityNumberData(bioEntityIds));
Loading