fix(genericModal/index.tsx): handle case when field_name is an empty string in GenericModal component
fix(genericModal/index.tsx): handle case when field_name is an empty string in GenericModal component
This commit is contained in:
parent
f38692c9df
commit
765db810c7
1 changed files with 14 additions and 7 deletions
|
|
@ -112,9 +112,12 @@ export default function GenericModal({
|
||||||
// if field_name is an empty string, then we need to set it
|
// if field_name is an empty string, then we need to set it
|
||||||
// to the first key of the custom_fields object
|
// to the first key of the custom_fields object
|
||||||
if (field_name === "") {
|
if (field_name === "") {
|
||||||
field_name = Object.keys(
|
console.log(apiReturn.data?.frontend_node?.custom_fields);
|
||||||
apiReturn.data?.frontend_node?.custom_fields ?? {}
|
field_name = Array.isArray(
|
||||||
)[0];
|
apiReturn.data?.frontend_node?.custom_fields?.[""]
|
||||||
|
)
|
||||||
|
? apiReturn.data?.frontend_node?.custom_fields?.[""][0] ?? ""
|
||||||
|
: apiReturn.data?.frontend_node?.custom_fields?.[""] ?? "";
|
||||||
}
|
}
|
||||||
if (apiReturn.data) {
|
if (apiReturn.data) {
|
||||||
let inputVariables = apiReturn.data.input_variables ?? [];
|
let inputVariables = apiReturn.data.input_variables ?? [];
|
||||||
|
|
@ -131,8 +134,10 @@ export default function GenericModal({
|
||||||
setNodeClass!(apiReturn.data?.frontend_node);
|
setNodeClass!(apiReturn.data?.frontend_node);
|
||||||
setModalOpen(closeModal);
|
setModalOpen(closeModal);
|
||||||
setValue(inputValue);
|
setValue(inputValue);
|
||||||
apiReturn.data.frontend_node["template"][field_name]["value"] =
|
if (field_name !== "") {
|
||||||
inputValue;
|
apiReturn.data.frontend_node["template"][field_name]["value"] =
|
||||||
|
inputValue;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setIsEdit(false);
|
setIsEdit(false);
|
||||||
setSuccessData({
|
setSuccessData({
|
||||||
|
|
@ -145,8 +150,10 @@ export default function GenericModal({
|
||||||
setNodeClass!(apiReturn.data?.frontend_node);
|
setNodeClass!(apiReturn.data?.frontend_node);
|
||||||
setModalOpen(closeModal);
|
setModalOpen(closeModal);
|
||||||
setValue(inputValue);
|
setValue(inputValue);
|
||||||
apiReturn.data.frontend_node["template"][field_name]["value"] =
|
if (field_name !== "") {
|
||||||
inputValue;
|
apiReturn.data.frontend_node["template"][field_name]["value"] =
|
||||||
|
inputValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setIsEdit(true);
|
setIsEdit(true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue