From 9f3b628d58354b72b1504002fdec6c99b7612bf5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrian=20Or=C5=82=C3=B3w?= <adrian.orlow@fishbrain.com>
Date: Mon, 26 Feb 2024 17:06:48 +0100
Subject: [PATCH] feat: add rfc changes

---
 .../AssociatedSubmap.component.test.tsx       | 28 +++++++++------
 .../BioEntityDrawer.component.tsx             |  1 +
 .../ChemicalsList/ChemicalsList.component.tsx |  9 ++---
 .../DrugsList/DrugsList.component.tsx         |  3 +-
 .../ResultsList.component.test.tsx            | 11 +++---
 .../SearchDrawerWrapper.component.test.tsx    | 10 ++++--
 src/redux/drawer/drawerFixture.ts             | 35 +++++++++++++++----
 7 files changed, 69 insertions(+), 28 deletions(-)

diff --git a/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx b/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx
index 0b3e93aa..d3880a09 100644
--- a/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx
+++ b/src/components/Map/Drawer/BioEntityDrawer/AssociatedSubmap/AssociatedSubmap.component.test.tsx
@@ -1,23 +1,23 @@
-import { StoreType } from '@/redux/store';
-import {
-  InitialStoreState,
-  getReduxWrapperWithStore,
-} from '@/utils/testing/getReduxWrapperWithStore';
-import { act, render, screen } from '@testing-library/react';
+import { SIZE_OF_ARRAY_WITH_ONE_ELEMENT, ZERO } from '@/constants/common';
+import { bioEntityContentFixture } from '@/models/fixtures/bioEntityContentsFixture';
+import { MODELS_MOCK_SHORT } from '@/models/mocks/modelsMock';
 import {
   BIOENTITY_INITIAL_STATE_MOCK,
   BIO_ENTITY_LINKING_TO_SUBMAP_DATA_MOCK,
 } from '@/redux/bioEntity/bioEntity.mock';
-import { bioEntityContentFixture } from '@/models/fixtures/bioEntityContentsFixture';
 import { DRAWER_INITIAL_STATE } from '@/redux/drawer/drawer.constants';
-import { MODELS_INITIAL_STATE_MOCK } from '@/redux/models/models.mock';
-import { MODELS_MOCK_SHORT } from '@/models/mocks/modelsMock';
 import {
   initialMapDataFixture,
   openedMapsInitialValueFixture,
   openedMapsThreeSubmapsFixture,
 } from '@/redux/map/map.fixtures';
-import { SIZE_OF_ARRAY_WITH_ONE_ELEMENT, ZERO } from '@/constants/common';
+import { MODELS_INITIAL_STATE_MOCK } from '@/redux/models/models.mock';
+import { StoreType } from '@/redux/store';
+import {
+  InitialStoreState,
+  getReduxWrapperWithStore,
+} from '@/utils/testing/getReduxWrapperWithStore';
+import { act, render, screen } from '@testing-library/react';
 import { AssociatedSubmap } from './AssociatedSubmap.component';
 
 const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => {
@@ -49,6 +49,8 @@ describe('AssociatedSubmap - component', () => {
         ...DRAWER_INITIAL_STATE,
         bioEntityDrawerState: {
           bioentityId: bioEntityContentFixture.bioEntity.id,
+          drugs: {},
+          chemicals: {},
         },
       },
       models: {
@@ -68,6 +70,8 @@ describe('AssociatedSubmap - component', () => {
         ...DRAWER_INITIAL_STATE,
         bioEntityDrawerState: {
           bioentityId: bioEntityContentFixture.bioEntity.id,
+          drugs: {},
+          chemicals: {},
         },
       },
       models: {
@@ -96,6 +100,8 @@ describe('AssociatedSubmap - component', () => {
           ...DRAWER_INITIAL_STATE,
           bioEntityDrawerState: {
             bioentityId: bioEntityContentFixture.bioEntity.id,
+            drugs: {},
+            chemicals: {},
           },
         },
         models: {
@@ -153,6 +159,8 @@ describe('AssociatedSubmap - component', () => {
           ...DRAWER_INITIAL_STATE,
           bioEntityDrawerState: {
             bioentityId: bioEntityContentFixture.bioEntity.id,
+            drugs: {},
+            chemicals: {},
           },
         },
         models: {
diff --git a/src/components/Map/Drawer/BioEntityDrawer/BioEntityDrawer.component.tsx b/src/components/Map/Drawer/BioEntityDrawer/BioEntityDrawer.component.tsx
index 1c37d3bd..2ee7eb5b 100644
--- a/src/components/Map/Drawer/BioEntityDrawer/BioEntityDrawer.component.tsx
+++ b/src/components/Map/Drawer/BioEntityDrawer/BioEntityDrawer.component.tsx
@@ -10,6 +10,7 @@ import {
 import { useAppDispatch } from '@/redux/hooks/useAppDispatch';
 import { useAppSelector } from '@/redux/hooks/useAppSelector';
 import { DrawerHeading } from '@/shared/DrawerHeading';
+import { ElementSearchResultType } from '@/types/models';
 import { CollapsibleSection } from '../ExportDrawer/CollapsibleSection';
 import { AnnotationItem } from './AnnotationItem';
 import { AssociatedSubmap } from './AssociatedSubmap';
diff --git a/src/components/Map/Drawer/BioEntityDrawer/ChemicalsList/ChemicalsList.component.tsx b/src/components/Map/Drawer/BioEntityDrawer/ChemicalsList/ChemicalsList.component.tsx
index ffbacbd9..c7cb5b9f 100644
--- a/src/components/Map/Drawer/BioEntityDrawer/ChemicalsList/ChemicalsList.component.tsx
+++ b/src/components/Map/Drawer/BioEntityDrawer/ChemicalsList/ChemicalsList.component.tsx
@@ -1,21 +1,22 @@
+import { ZERO } from '@/constants/common';
 import { currentSearchedBioEntityChemicalsSelector } from '@/redux/drawer/drawer.selectors';
 import { useAppSelector } from '@/redux/hooks/useAppSelector';
 import { LoadingIndicator } from '@/shared/LoadingIndicator';
-import { ZERO } from '@/constants/common';
 import { BioEntitiesPinsListItem } from '../../SearchDrawerWrapper/BioEntitiesResultsList/BioEntitiesPinsList/BioEntitiesPinsListItem';
 
 export const ChemicalsList = (): JSX.Element => {
   const chemicals = useAppSelector(currentSearchedBioEntityChemicalsSelector);
   const chemicalsData = chemicals.data || [];
+  const isPending = chemicals.loading === 'pending';
 
-  if (chemicals.loading === 'pending') {
+  if (isPending) {
     return <LoadingIndicator />;
   }
 
   return (
     <div>
-      {chemicalsData.map(drug => (
-        <BioEntitiesPinsListItem key={`${drug.id}`} pin={drug} name={drug.name} />
+      {chemicalsData.map(chemical => (
+        <BioEntitiesPinsListItem key={`${chemical.id}`} pin={chemical} name={chemical.name} />
       ))}
       {chemicalsData.length === ZERO && 'List is empty'}
     </div>
diff --git a/src/components/Map/Drawer/BioEntityDrawer/DrugsList/DrugsList.component.tsx b/src/components/Map/Drawer/BioEntityDrawer/DrugsList/DrugsList.component.tsx
index 998a0a77..da8cf74f 100644
--- a/src/components/Map/Drawer/BioEntityDrawer/DrugsList/DrugsList.component.tsx
+++ b/src/components/Map/Drawer/BioEntityDrawer/DrugsList/DrugsList.component.tsx
@@ -7,8 +7,9 @@ import { BioEntitiesPinsListItem } from '../../SearchDrawerWrapper/BioEntitiesRe
 export const DrugsList = (): JSX.Element => {
   const drugs = useAppSelector(currentSearchedBioEntityDrugsSelector);
   const drugsData = drugs.data || [];
+  const isPending = drugs.loading === 'pending';
 
-  if (drugs.loading === 'pending') {
+  if (isPending) {
     return <LoadingIndicator />;
   }
 
diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/ResultsList.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/ResultsList.component.test.tsx
index 94bc618d..24af3ef7 100644
--- a/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/ResultsList.component.test.tsx
+++ b/src/components/Map/Drawer/SearchDrawerWrapper/ResultsList/ResultsList.component.test.tsx
@@ -1,11 +1,11 @@
 /* eslint-disable no-magic-numbers */
-import { act, render, screen } from '@testing-library/react';
+import { drugsFixture } from '@/models/fixtures/drugFixtures';
+import { StoreType } from '@/redux/store';
 import {
   InitialStoreState,
   getReduxWrapperWithStore,
 } from '@/utils/testing/getReduxWrapperWithStore';
-import { StoreType } from '@/redux/store';
-import { drugsFixture } from '@/models/fixtures/drugFixtures';
+import { act, render, screen } from '@testing-library/react';
 import { ResultsList } from './ResultsList.component';
 
 const INITIAL_STATE: InitialStoreState = {
@@ -25,7 +25,10 @@ const INITIAL_STATE: InitialStoreState = {
       selectedSearchElement: 'aspirin',
     },
     reactionDrawerState: {},
-    bioEntityDrawerState: {},
+    bioEntityDrawerState: {
+      drugs: {},
+      chemicals: {},
+    },
     overlayDrawerState: {
       currentStep: 0,
     },
diff --git a/src/components/Map/Drawer/SearchDrawerWrapper/SearchDrawerWrapper.component.test.tsx b/src/components/Map/Drawer/SearchDrawerWrapper/SearchDrawerWrapper.component.test.tsx
index c36eb3a9..3ad3dbab 100644
--- a/src/components/Map/Drawer/SearchDrawerWrapper/SearchDrawerWrapper.component.test.tsx
+++ b/src/components/Map/Drawer/SearchDrawerWrapper/SearchDrawerWrapper.component.test.tsx
@@ -44,7 +44,10 @@ describe('SearchDrawerWrapper - component', () => {
           selectedSearchElement: '',
         },
         reactionDrawerState: {},
-        bioEntityDrawerState: {},
+        bioEntityDrawerState: {
+          drugs: {},
+          chemicals: {},
+        },
         overlayDrawerState: {
           currentStep: 0,
         },
@@ -67,7 +70,10 @@ describe('SearchDrawerWrapper - component', () => {
           selectedSearchElement: '',
         },
         reactionDrawerState: {},
-        bioEntityDrawerState: {},
+        bioEntityDrawerState: {
+          drugs: {},
+          chemicals: {},
+        },
         overlayDrawerState: {
           currentStep: 0,
         },
diff --git a/src/redux/drawer/drawerFixture.ts b/src/redux/drawer/drawerFixture.ts
index 29b32d3a..fc7138ab 100644
--- a/src/redux/drawer/drawerFixture.ts
+++ b/src/redux/drawer/drawerFixture.ts
@@ -11,7 +11,10 @@ export const initialStateFixture: DrawerState = {
     selectedSearchElement: '',
   },
   reactionDrawerState: {},
-  bioEntityDrawerState: {},
+  bioEntityDrawerState: {
+    drugs: {},
+    chemicals: {},
+  },
   overlayDrawerState: {
     currentStep: 0,
   },
@@ -28,7 +31,10 @@ export const openedDrawerSubmapsFixture: DrawerState = {
     selectedSearchElement: '',
   },
   reactionDrawerState: {},
-  bioEntityDrawerState: {},
+  bioEntityDrawerState: {
+    drugs: {},
+    chemicals: {},
+  },
   overlayDrawerState: {
     currentStep: 0,
   },
@@ -45,7 +51,10 @@ export const drawerSearchStepOneFixture: DrawerState = {
     selectedSearchElement: '',
   },
   reactionDrawerState: {},
-  bioEntityDrawerState: {},
+  bioEntityDrawerState: {
+    drugs: {},
+    chemicals: {},
+  },
   overlayDrawerState: {
     currentStep: 0,
   },
@@ -62,7 +71,10 @@ export const drawerSearchDrugsStepTwoFixture: DrawerState = {
     selectedSearchElement: '',
   },
   reactionDrawerState: {},
-  bioEntityDrawerState: {},
+  bioEntityDrawerState: {
+    drugs: {},
+    chemicals: {},
+  },
   overlayDrawerState: {
     currentStep: 0,
   },
@@ -79,7 +91,10 @@ export const drawerSearchChemicalsStepTwoFixture: DrawerState = {
     selectedSearchElement: '',
   },
   reactionDrawerState: {},
-  bioEntityDrawerState: {},
+  bioEntityDrawerState: {
+    drugs: {},
+    chemicals: {},
+  },
   overlayDrawerState: {
     currentStep: 0,
   },
@@ -96,7 +111,10 @@ export const drawerOverlaysStepOneFixture: DrawerState = {
     selectedSearchElement: '',
   },
   reactionDrawerState: {},
-  bioEntityDrawerState: {},
+  bioEntityDrawerState: {
+    drugs: {},
+    chemicals: {},
+  },
   overlayDrawerState: {
     currentStep: 2,
   },
@@ -113,7 +131,10 @@ export const openedExportDrawerFixture: DrawerState = {
     selectedSearchElement: '',
   },
   reactionDrawerState: {},
-  bioEntityDrawerState: {},
+  bioEntityDrawerState: {
+    drugs: {},
+    chemicals: {},
+  },
   overlayDrawerState: {
     currentStep: 0,
   },
-- 
GitLab