Added dagens fangst link to virtual lottery game page.

This commit is contained in:
2020-03-20 13:47:33 +01:00
parent 49b4594f8f
commit e51e6598a7
2 changed files with 52 additions and 11 deletions

View File

@@ -52,6 +52,7 @@ import Banner from "@/ui/Banner";
import Wines from "@/ui/Wines"; import Wines from "@/ui/Wines";
import Vipps from "@/ui/Vipps"; import Vipps from "@/ui/Vipps";
import Countdown from "@/ui/Countdown"; import Countdown from "@/ui/Countdown";
import { prelottery } from "@/api";
export default { export default {
components: { components: {
@@ -67,7 +68,6 @@ export default {
data() { data() {
return { return {
hardStart: false, hardStart: false,
todayExists: false,
pushAllowed: false pushAllowed: false
}; };
}, },
@@ -81,21 +81,17 @@ export default {
!this.pushAllowed || !this.pushAllowed ||
localStorage.getItem("push") == null localStorage.getItem("push") == null
); );
},
todayExists: () => {
return prelottery()
.then(wines => wines.length > 0)
.catch(() => false)
} }
}, },
mounted() { mounted() {
this.$on("push-allowed", () => { this.$on("push-allowed", () => {
this.pushAllowed = true; 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") { if (window.location.hostname == "localhost") {
return; return;
} }

View File

@@ -15,6 +15,12 @@
<h2>Send vipps med melding "Vinlotteri" for å bli registrert til virtuelt lotteri</h2> <h2>Send vipps med melding "Vinlotteri" for å bli registrert til virtuelt lotteri</h2>
<p>Send gjerne melding om fargeønsker også</p> <p>Send gjerne melding om fargeønsker også</p>
</div> </div>
<router-link to="dagens" class="generate-link" v-if="todayExists">
Lurer du på dagens fangst?
<span class="subtext generator-link">Se her</span>
</router-link>
<WinnerDraw <WinnerDraw
:currentWinnerDrawn="currentWinnerDrawn" :currentWinnerDrawn="currentWinnerDrawn"
:currentWinner="currentWinner" :currentWinner="currentWinner"
@@ -39,7 +45,7 @@
<script> <script>
import { page, event } from "vue-analytics"; 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 Chat from "@/ui/Chat";
import Vipps from "@/ui/Vipps"; import Vipps from "@/ui/Vipps";
import Attendees from "@/ui/Attendees"; import Attendees from "@/ui/Attendees";
@@ -124,6 +130,13 @@ export default {
this.socket.disconnect(); this.socket.disconnect();
this.socket = null; this.socket = null;
}, },
computed: {
todayExists: () => {
return prelottery()
.then(wines => wines.length > 0)
.catch(() => false)
}
},
methods: { methods: {
setUsername: function(username) { setUsername: function(username) {
this.username = username; this.username = username;
@@ -157,6 +170,38 @@ export default {
}; };
</script> </script>
<!-- TODO move link styling to global with more generic name -->
<style lang="scss" scoped>
@import "../styles/global.scss";
@import "../styles/variables.scss";
@import "../styles/media-queries.scss";
.generate-link {
color: #333333;
text-decoration: none;
display: block;
width: 100vw;
text-align: center;
margin-bottom: 0px;
@include mobile {
width: 60vw;
margin: auto;
}
}
.vipps-image {
width: 250px;
margin: auto;
display: block;
margin-top: 30px;
}
.generator-link {
font-weight: bold;
border-bottom: 1px solid #ff5fff;
}
</style>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "../styles/global.scss"; @import "../styles/global.scss";
@import "../styles/variables.scss"; @import "../styles/variables.scss";