import PropTypes from 'prop-types';
import useContestMetadata from "../../../hooks/election/useContestMetadata/index.js";

/**
 * A contest's description.
 *
 * This component takes a contest id and renders the contest's description.
 * If the contest does not have a description, the component returns null.
 */
const ContestName = function ContestName(props) {
  const {
    id
  } = props;
  const metadata = useContestMetadata(id);
  if (!metadata) return null;
  const {
    description
  } = metadata;
  if (!description) {
    return null;
  }
  return <>
      {description}
    </>;
};
ContestName.defaultProps = {};
ContestName.propTypes = {
  /**
   * The ID of the contest whose description you'd like to show.
   */
  id: PropTypes.string.isRequired
};
export default ContestName;