Chatwoot/app/javascript/dashboard/helper/actionQueryGenerator.js
Fayaz Ahmed 375d943a48
fix: Avoid filter payload changing to null on load more conversations (#3926)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>
2022-02-07 22:14:21 +05:30

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;