prompt template bug fix
This commit is contained in:
parent
66d8a104c0
commit
7a7efc2afa
1 changed files with 28 additions and 17 deletions
|
|
@ -4,7 +4,6 @@ import GenericModal from "../../modals/genericModal";
|
||||||
import { TextAreaComponentType } from "../../types/components";
|
import { TextAreaComponentType } from "../../types/components";
|
||||||
import { TypeModal } from "../../utils";
|
import { TypeModal } from "../../utils";
|
||||||
|
|
||||||
import * as _ from "lodash";
|
|
||||||
import { ExternalLink } from "lucide-react";
|
import { ExternalLink } from "lucide-react";
|
||||||
import { typesContext } from "../../contexts/typesContext";
|
import { typesContext } from "../../contexts/typesContext";
|
||||||
import { postValidatePrompt } from "../../controllers/API";
|
import { postValidatePrompt } from "../../controllers/API";
|
||||||
|
|
@ -18,7 +17,7 @@ export default function PromptAreaComponent({
|
||||||
disabled,
|
disabled,
|
||||||
editNode = false,
|
editNode = false,
|
||||||
}: TextAreaComponentType) {
|
}: TextAreaComponentType) {
|
||||||
const [myValue, setMyValue] = useState("");
|
const [myValue, setMyValue] = useState(value);
|
||||||
const { openPopUp } = useContext(PopUpContext);
|
const { openPopUp } = useContext(PopUpContext);
|
||||||
const { reactFlowInstance } = useContext(typesContext);
|
const { reactFlowInstance } = useContext(typesContext);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -29,22 +28,34 @@ export default function PromptAreaComponent({
|
||||||
}, [disabled, onChange]);
|
}, [disabled, onChange]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (value !== "" && myValue !== value && reactFlowInstance) {
|
setMyValue(value);
|
||||||
// only executed once
|
if (value !== "" && !editNode) {
|
||||||
setMyValue(value);
|
postValidatePrompt(field_name, value, nodeClass).then((apiReturn) => {
|
||||||
postValidatePrompt(field_name, value, nodeClass)
|
if (apiReturn.data) {
|
||||||
.then((apiReturn) => {
|
setNodeClass(apiReturn.data.frontend_node);
|
||||||
if (apiReturn.data) {
|
// need to update reactFlowInstance to re-render the nodes.
|
||||||
setNodeClass(apiReturn.data.frontend_node);
|
}
|
||||||
// need to update reactFlowInstance to re-render the nodes.
|
});
|
||||||
reactFlowInstance.setEdges(
|
|
||||||
_.cloneDeep(reactFlowInstance.getEdges())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {});
|
|
||||||
}
|
}
|
||||||
}, [reactFlowInstance, field_name, myValue, nodeClass, setNodeClass, value]);
|
}, [value, reactFlowInstance]);
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// if (value !== "" && myValue !== value && reactFlowInstance) {
|
||||||
|
// // only executed once
|
||||||
|
// setMyValue(value);
|
||||||
|
// postValidatePrompt(field_name, value, nodeClass)
|
||||||
|
// .then((apiReturn) => {
|
||||||
|
// if (apiReturn.data) {
|
||||||
|
// setNodeClass(apiReturn.data.frontend_node);
|
||||||
|
// // need to update reactFlowInstance to re-render the nodes.
|
||||||
|
// reactFlowInstance.setEdges(
|
||||||
|
// _.cloneDeep(reactFlowInstance.getEdges())
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// .catch((error) => {});
|
||||||
|
// }
|
||||||
|
// }, [reactFlowInstance, field_name, myValue, nodeClass, setNodeClass, value]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={disabled ? "pointer-events-none w-full " : " w-full"}>
|
<div className={disabled ? "pointer-events-none w-full " : " w-full"}>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue