Include send_at when cloning campaigns on the UI. Closes #1027.

This commit is contained in:
Kailash Nadh 2022-11-19 17:00:06 +05:30
parent 6fcb4ff978
commit 4f2f419ae2

View file

@ -260,6 +260,7 @@
</template> </template>
<script> <script>
import dayjs from 'dayjs';
import Vue from 'vue'; import Vue from 'vue';
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import CampaignPreview from '../components/CampaignPreview.vue'; import CampaignPreview from '../components/CampaignPreview.vue';
@ -400,6 +401,14 @@ export default Vue.extend({
}, },
cloneCampaign(name, c) { cloneCampaign(name, c) {
const now = this.$utils.getDate();
const sendLater = !!c.sendAt;
let sendAt = null;
if (sendLater) {
sendAt = dayjs(c.sendAt).isAfter(now) ? c.sendAt : now.add(7, 'day');
}
const data = { const data = {
name, name,
subject: c.subject, subject: c.subject,
@ -413,7 +422,10 @@ export default Vue.extend({
body: c.body, body: c.body,
altbody: c.altbody, altbody: c.altbody,
headers: c.headers, headers: c.headers,
send_later: sendLater,
send_at: sendAt,
}; };
this.$api.createCampaign(data).then((d) => { this.$api.createCampaign(data).then((d) => {
this.$router.push({ name: 'campaign', params: { id: d.id } }); this.$router.push({ name: 'campaign', params: { id: d.id } });
}); });