Skip to content

Commit 3ab3837

Browse files
committed
Create the LastUpdated component
1 parent 95ad6d6 commit 3ab3837

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

components/LastUpdated.vue

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<template>
2+
<div v-if="lastUpdated" class="flex justify-end mr-24 pt-5">
3+
<p class="opacity-50">
4+
{{ lastUpdated }}
5+
</p>
6+
</div>
7+
</template>
8+
9+
<script>
10+
export default {
11+
name: 'LastUpdated',
12+
data() {
13+
return {
14+
lastUpdated: null,
15+
}
16+
},
17+
async fetch() {
18+
const response = await this.$axios.get('/v1/stats/updated')
19+
const year = new Date(response.data.lastUpdated).getFullYear()
20+
const month = new Date(response.data.lastUpdated).toLocaleString('en-GB', {
21+
month: '2-digit',
22+
})
23+
const day = new Date(response.data.lastUpdated).toLocaleString('en-GB', {
24+
day: '2-digit',
25+
})
26+
const time = new Date(response.data.lastUpdated).toLocaleTimeString('en-GB')
27+
this.lastUpdated = `The information on this site was last updated at ${year}-${month}-${day} ${time}`
28+
},
29+
}
30+
</script>
31+
32+
<style lang="postcss" scoped>
33+
.cards-container {
34+
@apply block py-2 w-11/12 mx-auto lg:flex lg:flex-nowrap lg:justify-center;
35+
}
36+
</style>

0 commit comments

Comments
 (0)