From dfdd588ee6f52500126cdd0c4f15b117baed1fe2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mi=C5=82osz=20Grocholewski?= <m.grocholewski@atcomp.pl>
Date: Mon, 4 Nov 2024 14:31:54 +0100
Subject: [PATCH] feat(vector-map): add drawing for reaction modifiers lines

---
 .../config/reactionsLayer/useOlMapReactionsLayer.ts    |  1 +
 .../utils/shapes/reaction/Reaction.test.ts             |  3 ++-
 .../MapViewerVector/utils/shapes/reaction/Reaction.ts  | 10 ++++++++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.ts b/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.ts
index eb1c4ef8..7a693a8c 100644
--- a/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.ts
+++ b/src/components/Map/MapViewer/MapViewerVector/utils/config/reactionsLayer/useOlMapReactionsLayer.ts
@@ -58,6 +58,7 @@ export const useOlMapReactionsLayer = ({
         line: reaction.line,
         products: reaction.products,
         reactants: reaction.reactants,
+        modifiers: reaction.modifiers,
         operators: reaction.operators,
         zIndex: reaction.z,
         lineTypes,
diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.test.ts b/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.test.ts
index a8fc5b81..06427838 100644
--- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.test.ts
+++ b/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.test.ts
@@ -26,6 +26,7 @@ describe('Layer', () => {
       line: newReactionFixture.line,
       products: newReactionFixture.products,
       reactants: newReactionFixture.reactants,
+      modifiers: newReactionFixture.modifiers,
       operators: newReactionFixture.operators,
       shapes: shapesFixture,
       zIndex: newReactionFixture.z,
@@ -39,7 +40,7 @@ describe('Layer', () => {
   it('should initialize a Reaction class', () => {
     const reaction = new Reaction(props);
 
-    expect(reaction.features.length).toBe(10);
+    expect(reaction.features.length).toBe(12);
     expect(reaction.features).toBeInstanceOf(Array<Feature>);
   });
 });
diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.ts b/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.ts
index 1eae0a65..1d2880b8 100644
--- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.ts
+++ b/src/components/Map/MapViewer/MapViewerVector/utils/shapes/reaction/Reaction.ts
@@ -19,6 +19,7 @@ export interface ReactionProps {
   line: Line;
   products: Array<ReactionProduct>;
   reactants: Array<ReactionProduct>;
+  modifiers: Array<ReactionProduct>;
   operators: Array<Operator>;
   zIndex: number;
   lineTypes: Array<LineType>;
@@ -35,6 +36,8 @@ export default class Reaction {
 
   reactants: Array<ReactionProduct>;
 
+  modifiers: Array<ReactionProduct>;
+
   operators: Array<Operator>;
 
   zIndex: number;
@@ -55,6 +58,7 @@ export default class Reaction {
     line,
     products,
     reactants,
+    modifiers,
     operators,
     zIndex,
     lineTypes,
@@ -66,6 +70,7 @@ export default class Reaction {
     this.line = line;
     this.products = products;
     this.reactants = reactants;
+    this.modifiers = modifiers;
     this.operators = operators;
     this.zIndex = zIndex;
     this.lineTypes = lineTypes;
@@ -99,6 +104,11 @@ export default class Reaction {
       this.features.push(...lineFeature.arrowsFeatures);
       this.features.push(this.getOperator(operator));
     });
+    this.modifiers.forEach(modifier => {
+      lineFeature = this.getLineFeature(modifier.line);
+      this.features.push(lineFeature.lineFeature);
+      this.features.push(...lineFeature.arrowsFeatures);
+    });
   }
 
   private getLineFeature(line: Line): {
-- 
GitLab