{"size": 880, "ext": "js", "max_stars_repo_path": "shared/containers/filters/Categories.js", "max_stars_repo_name": "polbac/ctiamapreact", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "shared/containers/filters/Categories.js", "max_issues_repo_name": "polbac/ctiamapreact", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "shared/containers/filters/Categories.js", "max_forks_repo_name": "polbac/ctiamapreact", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.0, "max_line_length": 97, "alphanum_fraction": 0.6056818182}
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { inject } from 'mobx-react';
import { withJob } from 'react-jobs';

import { Dropdown } from 'components/filters';

class Categories extends Component {

  static propTypes = {
    jobResult: PropTypes.array,
    label: PropTypes.string,
  }

  static defaultProps = {
    label: 'Content Type',
  }

  render() {
    const { jobResult, ...rest } = this.props;
    const options = [
      { value: '', text: 'All' },
      ...jobResult.map(t => ({
        value: t.slug,
        text: t.name,
      })),
    ];

    return (
      <Dropdown options={options} {...rest} />
    );
  }
}

const contentTypeWithJob = withJob({
  work: ({ wordpress, include = [] }) => wordpress.getCategories({ include: include.join(',') }),
})(Categories);

export default inject('wordpress')(contentTypeWithJob);
