2019-12-03 20:57:52 +00:00
|
|
|
<template>
|
2019-12-27 21:09:24 +00:00
|
|
|
<div v-if="championsLoaded" class="mt-3">
|
|
|
|
|
<div class="mt-4 flex items-center">
|
|
|
|
|
<ChampionsSearch @search-champions="updateSearch" />
|
|
|
|
|
<FilterQueue @filter-queue="filterByQueue" :choices="queues" class="ml-4" />
|
2019-12-03 20:57:52 +00:00
|
|
|
</div>
|
2019-12-27 21:09:24 +00:00
|
|
|
<ChampionsTable
|
|
|
|
|
v-if="champions.length"
|
|
|
|
|
:champions="champions"
|
|
|
|
|
:search="searchChampions"
|
|
|
|
|
class="mt-6"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else class="mt-3">
|
|
|
|
|
<div class="mt-4 text-white">LOADING CHAMPIONS</div>
|
2019-12-03 20:57:52 +00:00
|
|
|
</div>
|
|
|
|
|
</template>
|
2019-12-21 16:56:31 +00:00
|
|
|
|
|
|
|
|
<script>
|
2019-12-27 21:09:24 +00:00
|
|
|
import { mapActions, mapGetters, mapState } from 'vuex'
|
2019-12-23 21:13:42 +00:00
|
|
|
import { gameModes } from '@/data/data.js'
|
2019-12-22 23:23:05 +00:00
|
|
|
import ChampionsSearch from '@/components/Summoner/Champions/ChampionsSearch.vue'
|
2019-12-21 16:56:31 +00:00
|
|
|
import ChampionsTable from '@/components/Summoner/Champions/ChampionsTable.vue'
|
2019-12-23 21:13:42 +00:00
|
|
|
import FilterQueue from '@/components/Summoner/Champions/FilterQueue.vue'
|
2019-12-21 16:56:31 +00:00
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
2019-12-22 23:23:05 +00:00
|
|
|
ChampionsSearch,
|
2019-12-21 16:56:31 +00:00
|
|
|
ChampionsTable,
|
2019-12-23 21:13:42 +00:00
|
|
|
FilterQueue,
|
2019-12-21 16:56:31 +00:00
|
|
|
},
|
|
|
|
|
|
2019-12-22 23:23:05 +00:00
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
searchChampions: ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-12-21 16:56:31 +00:00
|
|
|
computed: {
|
2019-12-23 21:13:42 +00:00
|
|
|
queues() {
|
|
|
|
|
// Only keep the gameModes the summoner has played
|
|
|
|
|
const queues = Object.keys(gameModes)
|
|
|
|
|
.filter(gameMode =>
|
|
|
|
|
gameModes[gameMode].type !== 'Bot' &&
|
|
|
|
|
this.matchList.find(match => match.queue === Number(gameMode))
|
|
|
|
|
)
|
|
|
|
|
.reduce((obj, key) => {
|
|
|
|
|
return {
|
|
|
|
|
...obj,
|
|
|
|
|
[key]: gameModes[key]
|
|
|
|
|
}
|
|
|
|
|
}, {})
|
|
|
|
|
return { '-1': { type: 'Normal', name: 'ALL QUEUES' }, ...queues }
|
|
|
|
|
},
|
2019-12-27 21:09:24 +00:00
|
|
|
...mapGetters('summoner', ['summonerFound']),
|
2019-12-21 16:56:31 +00:00
|
|
|
...mapState({
|
2019-12-27 17:38:43 +00:00
|
|
|
champions: state => state.summoner.champions.list,
|
|
|
|
|
championsLoaded: state => state.summoner.champions.championsLoaded,
|
|
|
|
|
matchList: state => state.summoner.basic.matchList
|
2019-12-21 16:56:31 +00:00
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
created() {
|
2019-12-27 21:09:24 +00:00
|
|
|
console.log('HELLO')
|
|
|
|
|
if (!this.championsLoaded && this.summonerFound) {
|
2019-12-21 16:56:31 +00:00
|
|
|
console.log('FETCH CHAMPIONS')
|
|
|
|
|
this.championStats()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
methods: {
|
2019-12-23 21:13:42 +00:00
|
|
|
filterByQueue(queue) {
|
2019-12-27 17:38:43 +00:00
|
|
|
queue = Number(queue)
|
|
|
|
|
queue = queue === -1 ? null : queue
|
2019-12-23 21:13:42 +00:00
|
|
|
this.championStats(queue)
|
|
|
|
|
},
|
2019-12-22 23:23:05 +00:00
|
|
|
updateSearch(search) {
|
|
|
|
|
this.searchChampions = search
|
|
|
|
|
},
|
2019-12-21 16:56:31 +00:00
|
|
|
...mapActions('summoner', ['championStats']),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|