🔨 refactor(parameterComponent): improve code readability by adding line breaks and indentation

🔨 refactor(promptComponent): add nodeClass prop to improve code consistency
🔨 refactor(genericModal): add nodeClass prop to improve code consistency
🔨 refactor(types/components): remove unused imports and add nodeClass prop to TextAreaComponentType
The changes made in the code aim to improve code readability and consistency. The ParameterComponent, PromptAreaComponent, and GenericModal components now have a nodeClass prop to improve consistency with the naming conventions. The TextAreaComponentType now has a nodeClass prop to improve consistency with the other components.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-27 18:22:48 -03:00
commit ab77792d65
4 changed files with 18 additions and 12 deletions

View file

@ -229,7 +229,9 @@ export default function ParameterComponent({
</div> </div>
) : left === true && type === "code" ? ( ) : left === true && type === "code" ? (
<CodeAreaComponent <CodeAreaComponent
setNodeClass={(nodeClass)=>{data.node = nodeClass}} setNodeClass={(nodeClass) => {
data.node = nodeClass;
}}
nodeClass={data.node} nodeClass={data.node}
disabled={disabled} disabled={disabled}
value={data.node.template[name].value ?? ""} value={data.node.template[name].value ?? ""}
@ -258,6 +260,7 @@ export default function ParameterComponent({
</div> </div>
) : left === true && type === "prompt" ? ( ) : left === true && type === "prompt" ? (
<PromptAreaComponent <PromptAreaComponent
nodeClass={data.node}
disabled={disabled} disabled={disabled}
value={data.node.template[name].value ?? ""} value={data.node.template[name].value ?? ""}
onChange={handleOnNewValue} onChange={handleOnNewValue}

View file

@ -7,6 +7,7 @@ import { INPUT_STYLE } from "../../constants";
import { ExternalLink } from "lucide-react"; import { ExternalLink } from "lucide-react";
export default function PromptAreaComponent({ export default function PromptAreaComponent({
nodeClass,
value, value,
onChange, onChange,
disabled, disabled,
@ -44,6 +45,7 @@ export default function PromptAreaComponent({
setMyValue(t); setMyValue(t);
onChange(t); onChange(t);
}} }}
nodeClass={nodeClass}
/> />
); );
}} }}

View file

@ -1,9 +1,8 @@
import { Fragment, useContext, useRef, useState } from "react"; import { useContext, useRef, useState } from "react";
import { PopUpContext } from "../../contexts/popUpContext"; import { PopUpContext } from "../../contexts/popUpContext";
import { darkContext } from "../../contexts/darkContext"; import { darkContext } from "../../contexts/darkContext";
import { checkPrompt } from "../../controllers/API"; import { checkPrompt } from "../../controllers/API";
import { alertContext } from "../../contexts/alertContext"; import { alertContext } from "../../contexts/alertContext";
import { TypeModal } from "../../utils";
import { import {
Dialog, Dialog,
DialogContent, DialogContent,
@ -17,6 +16,7 @@ import { Button } from "../../components/ui/button";
import { Textarea } from "../../components/ui/textarea"; import { Textarea } from "../../components/ui/textarea";
import { PROMPT_DIALOG_SUBTITLE, TEXT_DIALOG_SUBTITLE } from "../../constants"; import { PROMPT_DIALOG_SUBTITLE, TEXT_DIALOG_SUBTITLE } from "../../constants";
import { FileText } from "lucide-react"; import { FileText } from "lucide-react";
import { APIClassType } from "../../types/api";
export default function GenericModal({ export default function GenericModal({
value, value,
@ -24,12 +24,14 @@ export default function GenericModal({
buttonText, buttonText,
modalTitle, modalTitle,
type, type,
nodeClass,
}: { }: {
setValue: (value: string) => void; setValue: (value: string) => void;
value: string; value: string;
buttonText: string; buttonText: string;
modalTitle: string; modalTitle: string;
type: number; type: number;
nodeClass: APIClassType;
}) { }) {
const [myButtonText] = useState(buttonText); const [myButtonText] = useState(buttonText);
const [myModalTitle] = useState(modalTitle); const [myModalTitle] = useState(modalTitle);
@ -97,9 +99,13 @@ export default function GenericModal({
setModalOpen(false); setModalOpen(false);
break; break;
case 2: case 2:
checkPrompt(myValue) checkPrompt(myValue, nodeClass)
.then((apiReturn) => { .then((apiReturn) => {
if (apiReturn.data) { if (apiReturn.data) {
if (apiReturn.data) {
setNodeClass(data);
setModalOpen(false);
}
let inputVariables = apiReturn.data.input_variables; let inputVariables = apiReturn.data.input_variables;
if (inputVariables.length === 0) { if (inputVariables.length === 0) {
setErrorData({ setErrorData({

View file

@ -1,13 +1,7 @@
import { import { ReactElement, ReactNode } from "react";
ComponentType,
ForwardRefExoticComponent,
ReactElement,
ReactNode,
SVGProps,
} from "react";
import { NodeDataType } from "../flow/index"; import { NodeDataType } from "../flow/index";
import { typesContextType } from "../typesContext"; import { typesContextType } from "../typesContext";
import { APIClassType, APITemplateType } from "../api"; import { APIClassType } from "../api";
export type InputComponentType = { export type InputComponentType = {
value: string; value: string;
disabled?: boolean; disabled?: boolean;
@ -51,6 +45,7 @@ export type InputListComponentType = {
}; };
export type TextAreaComponentType = { export type TextAreaComponentType = {
nodeClass?: APIClassType;
disabled: boolean; disabled: boolean;
onChange: (value: string[] | string) => void; onChange: (value: string[] | string) => void;
value: string; value: string;