<commit_before>import React, { PropTypes } from 'react'
import cx from 'classnames'
import Link from 'react-router/lib/Link'
import groupBy from 'lodash/groupBy'
import map from 'lodash/map'
import { interpose } from '../../../lib/interpose'
import { sortStudiesByType } from '../../../object-student'

import Button from '../../components/button'
import Icon from '../../components/icon'
import { iosTrashOutline, iosArrowForward } from '../../icons/ionicons'

import './student-list-item.scss'

export default function StudentListItem(props) {
    const { student, isEditing, destroyStudent } = props

    const isLoading = student.isLoading ||
        student.isFetching ||
        student.isValdiating ||
        student.isChecking
    let opts = { loading: isLoading }
    if (!isLoading) {
        opts['can-graduate'] = student.data.present.canGraduate
        opts['cannot-graduate'] = !student.data.present.canGraduate
    }

    const classname = cx('student-list-item-container', opts)

    let sortedStudies = sortStudiesByType(student.data.present.studies)
    const groupedStudies = groupBy(sortedStudies, s => s.type)
    return (
        <li className={classname}>
            {isEditing &&
                <Button
                    className="delete"
                    type="flat"
                    onClick={() => destroyStudent(student.data.present.id)}
                >
                    <Icon>{iosTrashOutline}</Icon>
                    Delete
                </Button>}
            <Link
                className="student-list-item"
                to={`/s/${student.data.present.id}/`}
            >
                <span className="student-list-item-info">
                    <div className="name">
                        {`${student.data.present.name} ${process.env.NODE_ENV !== 'production' ? '(' + student.data.present.id + ')' : ''}` ||
                            ''}
                    </div>
                    <div className="areas">
                        {map(
                            interpose(
                                map(groupedStudies, group =>
                                    group.map(s => s.name).join(' · ')),
                                <span className="joiner">|</span>
                            ),
                            (group, i) => (
                                <span className="area-type" key={i}>
                                    {group}
                                </span>
                            )
                        )}
                    </div>
                </span>

                <Icon className="student-list-item--go">{iosArrowForward}</Icon>
            </Link>
        </li>
    )
}

StudentListItem.propTypes = {
    destroyStudent: PropTypes.func.isRequired,
    isEditing: PropTypes.bool.isRequired,
    student: PropTypes.object.isRequired,
}<commit_msg>port StudentListItem to flow<commit_after>// @flow
import React from 'react'
import cx from 'classnames'
import Link from 'react-router/lib/Link'
import groupBy from 'lodash/groupBy'
import map from 'lodash/map'
import { interpose } from '../../../lib/interpose'
import { sortStudiesByType } from '../../../object-student'

import Button from '../../components/button'
import Icon from '../../components/icon'
import { iosTrashOutline, iosArrowForward } from '../../icons/ionicons'

import './student-list-item.scss'

type PropTypes = {
    destroyStudent: (string) => any,
    isEditing: boolean,
    student: Object,
};

export default function StudentListItem(props: PropTypes) {
    const { student, isEditing, destroyStudent } = props

    const isLoading = student.isLoading ||
        student.isFetching ||
        student.isValdiating ||
        student.isChecking
    let classes: any = { loading: isLoading }
    if (!isLoading) {
        classes['can-graduate'] = student.data.present.canGraduate
        classes['cannot-graduate'] = !student.data.present.canGraduate
    }

    const classname = cx('student-list-item-container', classes)

    let sortedStudies = sortStudiesByType(student.data.present.studies)
    const groupedStudies = groupBy(sortedStudies, s => s.type)
    return (
        <li className={classname}>
            {isEditing &&
                <Button
                    className="delete"
                    type="flat"
                    onClick={() => destroyStudent(student.data.present.id)}
                >
                    <Icon>{iosTrashOutline}</Icon>
                    Delete
                </Button>}
            <Link
                className="student-list-item"
                to={`/s/${student.data.present.id}/`}
            >
                <span className="student-list-item-info">
                    <div className="name">
                        {`${student.data.present.name} ${process.env.NODE_ENV !== 'production' ? '(' + student.data.present.id + ')' : ''}` ||
                            ''}
                    </div>
                    <div className="areas">
                        {map(
                            interpose(
                                map(groupedStudies, group =>
                                    group.map(s => s.name).join(' · ')),
                                <span className="joiner">|</span>
                            ),
                            (group, i) => (
                                <span className="area-type" key={i}>
                                    {group}
                                </span>
                            )
                        )}
                    </div>
                </span>

                <Icon className="student-list-item--go">{iosArrowForward}</Icon>
            </Link>
        </li>
    )
}
{'fraction_non_alphanumeric': 0.1305255830142708, 'fraction_numerical': 0.0, 'mean_word_length': 1.409643605870021, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6983570', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1451, 'n_words': 280}