375d943a48
Co-authored-by: Pranav Raj S <pranav@chatwoot.com> Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>
18 lines
551 B
JavaScript
18 lines
551 B
JavaScript
const generatePayload = data => {
|
|
const actions = JSON.parse(JSON.stringify(data));
|
|
let payload = actions.map(item => {
|
|
if (Array.isArray(item.action_params)) {
|
|
item.action_params = item.action_params.map(val => val.id);
|
|
} else if (typeof item.values === 'object') {
|
|
item.action_params = [item.action_params.id];
|
|
} else if (!item.action_params) {
|
|
item.action_params = [];
|
|
} else {
|
|
item.action_params = [item.action_params];
|
|
}
|
|
return item;
|
|
});
|
|
return payload;
|
|
};
|
|
|
|
export default generatePayload;
|