If date in params, fetch only that date.
- Now handles only fetching date by epoch from url params. - Displays date w/ helper function humanReadableDate.
This commit is contained in:
@@ -2,14 +2,15 @@
|
|||||||
<div>
|
<div>
|
||||||
<h1>Historie fra tidligere lotteri</h1>
|
<h1>Historie fra tidligere lotteri</h1>
|
||||||
|
|
||||||
<div v-if="lotteries.length" v-for="lottery in lotteries">
|
<div v-if="lotteries.length || lotteries != null" v-for="lottery in lotteries">
|
||||||
<Winners :winners="lottery.winners" :title="`Vinnere fra ${lottery.dateString}`" />
|
<Winners :winners="lottery.winners" :title="`Vinnere fra ${humanReadableDate(lottery.date)}`" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { historyAll } from '@/api'
|
import { historyByDate, historyAll } from '@/api'
|
||||||
|
import { humanReadableDate } from "@/utils";
|
||||||
import Winners from '@/ui/Winners'
|
import Winners from '@/ui/Winners'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -20,9 +21,18 @@ export default {
|
|||||||
lotteries: [],
|
lotteries: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
humanReadableDate: humanReadableDate
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
historyAll()
|
const dateFromUrl = this.$route.params.date;
|
||||||
.then(history => this.lotteries = history.lotteries.reverse())
|
|
||||||
|
if (dateFromUrl !== undefined)
|
||||||
|
historyByDate(dateFromUrl)
|
||||||
|
.then(history => this.lotteries = { "lottery": history })
|
||||||
|
else
|
||||||
|
historyAll()
|
||||||
|
.then(history => this.lotteries = history.lotteries)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user