LeagueStats/client/src/views/Summoner.vue

85 lines
2.2 KiB
Vue
Raw Normal View History

2019-03-30 22:55:48 +00:00
<template>
<div v-if="overviewLoaded" key="overview" class="mt-3 flex text-center">
<div class="w-3/12">
<SummonerChampions />
<SummonerStats />
<SummonerMates />
</div>
<div class="w-9/12">
<div v-if="current">
<LiveMatch />
</div>
<div v-if="overview.matches.length">
<ul>
<Match
v-for="(match, index) in overview.matches"
:key="index"
:data="overview.matches[index]"
:index-match="index"
/>
</ul>
<LoadingButton
v-if="moreMatchesToFetch"
@clicked="moreMatches"
:loading="matchesLoading"
btn-class="mt-4 block mx-auto bg-blue-800 px-4 py-2 rounded-md font-semibold hover:bg-blue-1000 shadow-lg"
>More matches</LoadingButton>
</div>
</div>
2019-03-30 22:55:48 +00:00
</div>
2020-01-01 16:04:55 +00:00
<div v-else>
<OverviewLoader />
2019-12-27 21:09:24 +00:00
</div>
2019-03-30 22:55:48 +00:00
</template>
2019-03-30 22:55:48 +00:00
<script>
2019-09-11 20:02:05 +00:00
import { mapState, mapActions, mapGetters } from 'vuex'
import LiveMatch from '@/components/Match/LiveMatch.vue'
import LoadingButton from '@/components/LoadingButton.vue'
import Match from '@/components/Match/Match.vue'
2020-01-01 16:04:55 +00:00
import OverviewLoader from '@/components/Summoner/Overview/OverviewLoader.vue'
import SummonerChampions from '@/components/Summoner/Overview/SummonerChampions.vue'
import SummonerMates from '@/components/Summoner/Overview/SummonerMates.vue'
import SummonerStats from '@/components/Summoner/Overview/SummonerStats.vue'
2019-03-30 22:55:48 +00:00
export default {
components: {
LiveMatch,
LoadingButton,
2019-04-08 20:06:22 +00:00
Match,
2020-01-01 16:04:55 +00:00
OverviewLoader,
SummonerChampions,
SummonerMates,
SummonerStats,
2019-03-30 22:55:48 +00:00
},
2019-08-23 14:48:16 +00:00
2019-04-07 17:44:01 +00:00
computed: {
2019-09-08 20:08:49 +00:00
...mapState({
current: state => state.summoner.live.match,
overview: state => state.summoner.overview
2019-09-11 20:02:05 +00:00
}),
2019-12-27 21:09:24 +00:00
...mapGetters('summoner', ['matchesLoading', 'moreMatchesToFetch', 'overviewLoaded', 'summonerFound'])
},
watch: {
summonerFound() {
this.fetchData()
}
},
created() {
this.fetchData()
2019-08-23 14:48:16 +00:00
},
2019-03-30 22:55:48 +00:00
methods: {
fetchData() {
if (!this.overviewLoaded && this.summonerFound) {
this.overviewRequest()
}
},
...mapActions('summoner', ['moreMatches', 'overviewRequest']),
},
2019-08-23 14:48:16 +00:00
}
2019-03-30 22:55:48 +00:00
</script>