From cf91c46cfec6e3e36b9184764016f9c1b5c997d4 Mon Sep 17 00:00:00 2001
From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com>
Date: Tue, 11 Mar 2025 17:31:16 +0100
Subject: c

---
 .../DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx   | 26 ++++++++--------------
 1 file changed, 9 insertions(+), 17 deletions(-)

(limited to 'src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx')

diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
index 099d082d3..6d0155b45 100644
--- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
+++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
@@ -7,7 +7,7 @@ import * as React from 'react';
 import ReactLoading from 'react-loading';
 import { ClientUtils, returnEmptyFilter, returnFalse, returnTrue, setupMoveUpEvents } from '../../../../../ClientUtils';
 import { emptyFunction } from '../../../../../Utils';
-import { Doc, FieldType, NumListCast, StrListCast, returnEmptyDoclist } from '../../../../../fields/Doc';
+import { Doc, DocListCast, FieldType, NumListCast, StrListCast, returnEmptyDoclist } from '../../../../../fields/Doc';
 import { Id } from '../../../../../fields/FieldSymbols';
 import { Cast, DocCast, ImageCast, StrCast } from '../../../../../fields/Types';
 import { ImageField } from '../../../../../fields/URLField';
@@ -34,6 +34,7 @@ import { TemplateManager } from './TemplateManager';
 import { Template } from './Template';
 import { Field, ViewType } from './FieldTypes/Field';
 import { TabDocView } from '../../../collections/TabDocView';
+import { DocData } from '../../../../../fields/DocSymbols';
 
 export enum LayoutType {
     FREEFORM = 'Freeform',
@@ -74,6 +75,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
     @observable _GPTOpt: boolean = false;
     @observable _callCount: number = 0;
     @observable _GPTLoading: boolean = false;
+    @observable _DOCCC: Doc | undefined;
 
     @observable _pageX: number = 0;
     @observable _pageY: number = 0;
@@ -623,8 +625,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
             const cols = this.fieldsInfos;
             templates.push(...this.templateManager.getValidTemplates(cols));
 
-            console.log(templates)
-
             const assignments: [Template, { [field: number]: Col }][] = await this.assignColsToFields(templates, cols);
 
             const renderedTemplatePromises: Promise<Template | undefined>[] = assignments.map(([template, assignments]) => this.applyGPTContentToTemplate(template, assignments));
@@ -735,12 +735,11 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
     
         const processContent = async (content: {[title: string]: string}) => {
 
-            const templateCopy = template.cloneBase(); 
+            const templateCopy = await template.cloneBase(); 
 
             fields.filter(title => title).forEach(title => {
                 const field = templateCopy.getFieldByTitle(title);
                 if (field === undefined) return;
-                console.log('setting content to: ', content[title]);
                 field.setContent(content[title], field.viewType);
             });
     
@@ -765,23 +764,20 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
             await Promise.all(gptPromises);
 
             await Promise.all(imagePromises);
-    
-            return templateCopy.getRenderedDoc();
-        };
 
-        const rows = [1, 2, 3, 4];
+            this._DOCCC = templateCopy.mainField.renderedDoc;
+            return templateCopy.mainField.renderedDoc;
+        };
         
         let docs: Promise<Doc>[];
         if (this.DEBUG_MODE) {
-            docs = rows.map(() => processContent({}));
+            docs = [1, 2, 3, 4].map(() => processContent({}));
         } else {
             docs = rowContents.map(content => processContent(content));
         }
 
         const renderedDocs = await Promise.all(docs);
 
-        //renderedDocs.forEach(doc => {console.log(doc._height, doc._width); doc._height = 400; doc._width = 400});
-
         this._docsRendering = false; // removes loading indicator
 
         return renderedDocs;
@@ -1035,7 +1031,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
 
     applyLayout = (collection: Doc, docs: Doc[]) => {
         const { horizontalSpan, verticalSpan } = this.previewInfo;
-        console.log(this.previewInfo)
         collection._height = verticalSpan;
         collection._width = horizontalSpan;
 
@@ -1088,11 +1083,8 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
     @type the type of collection the docs should render to (ie. freeform, carousel, card)
      */
     updateRenderedDocCollection = () => {
-        console.log('called');
         if (!this._fullyRenderedDocs) return;
 
-        //const largerSpan: number = horizontalSpan > verticalSpan ? horizontalSpan : verticalSpan;
-
         const collectionFactory = (): (docs: Doc[], options: DocumentOptions) => Doc => {
             switch (this._layout.type) {
                 case LayoutType.CAROUSEL3D:
@@ -1110,7 +1102,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
             }
         }
 
-        const collection = collectionFactory()(this._fullyRenderedDocs, {
+        const collection = collectionFactory()([this._fullyRenderedDocs[6], this._fullyRenderedDocs[9]], {
             isDefaultTemplateDoc: true,
             title: 'title',
             backgroundColor: 'gray',
-- 
cgit v1.2.3-70-g09d2

