LeagueStats/client/src/views/Summoner.vue

153 lines
3.5 KiB
Vue
Raw Normal View History

2019-03-30 22:55:48 +00:00
<template>
<div>
2019-04-10 20:05:52 +00:00
<header class="search mb-4 bg-teal-900 text-teal-100">
<div class="container mx-auto flex justify-between py-8">
2019-08-19 22:08:13 +00:00
<router-link
to="/"
class="flex items-center text-lg text-teal-100 mr-8 hover:text-teal-200"
>Accueil</router-link>
2019-04-10 20:05:52 +00:00
2019-08-19 22:08:13 +00:00
<SearchForm @formSubmit="redirect" />
2019-03-30 22:55:48 +00:00
</div>
2019-04-10 20:05:52 +00:00
</header>
2019-08-19 22:08:13 +00:00
<template v-if="summonerFound && !loading">
<div class="container mx-auto pb-16">
2019-04-07 17:44:01 +00:00
<div class="player bg-blue-100">
2019-08-19 22:08:13 +00:00
<div
class="player__pp"
:style="{background: `url(https://ddragon.leagueoflegends.com/cdn/${this.$patch}/img/profileicon/${localInfos.profileIconId}.png) center/cover`}"
></div>
<h1 class="player__name">{{ localInfos.name }}</h1>
<h3 class="player__level">{{ localInfos.level }}</h3>
<h3 class="player__rank">{{ localInfos.rank }}</h3>
2019-08-19 22:08:13 +00:00
<div
class="player__rank-img"
:style="{background: `url(${localInfos.rankImgLink}) center/cover`}"
></div>
<h3
class="player__ratio"
>{{ localInfos.rankedWins ? localInfos.rankedWins + ' wins / ' + localInfos.rankedLosses + ' losses' : "Joueur non classé" }}</h3>
2019-09-08 20:08:49 +00:00
<RecentActivity :matches="localInfos.allMatches" />
2019-03-30 22:55:48 +00:00
<ul class="list-matches--debug">
<Match
2019-08-19 22:08:13 +00:00
v-for="(match, index) in localInfos.matches"
:key="index"
:data="localInfos.matches[index]"
/>
</ul>
</div>
2019-03-30 22:55:48 +00:00
</div>
</template>
<template v-else-if="loading">
2019-08-19 22:08:13 +00:00
<div
class="flex items-center justify-center bg-white max-w-xs mx-auto p-5 rounded-lg shadow-xl"
>
2019-08-23 14:48:16 +00:00
<dot-loader :loading="loading" />
</div>
</template>
<template v-else>
<p>Le joueur est introuvable.</p>
</template>
2019-03-30 22:55:48 +00:00
</div>
</template>
<script>
2019-05-17 20:58:36 +00:00
// import itemsJSON from '@/data/item.json'
2019-09-08 20:08:49 +00:00
import { mapState, mapActions } from 'vuex'
2019-08-23 14:48:16 +00:00
import RecentActivity from '@/components/RecentActivity.vue'
import Match from '@/components/Match.vue'
import SearchForm from '@/components/SearchForm.vue'
2019-03-30 22:55:48 +00:00
export default {
components: {
2019-04-08 20:06:22 +00:00
Match,
2019-08-19 22:08:13 +00:00
RecentActivity,
2019-04-08 20:06:22 +00:00
SearchForm
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-08-23 14:48:16 +00:00
summoner() {
2019-04-07 17:44:01 +00:00
return this.$route.params.name
2019-04-08 20:06:22 +00:00
},
2019-08-23 14:48:16 +00:00
region() {
2019-04-08 20:06:22 +00:00
return this.$route.params.region
2019-09-08 20:08:49 +00:00
},
...mapState({
localInfos: state => state.summoner.infos,
summonerFound: state => state.summoner.summonerFound,
loading: state => state.summoner.loading
})
2019-04-07 17:44:01 +00:00
},
2019-08-23 14:48:16 +00:00
watch: {
$route() {
console.log('route changed')
2019-09-08 20:08:49 +00:00
this.apiCall()
2019-08-23 14:48:16 +00:00
}
},
2019-09-08 20:08:49 +00:00
// created() {
// this.getChampionData()
// },
mounted() {
this.apiCall()
2019-08-23 14:48:16 +00:00
},
2019-03-30 22:55:48 +00:00
methods: {
2019-08-31 17:19:48 +00:00
async apiCall() {
2019-09-08 20:08:49 +00:00
await this.summonerRequest({ summoner: this.summoner, region: this.region })
},
2019-08-23 14:48:16 +00:00
redirect(summoner, region) {
2019-04-08 20:06:22 +00:00
this.$router.push(`/summoner/${region}/${summoner}`)
2019-03-30 22:55:48 +00:00
},
2019-09-08 20:08:49 +00:00
...mapActions('summoner', ['summonerRequest'])
2019-03-30 22:55:48 +00:00
}
2019-08-23 14:48:16 +00:00
}
2019-03-30 22:55:48 +00:00
</script>
<style scoped>
.debug {
position: absolute;
right: 0;
top: 0;
width: 40px;
height: 40px;
border: none;
z-index: 9999999999;
}
.debug:hover {
background: #ef5753;
}
.player {
text-align: center;
margin: 16px auto 0;
border: 1px solid #ebebeb;
padding: 16px;
/* background: #fff; */
2019-03-30 22:55:48 +00:00
}
.player__pp {
width: 75px;
height: 75px;
background: #ebebeb;
margin: 0 auto;
}
.player__rank-img {
width: 75px;
height: 75px;
background: #ebebeb;
margin: 0 auto;
}
.list-matches {
list-style-type: none;
padding: 0;
}
</style>