Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cli-socks/src/components/Product.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div class="product-info">
<h1>
{{ product.name }}
{{ title }}
<!-- eslint-disable-next-line vue/no-unused-vars -->
<i v-for="i in averageReviewScore" class="fa fa-star" :key="i"></i>
</h1>
Expand Down Expand Up @@ -56,13 +56,14 @@ export default class Product extends Vue {
product = {
name: "Vue Socks",
brand: "Vue",
price: 5,
variants: [
{id: 1, color: "green"},
{id: 2, color: "blue"}
],
inventory: 3,
reviews: []
}
};

selectedVariantIndex = 0;

Expand All @@ -77,6 +78,10 @@ export default class Product extends Vue {
return Math.round(this.product.reviews.reduce((a, c) => a + c, 0) / this.product.reviews.length);
}

get title() {
return `${this.product.name} ($${this.product.price})`;
}

addToCart() {
this.product.inventory--;
const selectedVariant = this.product.variants[this.selectedVariantIndex];
Expand Down