sort templates by id desc

This commit is contained in:
Amine Ben hammou
2018-02-15 15:24:05 +00:00
committed by pavel-mailpoet
parent 57b2c577c6
commit cfc425dfd7

View File

@@ -337,6 +337,12 @@ class NewsletterTemplates extends React.Component {
templates = response.data.reduce(this.addTemplate, {}); templates = response.data.reduce(this.addTemplate, {});
for(const category in templates) {
templates[category].sort((a, b) =>
parseInt(a.id) < parseInt(b.id) ? 1 : -1
);
}
}).fail((response) => { }).fail((response) => {
if (response.errors.length > 0) { if (response.errors.length > 0) {
MailPoet.Notice.error( MailPoet.Notice.error(
@@ -370,7 +376,7 @@ class NewsletterTemplates extends React.Component {
if (templates[category] === undefined) { if (templates[category] === undefined) {
templates[category] = []; templates[category] = [];
} }
templates[category].push(template); templates[category].unshift(template);
return templates; return templates;
}, templates); }, templates);
} }