refactor(chatComponent): simplify conditional statement in Chat component's error handling logic

This commit is contained in:
Gabriel Almeida 2023-04-19 14:20:05 -03:00
commit 9b1f86b681

View file

@ -93,7 +93,7 @@ export default function Chat({ flow, reactFlowInstance }: ChatType) {
(errors: Array<string>, t) => (errors: Array<string>, t) =>
errors.concat( errors.concat(
(template[t].required && template[t].show) && (template[t].required && template[t].show) &&
(!template[t].value || template[t].value === "") && (!template[t].value && template[t].value !== false && template[t].value === "") &&
!reactFlowInstance !reactFlowInstance
.getEdges() .getEdges()
.some( .some(
@ -102,12 +102,11 @@ export default function Chat({ flow, reactFlowInstance }: ChatType) {
e.targetHandle.split("|")[2] === n.id e.targetHandle.split("|")[2] === n.id
) )
? [ ? [
`${type} is missing ${ `${type} is missing ${template.display_name
template.display_name ? template.display_name
? template.display_name : snakeToNormalCase(template[t].name)
: snakeToNormalCase(template[t].name) }.`,
}.`, ]
]
: [] : []
), ),
[] as string[] [] as string[]