25 lines
483 B
JavaScript
25 lines
483 B
JavaScript
import React from "react"
|
|
import PropTypes from "prop-types"
|
|
|
|
export const Rating = ({ rating, votes }) => {
|
|
if (rating === 0) { return null; }
|
|
|
|
return (
|
|
<span>
|
|
<i className="fa fa-star mr-1"></i>
|
|
{Number(rating).toFixed(1)}
|
|
{votes !== 0 &&
|
|
<small className="ml-1">({votes} votes)</small>
|
|
}
|
|
</span>
|
|
);
|
|
}
|
|
Rating.propTypes = {
|
|
rating: PropTypes.number,
|
|
votes: PropTypes.number,
|
|
};
|
|
Rating.defaultProps = {
|
|
rating: 0,
|
|
votes: 0,
|
|
};
|