<commit_before>/**
 * Copyright (c) 2017, Shopgate, Inc. All rights reserved.
 *
 * This source code is licensed under the Apache 2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

import React from 'react';
import PropTypes from 'prop-types';
import I18n from '@shopgate/pwa-common/components/I18n';
import Link from '@shopgate/pwa-common/components/Router/components/Link';
import { REVIEW_PREVIEW_LIMIT } from 'Pages/Product/constants';
import connect from './connector';
import styles from './style';

/**
 * Link to all reviews.
 * @param {string} productId ProductId.
 * @param {number} totalReviewCount The number of reviews given.
 * @returns {JSX|null}
 */
const AllReviewsLink = ({ productId, totalReviewCount }) => {
  if (totalReviewCount < REVIEW_PREVIEW_LIMIT) {
    return null;
  }

  return (
    <Link href={`/item/${productId}/reviews`} className={styles}>
      <I18n.Text string="reviews.button_all" params={{ count: totalReviewCount }} />
    </Link>
  );
};

AllReviewsLink.propTypes = {
  productId: PropTypes.string.isRequired,
  totalReviewCount: PropTypes.number,
};

AllReviewsLink.defaultProps = {
  totalReviewCount: null,
};

export default connect(AllReviewsLink);<commit_msg>CON-1082 - productId encode for url<commit_after>/**
 * Copyright (c) 2017, Shopgate, Inc. All rights reserved.
 *
 * This source code is licensed under the Apache 2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

import React from 'react';
import PropTypes from 'prop-types';
import { bin2hex } from '@shopgate/pwa-common/helpers/data';
import I18n from '@shopgate/pwa-common/components/I18n';
import Link from '@shopgate/pwa-common/components/Router/components/Link';
import { REVIEW_PREVIEW_LIMIT } from 'Pages/Product/constants';
import connect from './connector';
import styles from './style';

/**
 * Link to all reviews.
 * @param {string} productId ProductId.
 * @param {number} totalReviewCount The number of reviews given.
 * @returns {JSX|null}
 */
const AllReviewsLink = ({ productId, totalReviewCount }) => {
  if (totalReviewCount < REVIEW_PREVIEW_LIMIT) {
    return null;
  }

  const publicProductId = bin2hex(productId);

  return (
    <Link href={`/item/${publicProductId}/reviews`} className={styles}>
      <I18n.Text string="reviews.button_all" params={{ count: totalReviewCount }} />
    </Link>
  );
};

AllReviewsLink.propTypes = {
  productId: PropTypes.string.isRequired,
  totalReviewCount: PropTypes.number,
};

AllReviewsLink.defaultProps = {
  totalReviewCount: null,
};

export default connect(AllReviewsLink);
{'fraction_non_alphanumeric': 0.12709284627092846, 'fraction_numerical': 0.01141552511415525, 'mean_word_length': 4.488517745302714, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1786851', 'n_tokens_mistral': 811, 'n_tokens_neox': 806, 'n_words': 226}