<commit_before>import React, { PropTypes } from 'react'
import classnames from 'classnames'

// Global module dependencies
import SelectableList from '~components/selectable-list'
import FilterableSearchBar from '~components/filterable-search-bar'

const TemplateSelectableList = props => {
  const {
    templates,
    filterableTemplates,
    setSelectedIndex,
    selectedIndex,
    handleSelectItem
  } = props

  const item = filterableTemplates.filter(item => item.id === selectedIndex)[0]

  return (
    <div className='mobilization-templates-selectable-list'>
      <FilterableSearchBar list={templates} />

      <div className='bg-white rounded-bottom' style={{ padding: '1.6rem 2rem' }}>
        <SelectableList
          selectedIndex={selectedIndex}
          setSelectedIndex={setSelectedIndex}
          list={filterableTemplates}
          emptyListText='Não existe nenhum template com esse nome'
        />
        <button
          disabled={!item}
          style={{ marginTop: '1.6rem' }}
          onClick={() => handleSelectItem(item)}
          className={classnames(
            'btn h3 col-12 white p2 rounded',
            !item ? 'bg-gray95' : 'bg-pagenta'
          )}
        >
          Continuar
        </button>
      </div>
    </div>
  )
}

TemplateSelectableList.propTypes = {
  templates: PropTypes.array.isRequired,
  filterableTemplates: PropTypes.array.isRequired,
  selectedIndex: PropTypes.number,
  setSelectedIndex: PropTypes.func.isRequired,
  handleSelectItem: PropTypes.func.isRequired
}

export default TemplateSelectableList<commit_msg>Add option to render and handle go back. Issue #485<commit_after>import React, { PropTypes } from 'react'
import classnames from 'classnames'

// Global module dependencies
import SelectableList from '~components/selectable-list'
import FilterableSearchBar from '~components/filterable-search-bar'

const btnStyle = {
  width: '100%'
}

const TemplateSelectableList = props => {
  const {
    templates,
    filterableTemplates,
    setSelectedIndex,
    selectedIndex,
    handleSelectItem,
    handleGoBack
  } = props

  const item = filterableTemplates.filter(item => item.id === selectedIndex)[0]

  return (
    <div className='mobilization-templates-selectable-list'>
      <FilterableSearchBar list={templates} />

      <div className='bg-white rounded-bottom' style={{ padding: '1.6rem 2rem' }}>
        <SelectableList
          selectedIndex={selectedIndex}
          setSelectedIndex={setSelectedIndex}
          list={filterableTemplates}
          emptyListText='Não existe nenhum template com esse nome'
        />
        <div className='flex flex-wrap' style={{ marginTop: '1.6rem' }}>
          {handleGoBack !== undefined ? (
            <div className='col-4'>
              <button
                style={btnStyle}
                onClick={() => handleGoBack()}
                className={classnames('btn h3 white p2 rounded bg-gray')}
              >
                Voltar
              </button>
            </div>
          ) : undefined}
          <div className={classnames(!handleGoBack ? 'col-12' : 'col-8 pl1')}>
            <button
              style={btnStyle}
              disabled={!item}
              onClick={() => handleSelectItem(item)}
              className={classnames(
                'btn h3 white p2 rounded',
                !item ? 'bg-gray95' : 'bg-pagenta'
              )}
            >
              Continuar
            </button>
          </div>
        </div>
      </div>
    </div>
  )
}

TemplateSelectableList.propTypes = {
  templates: PropTypes.array.isRequired,
  filterableTemplates: PropTypes.array.isRequired,
  selectedIndex: PropTypes.number,
  setSelectedIndex: PropTypes.func.isRequired,
  handleSelectItem: PropTypes.func.isRequired,
  handleGoBack: PropTypes.func
}

export default TemplateSelectableList
{'fraction_non_alphanumeric': 0.10866752910737387, 'fraction_numerical': 0.009055627425614488, 'mean_word_length': 2.559852670349908, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 34, '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': '3437109', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1071, 'n_words': 229}