<commit_before>import * as React from 'react';
import { Button } from '@shopify/polaris';
import { Tooltip } from '@blueprintjs/core';
import { TOpticonData, RequesterScores } from '../../types';
import { turkopticonBaseUrl } from '../../constants/urls';

export interface Props {
  readonly requesterId: string;
  readonly turkopticon?: TOpticonData;
}

class TOpticonButton extends React.PureComponent<Props, never> {
  static generateTooltipContent = (scores: RequesterScores) =>
    `Pay: ${scores.pay}.
    Comm: ${scores.comm}. 
    Fair: ${scores.fair}. 
    Fast: ${scores.fast}.`;

  public render() {
    const { requesterId, turkopticon } = this.props;

    return turkopticon ? (
      <Tooltip
        content={TOpticonButton.generateTooltipContent(turkopticon.attrs)}
      >
        <Button plain external url={turkopticonBaseUrl + requesterId}>
          T.O. Page
        </Button>
      </Tooltip>
    ) : (
      <Button plain disabled external url={turkopticonBaseUrl + requesterId}>
        No T.O. data.<commit_msg>Add number of reviews and TOS violations to TO tooltip.<commit_after>import * as React from 'react';
import { Button, Stack, TextContainer } from '@shopify/polaris';
import { Tooltip } from '@blueprintjs/core';
import { TOpticonData } from '../../types';
import { turkopticonBaseUrl } from '../../constants/urls';

export interface Props {
  readonly requesterId: string;
  readonly turkopticon?: TOpticonData;
}

class TOpticonButton extends React.PureComponent<Props, never> {
  static generateTooltipContent = (data: TOpticonData) => {
    const { attrs: { pay, comm, fair, fast }, reviews, tos_flags } = data;

    return (
      <Stack vertical>
        <TextContainer>
          Pay: {pay}. Comm: {comm}. Fair: {fair}. Fast: {fast}.
        </TextContainer>
        <TextContainer>Calculated from {reviews} reviews.</TextContainer>
        <TextContainer>{tos_flags} reported TOS violations.</TextContainer>
      </Stack>
    );
  };

  public render() {
    const { requesterId, turkopticon } = this.props;

    return turkopticon ? (
      <Tooltip content={TOpticonButton.generateTooltipContent(turkopticon)}>
        <Button plain external url={turkopticonBaseUrl + requesterId}>
          T.O. Page
        </Button>
      </Tooltip>
    ) : (
      <Button plain disabled external url={turkopticonBaseUrl + requesterId}>
        No T.O. data.
{'fraction_non_alphanumeric': 0.12792642140468227, 'fraction_numerical': 0.0, 'mean_word_length': 3.2204585537918873, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, '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': '3097195', 'n_tokens_mistral': 730, 'n_tokens_neox': 724, 'n_words': 184}