Show undefined variable warning before sending messaeg
This commit is contained in:
parent
efa3d41ea6
commit
ea69d46b9e
4 changed files with 67 additions and 2 deletions
|
@ -40,3 +40,19 @@ export const getMessageVariables = ({ conversation }) => {
|
|||
'agent.email': assignee?.email ? assignee?.email : '',
|
||||
};
|
||||
};
|
||||
|
||||
export const getUndefinedVariablesInMessage = ({ message, variables }) => {
|
||||
const regex = /{{(.*?)}}/g;
|
||||
const matches = message.match(regex);
|
||||
const undefinedVariables = [];
|
||||
matches.forEach(match => {
|
||||
const variable = match
|
||||
.replace('{{', '')
|
||||
.replace('}}', '')
|
||||
.trim();
|
||||
if (!variables[variable]) {
|
||||
undefinedVariables.push(match);
|
||||
}
|
||||
});
|
||||
return undefinedVariables;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue