improved new step
This commit is contained in:
committed by
Tautvidas Sipavičius
parent
71bb743487
commit
3e80fcbd50
@ -15,11 +15,28 @@ define(
|
|||||||
mixins: [
|
mixins: [
|
||||||
Router.History
|
Router.History
|
||||||
],
|
],
|
||||||
handleSelectType: function(type) {
|
setupNewsletter: function(type) {
|
||||||
if(type !== undefined) {
|
if(type !== undefined) {
|
||||||
this.history.pushState(null, `/new/${type}`);
|
this.history.pushState(null, `/new/${type}`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
createNewsletter: function(type) {
|
||||||
|
MailPoet.Ajax.post({
|
||||||
|
endpoint: 'newsletters',
|
||||||
|
action: 'create',
|
||||||
|
data: {
|
||||||
|
type: type,
|
||||||
|
}
|
||||||
|
}).done(function(response) {
|
||||||
|
if(response.id !== undefined) {
|
||||||
|
this.history.pushState(null, `/template/${response.id}`);
|
||||||
|
} else {
|
||||||
|
response.map(function(error) {
|
||||||
|
MailPoet.Notice.error(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -42,7 +59,7 @@ define(
|
|||||||
<div className="mailpoet_actions">
|
<div className="mailpoet_actions">
|
||||||
<a
|
<a
|
||||||
className="button button-primary"
|
className="button button-primary"
|
||||||
onClick={ this.handleSelectType.bind(null, 'standard') }
|
onClick={ this.createNewsletter.bind(null, 'standard') }
|
||||||
>
|
>
|
||||||
Create
|
Create
|
||||||
</a>
|
</a>
|
||||||
@ -62,7 +79,7 @@ define(
|
|||||||
<div className="mailpoet_actions">
|
<div className="mailpoet_actions">
|
||||||
<a
|
<a
|
||||||
className="button button-primary"
|
className="button button-primary"
|
||||||
onClick={ this.handleSelectType.bind(null, 'welcome') }
|
onClick={ this.setupNewsletter.bind(null, 'welcome') }
|
||||||
>
|
>
|
||||||
Set up
|
Set up
|
||||||
</a>
|
</a>
|
||||||
|
Reference in New Issue
Block a user