From f2a4c9e484340b0542b896974673ffa13fbc0ac5 Mon Sep 17 00:00:00 2001
From: alyssaf16 <alyssa_feinberg@brown.edu>
Date: Tue, 12 Nov 2024 07:53:22 -0500
Subject: comparison box with assistant working

---
 .../views/nodes/chatbot/chatboxcomponents/ChatBox.tsx   | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

(limited to 'src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx')

diff --git a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
index 95f3fbc5d..d85f9d82e 100644
--- a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
+++ b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
@@ -495,7 +495,7 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
                 doc = DocCast(Docs.Create.WebDocument(data, options));
                 break;
             case 'comparison':
-                doc = Docs.Create.ComparisonDocument('', options);
+                doc = this.createComparison(data, options);
                 break;
             case 'diagram':
                 doc = Docs.Create.DiagramDocument(options);
@@ -631,6 +631,21 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
         // return carouselDoc;
     };
 
+    @action
+    createComparison = (doc: any, options: any) => {
+        const comp = Docs.Create.ComparisonDocument(options.title, { _width: options.width, _height: options.height | 300, backgroundColor: options.backgroundColor });
+        const [left, right] = doc;
+        console.log(DocCast(comp.dataDoc));
+        console.log(DocCast(comp[DocData]));
+        console.log(DocCast(comp[DocData].data_back));
+        const docLeft = DocCast(Docs.Create.TextDocument(left.data, { backgroundColor: left.backgroundColor, _width: left.width, _height: left.height }));
+        const docRight = DocCast(Docs.Create.TextDocument(right.data, { backgroundColor: right.backgroundColor, _width: right.width, _height: right.height }));
+        comp[DocData].data_back = docLeft;
+        comp[DocData].data_front = docRight;
+
+        return comp;
+    };
+
     /**
      * Event handler to manage citations click in the message components.
      * @param citation The citation object clicked by the user.
-- 
cgit v1.2.3-70-g09d2

