🐛 fix(alerts/error): remove unnecessary line break in ErrorAlert component

✨ feat(modals/EditNodeModal): add ability to set nodeClass in EditNodeModal component
🐛 fix(modals/genericModal): handle optional chaining for error response data in GenericModal component
🔥 chore(modals/promptModal): remove unused import and checkPrompt function in PromptAreaModal component
This commit is contained in:
Cristhian Zanforlin Lousa 2023-07-08 09:12:24 -03:00
commit 4883064e84
4 changed files with 7 additions and 33 deletions

View file

@ -20,6 +20,7 @@ export default function ErrorAlert({
}, 5000); }, 5000);
} }
}, [id, removeAlert, show]); }, [id, removeAlert, show]);
return ( return (
<Transition <Transition
className="relative" className="relative"
@ -50,7 +51,7 @@ export default function ErrorAlert({
</div> </div>
<div className="ml-3"> <div className="ml-3">
<h3 className="error-build-foreground">{title}</h3> <h3 className="error-build-foreground">{title}</h3>
{list.length !== 0 ? ( {list?.length !== 0 && list?.some(item => item !== null && item !== undefined) ? (
<div className="error-build-message-div"> <div className="error-build-message-div">
<ul className="error-build-message-list"> <ul className="error-build-message-list">
{list.map((item, index) => ( {list.map((item, index) => (

View file

@ -269,6 +269,10 @@ export default function EditNodeModal({ data }: { data: NodeDataType }) {
field_name={n} field_name={n}
editNode={true} editNode={true}
disabled={false} disabled={false}
nodeClass={data.node}
setNodeClass={(nodeClass) => {
data.node = nodeClass;
}}
value={data.node.template[n].value ?? ""} value={data.node.template[n].value ?? ""}
onChange={(t: string) => { onChange={(t: string) => {
handleOnNewValue(t, n); handleOnNewValue(t, n);

View file

@ -162,7 +162,7 @@ export default function GenericModal({
setIsEdit(true); setIsEdit(true);
return setErrorData({ return setErrorData({
title: "There is something wrong with this prompt, please review it", title: "There is something wrong with this prompt, please review it",
list: [error.response.data.detail], list: [error?.response?.data?.detail],
}); });
}); });
} }

View file

@ -4,7 +4,6 @@ import { Fragment, useContext, useRef, useState } from "react";
import { alertContext } from "../../contexts/alertContext"; import { alertContext } from "../../contexts/alertContext";
import { darkContext } from "../../contexts/darkContext"; import { darkContext } from "../../contexts/darkContext";
import { PopUpContext } from "../../contexts/popUpContext"; import { PopUpContext } from "../../contexts/popUpContext";
import { checkPrompt } from "../../controllers/API";
export default function PromptAreaModal({ export default function PromptAreaModal({
value, value,
setValue, setValue,
@ -105,36 +104,6 @@ export default function PromptAreaModal({
type="button" type="button"
className="node-modal-button" className="node-modal-button"
onClick={() => { onClick={() => {
checkPrompt(myValue)
.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: "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],
});
});
}} }}
> >
Check & Save Check & Save