diff --git a/resources/js/Pages/Room.vue b/resources/js/Pages/Room.vue index c749fb6..1bdb6a3 100644 --- a/resources/js/Pages/Room.vue +++ b/resources/js/Pages/Room.vue @@ -5,7 +5,7 @@ import BaseTable from "@/Components/VotePresentation/BaseTable.vue"; import HorizontalTable from "@/Components/VotePresentation/HorizontalTable.vue"; import MainLayout from "@/Layouts/MainLayout.vue"; import { Head } from "@inertiajs/vue3"; -import { onMounted, ref } from "vue"; +import { computed, onMounted, ref } from "vue"; import { createRound, rooms, rounds } from "../api"; const props = defineProps({ @@ -72,6 +72,24 @@ onMounted(async () => { finished.value = e.round.finished_at !== null; }); }); + +const groupedVotes = computed(() => { + const groups = votes + .value + .reduce((grouped, vote) => { + if (typeof vote.vote === 'number' && !isNaN(vote.vote)) { + grouped[vote.vote] = (grouped[vote.vote] ?? 0) + 1 + } + + return grouped; + }, {}); + + const x = Object + .entries(groups); + + x.sort((a, b) => a[1] - b[1]); + return x; +})