diff --git a/src/frontend/src/components/chatComponent/buildTrigger/index.tsx b/src/frontend/src/components/chatComponent/buildTrigger/index.tsx index d29f7ea7b..db691133d 100644 --- a/src/frontend/src/components/chatComponent/buildTrigger/index.tsx +++ b/src/frontend/src/components/chatComponent/buildTrigger/index.tsx @@ -121,7 +121,7 @@ export default function BuildTrigger({ // Step 3: Wait for the stream to finish while (!finished) { await new Promise((resolve) => setTimeout(resolve, 100)); - finished = validationResults.length === flow.data.nodes.length; + finished = validationResults.length === flow.data!.nodes.length; } // Step 4: Return true if all nodes are valid, false otherwise return validationResults.every((result) => result); diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx index ced7a2fee..89b8da0a5 100644 --- a/src/frontend/src/contexts/tabsContext.tsx +++ b/src/frontend/src/contexts/tabsContext.tsx @@ -28,6 +28,7 @@ import { import { getRandomDescription, getRandomName } from "../utils/utils"; import { alertContext } from "./alertContext"; import { typesContext } from "./typesContext"; +import { tweakType } from "../types/components"; const uid = new ShortUniqueId({ length: 5 }); @@ -78,7 +79,7 @@ export function TabsProvider({ children }: { children: ReactNode }) { edges: any; } | null>(null); const [tabsState, setTabsState] = useState({}); - const [getTweak, setTweak] = useState([]); + const [getTweak, setTweak] = useState([]); const newNodeId = useRef(uid()); function incrementNodeId() { diff --git a/src/frontend/src/controllers/API/api.tsx b/src/frontend/src/controllers/API/api.tsx index 8771fa67e..b0f173e2f 100644 --- a/src/frontend/src/controllers/API/api.tsx +++ b/src/frontend/src/controllers/API/api.tsx @@ -2,6 +2,7 @@ import axios, { AxiosError, AxiosInstance } from "axios"; import { useContext, useEffect, useRef } from "react"; import { URL_EXCLUDED_FROM_ERROR_RETRIES } from "../../constants/constants"; import { alertContext } from "../../contexts/alertContext"; +import { errorsVarType } from "../../types/tabs"; // Create a new Axios instance const api: AxiosInstance = axios.create({ @@ -37,7 +38,7 @@ function ApiInterceptor(): null { "Check if the backend is up", "Endpoint: " + error.config?.url, ], - }); + } as errorsVarType); return Promise.reject(error); } } diff --git a/src/frontend/src/controllers/API/index.ts b/src/frontend/src/controllers/API/index.ts index b7f19dd0b..be3d4f2e9 100644 --- a/src/frontend/src/controllers/API/index.ts +++ b/src/frontend/src/controllers/API/index.ts @@ -179,7 +179,7 @@ export async function downloadFlowsFromDatabase() { } } -export async function uploadFlowsToDatabase(flows: FlowType[]) { +export async function uploadFlowsToDatabase(flows: FormData) { try { const response = await api.post(`/api/v1/flows/upload/`, flows); diff --git a/src/frontend/src/modals/ApiModal/index.tsx b/src/frontend/src/modals/ApiModal/index.tsx index 0b7b763bd..51611ac83 100644 --- a/src/frontend/src/modals/ApiModal/index.tsx +++ b/src/frontend/src/modals/ApiModal/index.tsx @@ -16,7 +16,7 @@ import CodeTabsComponent from "../../components/codeTabsComponent"; import IconComponent from "../../components/genericIconComponent"; import { EXPORT_CODE_DIALOG } from "../../constants/constants"; import { TabsContext } from "../../contexts/tabsContext"; -import { FlowType, NodeType } from "../../types/flow/index"; +import { FlowType, NodeType, TweaksType } from "../../types/flow/index"; import { buildTweaks } from "../../utils/reactflowUtils"; import { getCurlCode, @@ -26,7 +26,7 @@ import { } from "../../utils/utils"; import BaseModal from "../baseModal"; import { tweakType } from "../../types/components"; -import { APITemplateType } from "../../types/api"; +import { APITemplateType, TemplateVariableType } from "../../types/api"; const ApiModal = forwardRef( ( @@ -43,7 +43,7 @@ const ApiModal = forwardRef( ) => { const [open, setOpen] = useState(false); const [activeTab, setActiveTab] = useState("0"); - const tweak = useRef([]); + const tweak = useRef([]); const tweaksList = useRef([]); const { setTweak, getTweak, tabsState } = useContext(TabsContext); const pythonApiCode = getPythonApiCode(flow, tweak.current, tabsState); @@ -92,7 +92,7 @@ const ApiModal = forwardRef( } useEffect(() => { - if (flow["data"]["nodes"].length == 0) { + if (flow["data"]!["nodes"].length == 0) { startState(); } else { tweak.current = []; @@ -179,12 +179,12 @@ const ApiModal = forwardRef( }, ]); } - }, [flow["data"]["nodes"], open]); + }, [flow["data"]!["nodes"], open]); function filterNodes() { let arrNodesWithValues: string[] = []; - flow["data"]["nodes"].forEach((t) => { + flow["data"]!["nodes"].forEach((t) => { Object.keys(t["data"]["node"]["template"]) .filter( (n) => @@ -207,7 +207,7 @@ const ApiModal = forwardRef( return self.indexOf(value) === index; }); } - function buildTweakObject(tw: string, changes: string | string[], template: APITemplateType) { + function buildTweakObject(tw: string | string[], changes: string | string[] | boolean, template: TemplateVariableType) { if (template.type === "float") { changes = parseFloat(changes); } diff --git a/src/frontend/src/modals/formModal/index.tsx b/src/frontend/src/modals/formModal/index.tsx index c0ce2aa5f..aa4bb8ace 100644 --- a/src/frontend/src/modals/formModal/index.tsx +++ b/src/frontend/src/modals/formModal/index.tsx @@ -317,7 +317,7 @@ export default function FormModal({ setErrorData({ title: "There was an error sending the message", list: [error.message], - }); + } as errorsVarType); setChatValue(data.inputs); connectWS(); } diff --git a/src/frontend/src/modals/genericModal/index.tsx b/src/frontend/src/modals/genericModal/index.tsx index 1b1da2c3a..42954fde6 100644 --- a/src/frontend/src/modals/genericModal/index.tsx +++ b/src/frontend/src/modals/genericModal/index.tsx @@ -1,4 +1,4 @@ -import { useContext, useEffect, useRef, useState } from "react"; +import { Ref, RefObject, useContext, useEffect, useRef, useState } from "react"; import SanitizedHTMLWrapper from "../../components/SanitizedHTMLWrapper"; import ShadTooltip from "../../components/ShadTooltipComponent"; import IconComponent from "../../components/genericIconComponent"; @@ -42,7 +42,7 @@ export default function GenericModal({ const [wordsHighlight, setWordsHighlight] = useState([]); const { setErrorData, setSuccessData, setNoticeData } = useContext(alertContext); - const ref = useRef(); + const ref = useRef>(); const divRef = useRef(null); const divRefPrompt = useRef(null); @@ -208,7 +208,7 @@ export default function GenericModal({ ) : type !== TypeModal.PROMPT ? (