File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 11
11
<i v-for =" i in averageReviewScore" class =" fa fa-star" :key =" i" ></i >
12
12
</h1 >
13
13
14
+ <div >All reviews:</div >
15
+ <div v-for =" j in product.reviews" :key =" j.name+j.rating" >
16
+ <label >{{ j.name}}: </label >
17
+ <i v-for =" k in j.rating" class =" fa fa-star" :key =" k" ></i >
18
+ </div >
19
+
14
20
<div >
15
21
<p v-if =" product.inventory > 10" >In Stock</p >
16
22
<p v-else-if =" product.inventory" >Almost sold out</p >
@@ -58,6 +64,7 @@ import ProductReview from './ProductReview.vue';
58
64
ProductReview
59
65
}
60
66
})
67
+
61
68
export default class Product extends Vue {
62
69
@Prop ({default: false }) private premium! : boolean ;
63
70
@Prop () private cartLength: number ;
@@ -84,7 +91,7 @@ export default class Product extends Vue {
84
91
if (! this .product .reviews .length ) {
85
92
return null ;
86
93
}
87
- return Math .round (this .product .reviews .reduce ((a , c ) => a + c , 0 ) / this .product .reviews .length );
94
+ return Math .round (this .product .reviews .map ( x => x . rating ). reduce ((a , c ) => a + c , 0 ) / this .product .reviews .length );
88
95
}
89
96
90
97
get title() {
@@ -105,7 +112,7 @@ export default class Product extends Vue {
105
112
106
113
addReview(review : any ) {
107
114
const reviews = this .product .reviews as any ;
108
- reviews .push (review . rating );
115
+ reviews .push (review );
109
116
}
110
117
}
111
118
</script >
You can’t perform that action at this time.
0 commit comments