@@ -86,56 +86,57 @@ class ProductReviewsList extends Component {
8686 page : 0 ,
8787 } ;
8888
89+ get isEmptyContent ( ) : boolean {
90+ const { listItems } = this . props ;
91+
92+ const activeReviews = _ . filter ( listItems , ( review ) => {
93+ return review . attributes . status . v == 'submitted' ;
94+ } ) ;
95+
96+ return _ . isEmpty ( activeReviews ) ;
97+ }
98+
8999 get reviewsEmptyContentTitle ( ) : ?Element < any > {
90100 const { listItems, emptyContentTitle } = this . props ;
91101
92- if ( _ . isEmpty ( listItems ) ) {
93- return (
94- < div styleName = "product-reviews-subtitle" >
95- { emptyContentTitle }
96- </ div >
97- ) ;
98- }
99- return null ;
102+ return (
103+ < div styleName = "product-reviews-subtitle" >
104+ { emptyContentTitle }
105+ </ div >
106+ ) ;
100107 }
101108
102109 get displayReviews ( ) : ?Element < any > {
103110 const { listItems, showLoadMore } = this . props ;
104- const activeReviews = _ . filter ( listItems , ( review ) => {
105- return review . attributes . status . v == 'submitted' ;
106- } ) ;
107- if ( ! _ . isEmpty ( activeReviews ) ) {
108- const reviews = _ . map ( listItems , ( review ) => {
109- return (
110- < ReviewBody
111- key = { review . id }
112- title = { review . attributes . title . v }
113- userName = { review . userName }
114- updatedAt = { review . updatedAt }
115- sku = { review . sku }
116- body = { review . attributes . body . v }
117- />
118- ) ;
119- } ) ;
120-
121- const loadMoreActionLink = ( showLoadMore )
122- ? (
123- < ActionLink
124- action = { this . handleLoadMoreReviews }
125- title = "LOAD MORE REVIEWS"
126- styleName = "product-review-load-more"
127- />
128- )
129- : null ;
130-
111+ const reviews = _ . map ( listItems , ( review ) => {
131112 return (
132- < div >
133- { reviews }
134- { loadMoreActionLink }
135- </ div >
113+ < ReviewBody
114+ key = { review . id }
115+ title = { review . attributes . title . v }
116+ userName = { review . userName }
117+ updatedAt = { review . updatedAt }
118+ sku = { review . sku }
119+ body = { review . attributes . body . v }
120+ />
136121 ) ;
137- }
138- return null ;
122+ } ) ;
123+
124+ const loadMoreActionLink = ( showLoadMore )
125+ ? (
126+ < ActionLink
127+ action = { this . handleLoadMoreReviews }
128+ title = "LOAD MORE REVIEWS"
129+ styleName = "product-review-load-more"
130+ />
131+ )
132+ : null ;
133+
134+ return (
135+ < div >
136+ { reviews }
137+ { loadMoreActionLink }
138+ </ div >
139+ ) ;
139140 }
140141
141142 handleLoadMoreReviews = ( ) => {
@@ -159,8 +160,7 @@ class ProductReviewsList extends Component {
159160 < div styleName = "product-reviews-title" >
160161 { title }
161162 </ div >
162- { this . reviewsEmptyContentTitle }
163- { this . displayReviews }
163+ { this . isEmptyContent ? this . reviewsEmptyContentTitle : this . displayReviews }
164164 </ div >
165165 ) ;
166166 }
0 commit comments