diff --git a/src/components/VinlottisPage.vue b/src/components/VinlottisPage.vue index a8da42e..b608cb3 100644 --- a/src/components/VinlottisPage.vue +++ b/src/components/VinlottisPage.vue @@ -52,6 +52,7 @@ import Banner from "@/ui/Banner"; import Wines from "@/ui/Wines"; import Vipps from "@/ui/Vipps"; import Countdown from "@/ui/Countdown"; +import { prelottery } from "@/api"; export default { components: { @@ -67,7 +68,6 @@ export default { data() { return { hardStart: false, - todayExists: false, pushAllowed: false }; }, @@ -81,21 +81,17 @@ export default { !this.pushAllowed || localStorage.getItem("push") == null ); + }, + todayExists: () => { + return prelottery() + .then(wines => wines.length > 0) + .catch(() => false) } }, mounted() { this.$on("push-allowed", () => { this.pushAllowed = true; }); - fetch("/api/wines/prelottery") - .then(wines => wines.json()) - .then(wines => { - if (wines.length > 0) { - this.todayExists = true; - } else { - this.todayExists = false; - } - }); if (window.location.hostname == "localhost") { return; } diff --git a/src/components/VirtualLotteryPage.vue b/src/components/VirtualLotteryPage.vue index 30fc135..9706119 100644 --- a/src/components/VirtualLotteryPage.vue +++ b/src/components/VirtualLotteryPage.vue @@ -15,6 +15,12 @@

Send vipps med melding "Vinlotteri" for å bli registrert til virtuelt lotteri

Send gjerne melding om fargeønsker også

+ + + Lurer du på dagens fangst? + Se her + + import { page, event } from "vue-analytics"; -import { attendees, winners, getChatHistory } from "@/api"; +import { attendees, winners, getChatHistory, prelottery } from "@/api"; import Chat from "@/ui/Chat"; import Vipps from "@/ui/Vipps"; import Attendees from "@/ui/Attendees"; @@ -124,6 +130,13 @@ export default { this.socket.disconnect(); this.socket = null; }, + computed: { + todayExists: () => { + return prelottery() + .then(wines => wines.length > 0) + .catch(() => false) + } + }, methods: { setUsername: function(username) { this.username = username; @@ -157,6 +170,38 @@ export default { }; + + +