Skip to content

Commit 0c90a93

Browse files
authored
Merge pull request #80 from jordanopensource/task/add_last_year_filter
Add last year to the period drop down
2 parents 921a6ff + 0c52e73 commit 0c90a93

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

components/PeriodDropdown.vue

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<template>
22
<div>
33
<select id="period" name="period" @change="onChange">
4+
<option value="last_year">Last Year</option>
45
<option value="last_30_days" selected>Last 30 Days</option>
56
<option value="last_month">Last Month</option>
67
<option value="this_year">This Year</option>
78
</select>
9+
<p v-if="period === 'last_year'">
10+
<small>{{ firstDayOfLastYear }} ➜ {{ lastDayOfLastYear }}</small>
11+
</p>
812
<p v-if="period === 'last_30_days'">
913
<small>{{ last30Days }} ➜ {{ todayDate }}</small>
1014
</p>
@@ -43,6 +47,24 @@ export default {
4347
month: 'long',
4448
}),
4549
last30Days: 0,
50+
firstDayOfLastYear: new Date(
51+
new Date().getFullYear() - 1,
52+
0,
53+
1
54+
).toLocaleString('en-GB', {
55+
day: 'numeric',
56+
month: 'long',
57+
year: 'numeric',
58+
}),
59+
lastDayOfLastYear: new Date(
60+
new Date().getFullYear() - 1,
61+
11,
62+
31
63+
).toLocaleString('en-GB', {
64+
day: 'numeric',
65+
month: 'long',
66+
year: 'numeric',
67+
}),
4668
}
4769
},
4870
computed: {

0 commit comments

Comments
 (0)