<commit_before>import * as React from 'react';
import { Requester } from '../../types';
import { Button } from '@shopify/polaris';
import { calculateAverageScore } from '../../utils/turkopticon';
import { tutkopticonBaseUrl } from '../../constants';

interface Props {
  readonly requester: Requester | string;
  readonly id: string;
}

const RequesterButton = ({ requester, id }: Props) => {
  const buttonNoTO = (name: string) => {
    return (
      <Button plain url={tutkopticonBaseUrl + id} external>
        {`${name}`}
      </Button>
    );
  };

  const buttonTO = ({ name, attrs }: Requester) => {
    return (
      <Button plain url={tutkopticonBaseUrl + id} external>
        {`${name} - ${calculateAverageScore(attrs) || 'No Data'}`}
      </Button>
    );
  };

  return typeof requester === 'string' ? buttonNoTO(requester) : buttonTO(requester);
};<commit_msg>No longer display a button when requester has no TO data<commit_after>import * as React from 'react';
import { Requester } from '../../types';
import { Button } from '@shopify/polaris';
import { calculateAverageScore } from '../../utils/turkopticon';
import { tutkopticonBaseUrl } from '../../constants';

interface Props {
  readonly requester: Requester | string;
  readonly id: string;
}

const RequesterButton = ({ requester, id }: Props) => {
  const textNoTO = (name: string) => {
    return <p>{name}</p>;
  };

  const buttonTO = ({ name, attrs }: Requester) => {
    return (
      <Button plain url={tutkopticonBaseUrl + id} external>
        {`${name} - ${calculateAverageScore(attrs) || 'No Data'}`}
      </Button>
    );
  };

  return typeof requester === 'string' ? textNoTO(requester) : buttonTO(requester);
};
{'fraction_non_alphanumeric': 0.16715542521994134, 'fraction_numerical': 0.0, 'mean_word_length': 3.4196891191709846, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, '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': '2968935', 'n_tokens_mistral': 535, 'n_tokens_neox': 543, 'n_words': 142}