/** @format */
/**
* External dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { Component, Fragment } from '@wordpress/element';
import Gridicon from 'gridicons';
import interpolateComponents from 'interpolate-components';
import { noop } from 'lodash';
/**
* Internal dependencies
*/
import { ActivityCard, ActivityCardPlaceholder } from '../activity-card';
import ActivityHeader from '../activity-header';
import {
Gravatar,
Link,
ProductImage,
ReviewRating,
Section,
SplitButton,
} from '@woocommerce/components';
// TODO Pull proper data from the API
const demoReviews = [
{
id: 1,
product_id: 1,
reviewer: 'Justin Shreve',
reviewer_email: 'justin@automattic.com',
rating: 3,
verified: true,
review:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque finibus hendrerit finibus.' +
'Integer tristique turpis a aliquam aliquam. Phasellus sapien lectus, sodales in sagittis nec, placerat a augue.',
status: 'pending',
date_created: '2018-07-10T02:49:00Z',
},
];
const demoProducts = [
{
id: 1,
name: 'WordPress Shirt',
permalink: '#',
images: [
{
id: 1,
src: 'https://cldup.com/5QyaPgyfFo-3000x3000.png',
},
],
},
];
class ReviewsPanel extends Component {
constructor( props ) {
super( props );
this.state = {
loading: true,
reviews: [],
};
}
componentDidMount() {
this.interval = setTimeout( () => {
this.setState( {
loading: false,
reviews: demoReviews,
} );
}, 5000 );
}
componentWillUnmount() {
clearTimeout( this.interval );
}
renderReview( review ) {
const product = demoProducts[ 0 ];
const title = interpolateComponents( {
mixedString: sprintf(
__(
'{{productLink}}%s{{/productLink}} reviewed by {{authorLink}}%s{{/authorLink}}',
'wc-admin'
),
product.name,
review.reviewer
),
components: {
productLink: ,
authorLink: ,
},
} );
const subtitle = (