import React from 'react';
import PropTypes from 'prop-types';

import styles from './number-rating.module.scss';
import { getRating } from '~helpers/rating';

const NumberRating = ({ total, rating }) => {
  const rate = getRating(rating);
  return <div className={styles.numberRatingContainer || ''}>{`${rate}/${total}`}</div>;
};

NumberRating.propTypes = {
  total: PropTypes.oneOfType([PropTypes.oneOf([5, 10]), PropTypes.oneOf(['5', '10'])]).isRequired,
  rating: PropTypes.oneOfType([PropTypes.array, PropTypes.number]).isRequired,
};

export default NumberRating;
