From cd54cba6269dbc4e10b457fe7eddd5114a9d301e Mon Sep 17 00:00:00 2001
From: alyssaf16 <alyssa_feinberg@brown.edu>
Date: Wed, 30 Oct 2024 22:17:57 -0400
Subject: version 5 working

---
 .../nodes/chatbot/chatboxcomponents/ChatBox.tsx     | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

(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 0939247b7..4a39ee388 100644
--- a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
+++ b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
@@ -428,22 +428,22 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
     //     });
     // };
     @action
-    private createCollectionWithChildren = async (data: string[]): Promise<Doc[]> => {
+    private createCollectionWithChildren = async (data: any): Promise<Doc[]> => {
         console.log('Creating collection with nested documents');
 
         // Create an array of promises for each document
         const childDocPromises = data.map(async doc => {
-            const parsedDoc = JSON.parse(doc);
+            const parsedDoc = doc;
             console.log('Parse #3: ' + parsedDoc);
             if (parsedDoc.doc_type !== 'collection') {
                 // Handle non-collection documents
-                return await this.whichDoc(parsedDoc.doc_type, parsedDoc.data, parsedDoc.options, parsedDoc.id);
+                return await this.whichDoc(parsedDoc.doc_type, parsedDoc.data, { backgroundColor: parsedDoc.backgroundColor, _width: parsedDoc.width, _height: parsedDoc.height }, parsedDoc.id);
             } else {
                 // Recursively process collections
-                const nestedDocs = await this.createCollectionWithChildren(JSON.parse(parsedDoc.data) as string[]);
+                const nestedDocs = await this.createCollectionWithChildren(parsedDoc.data);
                 const collectionOptions: DocumentOptions = {
                     title: parsedDoc.title,
-                    backgroundColor: parsedDoc.background_color,
+                    backgroundColor: parsedDoc.backgroundColor,
                     _width: parsedDoc.width,
                     _height: parsedDoc.height,
                     _layout_fitWidth: true,
@@ -491,13 +491,14 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
                 doc = DocCast(Docs.Create.SimulationDocument(options));
                 break;
             case 'collection': {
-                const par = JSON.parse(data);
-                console.log('Parse #2: ' + par);
-                const arr = await this.createCollectionWithChildren(par);
+                // const par = JSON.parse(data);
+                // console.log('Parse #2: ' + par);
+                const arr = await this.createCollectionWithChildren(data);
                 options._layout_fitWidth = true;
                 options._freeform_backgroundGrid = true;
-                const opts = { _width: 500, _height: 800, _layout_fitWidth: true, _freeform_backgroundGrid: true };
-                doc = DocCast(Docs.Create.FreeformDocument(arr, opts));
+
+                // const opts = { _width: 500, _height: 800, _layout_fitWidth: true, _freeform_backgroundGrid: true };
+                doc = DocCast(Docs.Create.FreeformDocument(arr, options));
                 break;
             }
             case 'web':
-- 
cgit v1.2.3-70-g09d2

