<commit_before>import { toastr } from 'react-redux-toastr';
import { truncate } from './formatting';
import { HitReturnStatus } from '../api/returnHit';

export const generateSearchToast = (successful: boolean) => {
  successful ? successfulSearchToast() : failedSearchToast();
};

export const generateAcceptHitToast = (successful: boolean, title: string) => {
  successful ? successfulAcceptToast(title) : failedAcceptToast(title);
};

export const generateQueueToast = (notEmpty: boolean) => {
  notEmpty ? successfulQueueToast() : emptyQueueToast();
};

export const generateReturnToast = (status: HitReturnStatus) => {
  switch (status) {
    case 'error':
      return errorReturnToast();
    case 'repeat':
      return repeatReturnToast();
    case 'success':
      return successfulReturnToast();
    default:
      return errorReturnToast();
  }
};

const successfulAcceptToast = (title: string) => {
  toastr.success(
    'Success!',
    `Hit: "${truncate(title, 10)}" was added to your queue. `
  );
};

const failedAcceptToast = (title: string) => {
  toastr.warning(
    `HIT was not added to your queue.`,
    `You may not be qualified, or no HITs may be available, or you may need to solve a CAPTCHA.`,
    { timeOut: 5000 }
  );
};

const successfulQueueToast = () => {
  toastr.success(
    'Refreshed queue',
    `Last checked: ${new Date().toLocaleTimeString()}`
  );
};

export const failedQueueToast = () => {
  toastr.warning('Error', `There was a problem refreshing your queue.`);
};

const emptyQueueToast = () => {
  toastr.info(
    'Your queue is empty.',
    `Last checked: ${new Date().toLocaleTimeString()}`
  );
};

const successfulSearchToast = () => {
  toastr.success(
    `Search successful`,
    `Last checked: ${new Date().toLocaleTimeString()}`
  );
};

const failedSearchToast = () => {
  toastr.error(
    `Error`,
    `Your search returned no results. Make sure you're logged in and check your search settings.`,
    { timeOut: 3000 }
  );
};

const repeatReturnToast = () => {
  // tslint:disable-next-line:quotemark
  toastr.light("Couldn't return HIT", "You've already returned this HIT.");
};

const successfulReturnToast = () => {
  toastr.success(
    'Return successful.',
    'A HIT has been removed from your queue.'
  );
};

export const errorReturnToast = () => {
  toastr.error(
    'Problem returning HIT.',
    'The error was probably on our end and that HIT is likely no longer in your queue.'<commit_msg>Queue related toasts should be more informative at a glance.<commit_after>import { toastr } from 'react-redux-toastr';
import { truncate } from './formatting';
import { HitReturnStatus } from '../api/returnHit';

export const generateSearchToast = (successful: boolean) => {
  successful ? successfulSearchToast() : failedSearchToast();
};

export const generateAcceptHitToast = (successful: boolean, title: string) => {
  successful ? successfulAcceptToast(title) : failedAcceptToast(title);
};

export const generateQueueToast = (notEmpty: boolean) => {
  notEmpty ? successfulQueueToast() : emptyQueueToast();
};

export const generateReturnToast = (status: HitReturnStatus) => {
  switch (status) {
    case 'error':
      return errorReturnToast();
    case 'repeat':
      return repeatReturnToast();
    case 'success':
      return successfulReturnToast();
    default:
      return errorReturnToast();
  }
};

const successfulAcceptToast = (title: string) => {
  toastr.success(
    'Success!',
    `Hit: "${truncate(title, 10)}" was added to your queue. `
  );
};

const failedAcceptToast = (title: string) => {
  toastr.warning(
    `${title} was not added to your queue.`,
    `You may not be qualified, or no HITs may be available, or you may need to solve a CAPTCHA.`,
    { timeOut: 5000 }
  );
};

const successfulQueueToast = () => {
  toastr.success('Refreshed queue', new Date().toLocaleTimeString());
};

export const failedQueueToast = () => {
  toastr.warning('Error', `There was a problem refreshing your queue.`);
};

const emptyQueueToast = () => {
  toastr.info('Your queue is empty.', new Date().toLocaleTimeString());
};

const successfulSearchToast = () => {
  toastr.success(`Search successful`, new Date().toLocaleTimeString());
};

const failedSearchToast = () => {
  toastr.error(
    `Error`,
    `Your search returned no results. Make sure you're logged in and check your search settings.`,
    { timeOut: 3000 }
  );
};

const repeatReturnToast = () => {
  // tslint:disable-next-line:quotemark
  toastr.light("Couldn't return HIT", "You've already returned this HIT.");
};

const successfulReturnToast = () => {
  toastr.success(
    'Return successful.',
    'A HIT has been removed from your queue.'
  );
};

export const errorReturnToast = () => {
  toastr.error(
    'Problem returning HIT.',
    'The error was probably on our end and that HIT is likely no longer in your queue.'
{'fraction_non_alphanumeric': 0.13925865246774524, 'fraction_numerical': 0.0040958427196395655, 'mean_word_length': 3.8986960882647943, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, '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': '6301982', 'n_tokens_mistral': 1498, 'n_tokens_neox': 1498, 'n_words': 431}