2018-07-23 13:19:24 +00:00
|
|
|
/** @format */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2018-08-20 21:18:13 +00:00
|
|
|
import Rating from './index';
|
2018-07-23 13:19:24 +00:00
|
|
|
|
2018-08-31 17:27:21 +00:00
|
|
|
/**
|
|
|
|
* Display a set of stars representing the review's rating.
|
|
|
|
*
|
|
|
|
* @return { object } -
|
|
|
|
*/
|
2018-08-20 21:18:13 +00:00
|
|
|
const ReviewRating = ( { review, ...props } ) => {
|
|
|
|
const rating = ( review && review.rating ) || 0;
|
|
|
|
return <Rating rating={ rating } { ...props } />;
|
|
|
|
};
|
2018-07-23 13:19:24 +00:00
|
|
|
|
|
|
|
ReviewRating.propTypes = {
|
2018-08-31 17:27:21 +00:00
|
|
|
/**
|
|
|
|
* A review object containing a `rating`.
|
|
|
|
* See https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-product-reviews.
|
|
|
|
*/
|
2018-07-23 13:19:24 +00:00
|
|
|
review: PropTypes.object.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ReviewRating;
|