cinema/movie.riot

42 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

2022-04-02 12:00:24 +02:00
<movie>
2022-04-03 01:58:58 +02:00
<a href="./movie-page.html?id={props.movie.id}">{props.movie.title}</a>
2022-04-02 12:00:24 +02:00
<img src='https://image.tmdb.org/t/p/w300{props.movie.poster_path}'></img>
<label>{props.movie.vote_average}/10</label>
<label>{props.movie.vote_count} votes</label>
2022-04-03 01:58:58 +02:00
<ul class="genres">
<li class="genre" each={ genre in state.movie_genres }>{genre}</li>
</ul>
2022-04-02 12:00:24 +02:00
<script>
export default {
onBeforeMount(props, state) {
2022-04-03 01:58:58 +02:00
this.state = {
movie_genres: this.getGenresFromIds(),
}
2022-04-02 12:00:24 +02:00
},
2022-04-03 01:58:58 +02:00
getGenresFromIds() {
let ret = []
let genres = []
genres = JSON.parse(localStorage.getItem("genres")).genres;
this.props.movie.genre_ids.length
for(let i = 0; i<genres.length; i++)
{
for(let j = 0; j< this.props.movie.genre_ids.length; j++) {
if(genres[i].id == this.props.movie.genre_ids[j]) {
ret.push(genres[i].name)
}
}
}
//console.log(ret)
return ret
2022-04-02 12:00:24 +02:00
},
2022-04-03 01:58:58 +02:00
onBeforeUpdate(props, state) {
this.state.movie_genres = this.getGenresFromIds();
},
2022-04-02 12:00:24 +02:00
}
</script>
</movie>