const initialState = [];
const changed = ' изменён статус запроса на';
var log = [];
var comments = [];
export function queryLog(state = initialState, action): object {
if (action.type === constants.LOAD_QUERY_LOG_STOP) {
log = action.queryLog;
}
if (action.type === constants.LOAD_COMMENTS_STOP) {
comments = action.comments;
}
let summ = log.concat(comments).map(el => {
el.date = el.dt_changelog * 1000 || el.datetime * 1000;
el.type = el.dt_changelog ? 'changelog' : 'comment';
el.text = el.dt_changelog ? changed : el.text;
el.author = el.dt_changelog ? el.usr.source : el.author;
el.status = ("Статус") in el.changelog ? el.changelog["Статус"].after : 'не назначен';
return el;
});
console.log('!!!!!!!!!!!!!!!!!!!!!');
console.log(comments);
console.log(log);
console.log(summ);
summ.sort(function(a, b) {
if (a.date > b.date) {
return 1;
}
if (a.date < b.date) {
return -1;
}
return 0;
});
return summ;
}