🔧 chore(frontend): format code with prettier

The changes in this commit are purely cosmetic, as the code has been formatted with prettier to improve its readability and consistency. No functional changes have been made.
This commit is contained in:
Gabriel Almeida 2023-05-29 14:35:41 -03:00
commit 20a438428f
4 changed files with 66 additions and 54 deletions

View file

@ -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({
}}
/>
<Tooltip title={data.type} placement="top">
<div className="ml-2 truncate">{data.type}</div>
<div className="ml-2 truncate">{data.type}</div>
</Tooltip>
<div>
<Tooltip

View file

@ -11,7 +11,7 @@ export default function PromptAreaModal({
setValue,
buttonText,
modalTitle,
type
type,
}: {
setValue: (value: string) => 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;
}

View file

@ -34,7 +34,7 @@ export default function ExtraSidebar() {
{Object.keys(data[d])
.sort()
.map((t: string, k) => (
<Tooltip title={t.length > 21 ? t : ''} placement="right">
<Tooltip title={t.length > 21 ? t : ""} placement="right">
<div key={k}>
<div
draggable

View file

@ -27,7 +27,7 @@ export function classNames(...classes: Array<string>) {
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(' ');
}
return words.join(" ");
}