Fetch and display todays wines.

This commit is contained in:
2020-12-31 17:29:53 +01:00
parent 30b63a8e61
commit 7a2b5600c4

View File

@@ -63,16 +63,18 @@ import { attendees, winners, 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";
import Wine from "@/ui/Wine";
import Winners from "@/ui/Winners"; import Winners from "@/ui/Winners";
import WinnerDraw from "@/ui/WinnerDraw"; import WinnerDraw from "@/ui/WinnerDraw";
import io from "socket.io-client"; import io from "socket.io-client";
export default { export default {
components: { Chat, Attendees, Winners, WinnerDraw, Vipps }, components: { Chat, Attendees, Winners, WinnerDraw, Vipps, Wine },
data() { data() {
return { return {
attendees: [], attendees: [],
winners: [], winners: [],
wines: [],
currentWinnerDrawn: false, currentWinnerDrawn: false,
currentWinner: {}, currentWinner: {},
socket: null, socket: null,
@@ -85,6 +87,7 @@ export default {
mounted() { mounted() {
this.track(); this.track();
this.getAttendees(); this.getAttendees();
this.getTodaysWines();
this.getWinners(); this.getWinners();
this.socket = io(window.location.origin); this.socket = io(window.location.origin);
this.socket.on("color_winner", msg => {}); this.socket.on("color_winner", msg => {});
@@ -116,13 +119,6 @@ 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: {
getWinners: async function() { getWinners: async function() {
let response = await winners(); let response = await winners();
@@ -131,6 +127,14 @@ export default {
} }
this.winnersFetched = true; this.winnersFetched = true;
}, },
getTodaysWines() {
prelottery()
.then(wines => {
this.wines = wines;
this.todayExists = wines.length > 0;
})
.catch(_ => this.todayExists = false)
},
getAttendees: async function() { getAttendees: async function() {
let response = await attendees(); let response = await attendees();
if (response) { if (response) {