From eb5746da51bf44aeacb41d6337f666e178fae88e Mon Sep 17 00:00:00 2001
From: Sophie Zhang <sophie_zhang@brown.edu>
Date: Thu, 29 Feb 2024 01:25:37 -0500
Subject: added curr slide info to slide customization

---
 src/client/views/nodes/trails/PresBox.tsx | 53 +++++++++++++++++++++----------
 1 file changed, 37 insertions(+), 16 deletions(-)

(limited to 'src/client/views/nodes/trails/PresBox.tsx')

diff --git a/src/client/views/nodes/trails/PresBox.tsx b/src/client/views/nodes/trails/PresBox.tsx
index 1b1b65e46..ba80facce 100644
--- a/src/client/views/nodes/trails/PresBox.tsx
+++ b/src/client/views/nodes/trails/PresBox.tsx
@@ -38,10 +38,10 @@ import './PresBox.scss';
 import ReactLoading from 'react-loading';
 import { PresEffect, PresEffectDirection, PresMovement, PresStatus } from './PresEnums';
 import ReactTextareaAutosize from 'react-textarea-autosize';
-import { IconButton, Type } from 'browndash-components';
+import { Dropdown, IconButton, Type } from 'browndash-components';
 import { BiMicrophone, BiX } from 'react-icons/bi';
 import { AiOutlineSend } from 'react-icons/ai';
-import { gptTrailSlideCustomization } from '../../../apis/gpt/customization';
+import { gptSlideProperties, gptTrailSlideCustomization } from '../../../apis/gpt/customization';
 import { DictationManager } from '../../../util/DictationManager';
 export interface pinDataTypes {
     scrollable?: boolean;
@@ -263,7 +263,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
         }
     };
 
-    // GPT
+    // Recording for GPT customization
 
     recordDictation = () => {
         this.setIsRecording(true);
@@ -283,6 +283,7 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
     };
 
     setDictationContent = (value: string) => {
+        console.log('Dictation value', value);
         this.setChatInput(value);
         // // Get the current cursor position
         // if (!this._inputref) return;
@@ -306,24 +307,31 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
 
     @action
     customizeWithGPT = async (input: string) => {
-        console.log(this.slideToModify);
+        console.log('Slide to modify', this.slideToModify);
         // const testInput = 'change title to Customized Slide, transition for 2.3s with fade in effect';
         // if (!this.slideToModify) return;
         this.setIsRecording(false);
         this.setIsLoading(true);
+
+        let currSlideProperties: { [key: string]: any } = {};
+        for (const key of gptSlideProperties) {
+            currSlideProperties[key] = this.activeItem[key];
+        }
+        console.log('current slide props', currSlideProperties);
+
         try {
-            const res = await gptTrailSlideCustomization(input);
-            console.log('slide result', res);
-            // if (typeof res === 'string') {
-            //     const resObj = JSON.parse(res);
-            //     console.log('Result ', resObj);
-            //     // this.activeItem
-            //     for (let key in resObj) {
-            //         if (resObj[key]) {
-            //             this.slideToModify[key] = resObj[key];
-            //         }
-            //     }
-            // }
+            const res = await gptTrailSlideCustomization(input, currSlideProperties);
+            console.log('GPT Result:', res);
+            if (typeof res === 'string') {
+                const resObj = JSON.parse(res);
+                console.log('Parsed GPT Result ', resObj);
+                // this.activeItem
+                for (let key in resObj) {
+                    if (resObj[key]) {
+                        this.activeItem[key] = resObj[key];
+                    }
+                }
+            }
         } catch (err) {
             console.error(err);
         }
@@ -1833,6 +1841,19 @@ export class PresBox extends ViewBoxBaseComponent<FieldViewProps>() {
                     })}>
                     <div className="ribbon-box">
                         Movement
+                        {/* <Dropdown
+                        color={StrCast(Doc.UserDoc().userColor)}
+                        formLabel={'Type'}
+                        closeOnSelect={true}
+                        items={bugDropdownItems}
+                        selectedVal={this.formData.type}
+                        setSelectedVal={val => {
+                            if (typeof val === 'string') this.setFormData({ ...this.formData, type: val as BugType });
+                        }}
+                        dropdownType={DropdownType.SELECT}
+                        type={Type.TERT}
+                        fillWidth
+                    /> */}
                         <div
                             className="presBox-dropdown"
                             onClick={action(e => {
-- 
cgit v1.2.3-70-g09d2

