From 20a438428f93a596d8a93ce3a84e79f742ce4d77 Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Mon, 29 May 2023 14:35:41 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore(frontend):=20format=20code?= =?UTF-8?q?=20with=20prettier=20The=20changes=20in=20this=20commit=20are?= =?UTF-8?q?=20purely=20cosmetic,=20as=20the=20code=20has=20been=20formatte?= =?UTF-8?q?d=20with=20prettier=20to=20improve=20its=20readability=20and=20?= =?UTF-8?q?consistency.=20No=20functional=20changes=20have=20been=20made.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/CustomNodes/GenericNode/index.tsx | 10 +++- .../src/modals/genericModal/index.tsx | 55 ++++++++++--------- .../extraSidebarComponent/index.tsx | 2 +- src/frontend/src/utils.ts | 53 ++++++++++-------- 4 files changed, 66 insertions(+), 54 deletions(-) diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index 64665bf73..572210728 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -11,7 +11,13 @@ import { ExclamationCircleIcon, } from "@heroicons/react/24/solid"; -import { classNames, nodeColors, nodeIcons, toNormalCase, toTitleCase } from "../../utils"; +import { + classNames, + nodeColors, + nodeIcons, + toNormalCase, + toTitleCase, +} from "../../utils"; import ParameterComponent from "./components/parameterComponent"; import { typesContext } from "../../contexts/typesContext"; import { useContext, useState, useEffect, useRef, Fragment } from "react"; @@ -106,7 +112,7 @@ export default function GenericNode({ }} /> -
{data.type}
+
{data.type}
void; value: string; @@ -121,40 +121,41 @@ export default function PromptAreaModal({ switch (myModalType) { case 1: setModalOpen(false); - break; + break; case 2: checkPrompt(myValue) - .then((apiReturn) => { - if (apiReturn.data) { - let inputVariables = - apiReturn.data.input_variables; - if (inputVariables.length === 0) { + .then((apiReturn) => { + if (apiReturn.data) { + let inputVariables = + apiReturn.data.input_variables; + if (inputVariables.length === 0) { + setErrorData({ + title: + "The template you are attempting to use does not contain any variables for data entry.", + }); + } else { + setSuccessData({ + title: "Prompt is ready", + }); + setModalOpen(false); + setValue(myValue); + } + } else { setErrorData({ title: - "The template you are attempting to use does not contain any variables for data entry.", + "Something went wrong, please try again", }); - } else { - setSuccessData({ - title: "Prompt is ready", - }); - setModalOpen(false); - setValue(myValue); } - } else { - setErrorData({ - title: "Something went wrong, please try again", + }) + .catch((error) => { + return setErrorData({ + title: + "There is something wrong with this prompt, please review it", + list: [error.response.data.detail], }); - } - }) - .catch((error) => { - return setErrorData({ - title: - "There is something wrong with this prompt, please review it", - list: [error.response.data.detail], }); - }); - break; - + break; + default: break; } diff --git a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx index 41f98f299..1a9e721f7 100644 --- a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx @@ -34,7 +34,7 @@ export default function ExtraSidebar() { {Object.keys(data[d]) .sort() .map((t: string, k) => ( - 21 ? t : ''} placement="right"> + 21 ? t : ""} placement="right">
) { export enum TypeModal { TEXT = 1, - PROMPT = 2 + PROMPT = 2, } export const textColors = { @@ -499,33 +499,38 @@ export const programmingLanguages: languageMap = { }; export function toTitleCase(str: string) { - let result = str - .split("_") - .map((word, index) => { - if (index === 0) { + let result = str + .split("_") + .map((word, index) => { + if (index === 0) { + return checkUpperWords( + word[0].toUpperCase() + word.slice(1).toLowerCase() + ); + } + return checkUpperWords(word.toLowerCase()); + }) + .join(" "); - return checkUpperWords(word[0].toUpperCase() + word.slice(1).toLowerCase()); - } - return checkUpperWords(word.toLowerCase()); - }) - .join(" "); - - return result - .split("-") - .map((word, index) => { - if (index === 0) { - return checkUpperWords(word[0].toUpperCase() + word.slice(1).toLowerCase()); - } - return checkUpperWords(word.toLowerCase()); - }) - .join(" "); + return result + .split("-") + .map((word, index) => { + if (index === 0) { + return checkUpperWords( + word[0].toUpperCase() + word.slice(1).toLowerCase() + ); + } + return checkUpperWords(word.toLowerCase()); + }) + .join(" "); } export const upperCaseWords: string[] = ["llm", "uri"]; export function checkUpperWords(str: string) { - const words = str.split(' ').map((word) => { - return upperCaseWords.includes(word.toLowerCase()) ? word.toUpperCase() : word[0].toUpperCase() + word.slice(1).toLowerCase(); + const words = str.split(" ").map((word) => { + return upperCaseWords.includes(word.toLowerCase()) + ? word.toUpperCase() + : word[0].toUpperCase() + word.slice(1).toLowerCase(); }); - return words.join(' '); -} \ No newline at end of file + return words.join(" "); +}