fix: Unable to save automation "send email to team" (#6052)

* fix: Unable to save automation "send email to team"

* chore: Minor fixes
This commit is contained in:
Sivin Varghese 2022-12-12 20:10:33 +05:30 committed by GitHub
parent 823c836906
commit 86958278cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,13 +17,22 @@ const formatArray = params => {
return params; return params;
}; };
const generatePayloadForObject = item => {
if (item.action_params.id) {
item.action_params = [item.action_params.id];
} else {
item.action_params = [item.action_params];
}
return item.action_params;
};
const generatePayload = data => { const generatePayload = data => {
const actions = JSON.parse(JSON.stringify(data)); const actions = JSON.parse(JSON.stringify(data));
let payload = actions.map(item => { let payload = actions.map(item => {
if (Array.isArray(item.action_params)) { if (Array.isArray(item.action_params)) {
item.action_params = formatArray(item.action_params); item.action_params = formatArray(item.action_params);
} else if (typeof item.action_params === 'object') { } else if (typeof item.action_params === 'object') {
item.action_params = [item.action_params.id]; item.action_params = generatePayloadForObject(item);
} else if (!item.action_params) { } else if (!item.action_params) {
item.action_params = []; item.action_params = [];
} else { } else {