From 45f1f80a766913204205846cf26c018e0cbd3c2a Mon Sep 17 00:00:00 2001 From: Adrian Moya Date: Thu, 25 Jul 2024 08:30:04 -0400 Subject: [PATCH] fix(analytics): add to and from dates to campaign analytics URL (#1952) Co-authored-by: Adrian Moya --- frontend/src/views/CampaignAnalytics.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/CampaignAnalytics.vue b/frontend/src/views/CampaignAnalytics.vue index 67be5992..43cd385a 100644 --- a/frontend/src/views/CampaignAnalytics.vue +++ b/frontend/src/views/CampaignAnalytics.vue @@ -247,7 +247,7 @@ export default Vue.extend({ }, onSubmit() { - this.$router.push({ query: { id: this.form.campaigns.map((c) => c.id) } }); + this.$router.push({ query: { id: this.form.campaigns.map((c) => c.id), from: dayjs(this.form.from).unix(), to: dayjs(this.form.to).unix() } }); }, queryCampaigns(q) { @@ -300,8 +300,11 @@ export default Vue.extend({ created() { const now = dayjs().set('hour', 23).set('minute', 59).set('seconds', 0); - this.form.to = now.toDate(); - this.form.from = now.subtract(7, 'day').set('hour', 0).set('minute', 0).toDate(); + const weekAgo = now.subtract(7, 'day').set('hour', 0).set('minute', 0); + const from = this.$route.query.from ? dayjs.unix(this.$route.query.from) : weekAgo; + const to = this.$route.query.to ? dayjs.unix(this.$route.query.to) : now; + this.form.from = from.toDate(); + this.form.to = to.toDate(); }, mounted() {