Fix campaign start throwing error when disabling schedule on the UI.

Closes #690
This commit is contained in:
Kailash Nadh 2022-02-04 22:43:42 +05:30
parent da30d4688e
commit 251c1ea64f

View file

@ -406,12 +406,7 @@ export default Vue.extend({
// Starts or schedule a campaign. // Starts or schedule a campaign.
startCampaign() { startCampaign() {
let status = ''; if (!this.canStart && !this.canSchedule) {
if (this.canStart) {
status = 'running';
} else if (this.canSchedule) {
status = 'scheduled';
} else {
return; return;
} }
@ -420,6 +415,15 @@ export default Vue.extend({
// First save the campaign. // First save the campaign.
this.updateCampaign().then(() => { this.updateCampaign().then(() => {
// Then start/schedule it. // Then start/schedule it.
let status = '';
if (this.canStart) {
status = 'running';
} else if (this.canSchedule) {
status = 'scheduled';
} else {
return;
}
this.$api.changeCampaignStatus(this.data.id, status).then(() => { this.$api.changeCampaignStatus(this.data.id, status).then(() => {
this.$router.push({ name: 'campaigns' }); this.$router.push({ name: 'campaigns' });
}); });