<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { push } from 'react-router-redux'
import { FormattedMessage, injectIntl } from 'react-intl';

import Button from 'material-ui/Button';
//import { LinearProgress } from 'material-ui/Progress';
import ArrowForward from 'material-ui-icons/ArrowForward';
import Done from 'material-ui-icons/Done';
import { red300, lightGreen300 } from 'material-ui/styles/colors';
import AlertErrorOutline from 'material-ui-icons/ErrorOutline';

import TableCard from '../components/TableCard';
import PageHeader from '../components/PageHeader';

import rest from '../utils/rest';


@injectIntl
class Children extends React.Component {
  state = {
    page: 0,
    pageEntries: 20,
    showAll: false,
    name: '',
    orderBy: 'name',
    order: 'asc'
  }

  // Refresh user list when component is first mounted
  componentWillMount() {
    this.refresh();
  }

  refresh(p = {}) {
    const { dispatch } = this.props;
    const params = Object.assign(this.state, p);

    this.setState({...this.state, params});

    let queryParams = {
      offset: params.page * params.pageEntries,
      limit: params.pageEntries,
      assigneeId: !params.showAll ? this.props.user.id : null,
      name: params.name,
      orderBy: params.orderBy,
      order: params.order
    };

    dispatch(rest.actions.children(queryParams));
  }

  refreshUser(userId) {
    this.props.dispatch(push('/children/' + userId));
  }

  render() {
    const { children, intl: { formatMessage } } = this.props;
    const initialPage = 0;
    const pageEntries = 20;

    return (
      <div>
        <PageHeader header={formatMessage({id: 'Children'})} />
        <TableCard
          initialPage={ initialPage }
          pageEntries={ pageEntries }
          model={ children }
          emptyMsg={ this.props.noFeedbackMsg }
          orderBy={this.state.orderBy}
          order={this.state.order}
          header={[
            {
              id: null,
              value: row => row.reviewed ?
                <Done style={{ verticalAlign: 'middle' }} color={lightGreen300}/> :
                <AlertErrorOutline style={{ verticalAlign: 'middle' }} color={red300}/>,

              style: { width: '20px' },
              maxShowWidth: 320
            },
            {
              id: 'name',
              value: row => row.name,
              columnTitle: <FormattedMessage id='name' />
            },
            {
              id: 'assignee',
              value: row => row.assignee,
              columnTitle: <FormattedMessage id='assignee' />,
              defaultValue: '(nobody)',
              maxShowWidth: 680
            },
            {
              id: 'received',
              value: row => new Date(row.createdAt).toLocaleDateString(),
              columnTitle: <FormattedMessage id='lastFeedback' />,
              maxShowWidth: 440
            },
            {
              component: (
                <Button style={{
                  minWidth: '40px'
                }}><ArrowForward/></Button>
              ),

              style: { width: '20px' }
            }
          ]}
          onClickRow={this.refreshUser.bind(this)}
          refresh={this.refresh.bind(this)}
        />
      </div><commit_msg>Show feedback alerts based on last given feedback date<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { push } from 'react-router-redux'
import { FormattedMessage, injectIntl } from 'react-intl';

import Button from 'material-ui/Button';
//import { LinearProgress } from 'material-ui/Progress';
import Alert from 'material-ui-icons/Warning';
import ArrowForward from 'material-ui-icons/ArrowForward';
import Done from 'material-ui-icons/Done';
import { red300, lightGreen300 } from 'material-ui/styles/colors';
import AlertErrorOutline from 'material-ui-icons/ErrorOutline';

import TableCard from '../components/TableCard';
import PageHeader from '../components/PageHeader';

import rest from '../utils/rest';


@injectIntl
class Children extends React.Component {
  state = {
    page: 0,
    pageEntries: 20,
    showAll: false,
    name: '',
    orderBy: 'name',
    order: 'asc'
  }

  // Refresh user list when component is first mounted
  componentWillMount() {
    this.refresh();
  }

  refresh(p = {}) {
    const { dispatch } = this.props;
    const params = Object.assign(this.state, p);

    this.setState({...this.state, params});

    let queryParams = {
      offset: params.page * params.pageEntries,
      limit: params.pageEntries,
      assigneeId: !params.showAll ? this.props.user.id : null,
      name: params.name,
      orderBy: params.orderBy,
      order: params.order
    };

    dispatch(rest.actions.children(queryParams));
  }

  refreshUser(userId) {
    this.props.dispatch(push('/children/' + userId));
  }

  render() {
    const { children, intl: { formatMessage } } = this.props;
    const initialPage = 0;
    const pageEntries = 20;

    const threeMonthsAgo = new Date();
    threeMonthsAgo.setMonth(threeMonthsAgo.getMonth() - 3);

    return (
      <div>
        <PageHeader header={formatMessage({id: 'Children'})} />
        <TableCard
          initialPage={ initialPage }
          pageEntries={ pageEntries }
          model={ children }
          emptyMsg={ this.props.noFeedbackMsg }
          orderBy={this.state.orderBy}
          order={this.state.order}
          header={[
            {
              id: null,
              value: row => row.reviewed ?
                <Done style={{ verticalAlign: 'middle' }} color={lightGreen300}/> :
                <AlertErrorOutline style={{ verticalAlign: 'middle' }} color={red300}/>,

              style: { width: '20px' },
              maxShowWidth: 320
            },
            {
              id: 'name',
              value: row => row.name,
              columnTitle: <FormattedMessage id='name' />
            },
            {
              id: 'assignee',
              value: row => row.assignee,
              columnTitle: <FormattedMessage id='assignee' />,
              defaultValue: '(nobody)',
              maxShowWidth: 680
            },
            {
              id: 'received',
              value: row => <div>
                {
                  row.showAlerts && new Date(row.prevFeedbackDate) < threeMonthsAgo
                  ? <Alert style={{ paddingRight: 10 }} />
                  : null
                }
                { new Date(row.prevFeedbackDate).toLocaleDateString() }
              </div>,
              columnTitle: <FormattedMessage id='lastFeedback' />,
              maxShowWidth: 440
            },
            {
              component: (
                <Button style={{
                  minWidth: '40px'
                }}><ArrowForward/></Button>
              ),

              style: { width: '20px' }
            }
          ]}
          onClickRow={this.refreshUser.bind(this)}
          refresh={this.refresh.bind(this)}
        />
      </div>
{'fraction_non_alphanumeric': 0.1287281935846933, 'fraction_numerical': 0.009707371975239167, 'mean_word_length': 1.9388176932616783, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 38, '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': '6579295', 'n_tokens_mistral': 2053, 'n_tokens_neox': 1957, 'n_words': 444}