<commit_before>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Modal from 'components/Modal';
import Button from 'components/Button';
import StartScreen from './StartScreen';
import SelectAttachmentScreen from './SelectAttachmentScreen';

const sectionObj = {
  start: {
    title: 'Which Content Type?',
    doneShown: false
  },
  selectVideo: {
    title: 'Select a Video',
    doneShown: true,
    back: 'start'
  },
  selectLink: {
    title: 'Select a Webpage',
    doneShown: true,
    back: 'start'
  }
};

export default class AttachContentModal extends Component {
  static propTypes = {
    onConfirm: PropTypes.func.isRequired,
    onHide: PropTypes.func.isRequired
  };

  state = {
    section: 'start',
    selected: undefined
  };

  render() {
    const { onHide } = this.props;
    const { section, selected } = this.state;
    return (
      <Modal
        large={section === 'selectVideo' || section === 'selectLink'}
        onHide={onHide}
      >
        <header>{sectionObj[section].title}</header>
        <main>
          {section === 'start' && (
            <StartScreen navigateTo={section => this.setState({ section })} />
          )}
          {section === 'selectVideo' && (
            <SelectAttachmentScreen
              type="video"
              onSelect={video =>
                this.setState({
                  selected: { type: 'video', id: video.id, title: video.title }
                })
              }
              onDeselect={() => this.setState({ selected: undefined })}
            />
          )}
          {section === 'selectLink' && (
            <SelectAttachmentScreen
              type="url"
              onSelect={link =>
                this.setState({
                  selected: { type: 'url', id: link.id, title: link.title }
                })
              }
              onDeselect={() => this.setState({ selected: undefined })}
            />
          )}
          {section === 'add' && <div>something</div>}
        </main>
        <footer>
          <Button
            transparent
            onClick={
              sectionObj[section].back
                ? () =>
                    this.setState({
                      section: sectionObj[section].back,
                      selected: undefined
                    })
                : onHide
            }
          >
            {sectionObj[section].back ? 'Back' : 'Cancel'}
          </Button>
          {sectionObj[section].doneShown && (
            <Button
              disabled={!selected}
              primary
              style={{ marginLeft: '0.7rem' }}
              onClick={this.onConfirm}
            >
              Confirm
            </Button>
          )}
        </footer>
      </Modal>
    );
  }

  onConfirm = () => {
    const { onConfirm } = this.props;
    const { selected } = this.state;
    onConfirm(selected);
  };

  onContentUpload = data => {
    this.setState({ section: 'confirm' });
  };
}<commit_msg>remove unnecessary code<commit_after>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Modal from 'components/Modal';
import Button from 'components/Button';
import StartScreen from './StartScreen';
import SelectAttachmentScreen from './SelectAttachmentScreen';

const sectionObj = {
  start: {
    title: 'Which Content Type?',
    doneShown: false
  },
  selectVideo: {
    title: 'Select a Video',
    doneShown: true,
    back: 'start'
  },
  selectLink: {
    title: 'Select a Webpage',
    doneShown: true,
    back: 'start'
  }
};

export default class AttachContentModal extends Component {
  static propTypes = {
    onConfirm: PropTypes.func.isRequired,
    onHide: PropTypes.func.isRequired
  };

  state = {
    section: 'start',
    selected: undefined
  };

  render() {
    const { onHide } = this.props;
    const { section, selected } = this.state;
    return (
      <Modal
        large={section === 'selectVideo' || section === 'selectLink'}
        onHide={onHide}
      >
        <header>{sectionObj[section].title}</header>
        <main>
          {section === 'start' && (
            <StartScreen navigateTo={section => this.setState({ section })} />
          )}
          {section === 'selectVideo' && (
            <SelectAttachmentScreen
              type="video"
              onSelect={video =>
                this.setState({
                  selected: { type: 'video', id: video.id, title: video.title }
                })
              }
              onDeselect={() => this.setState({ selected: undefined })}
            />
          )}
          {section === 'selectLink' && (
            <SelectAttachmentScreen
              type="url"
              onSelect={link =>
                this.setState({
                  selected: { type: 'url', id: link.id, title: link.title }
                })
              }
              onDeselect={() => this.setState({ selected: undefined })}
            />
          )}
          {section === 'add' && <div>something</div>}
        </main>
        <footer>
          <Button
            transparent
            onClick={
              sectionObj[section].back
                ? () =>
                    this.setState({
                      section: sectionObj[section].back,
                      selected: undefined
                    })
                : onHide
            }
          >
            {sectionObj[section].back ? 'Back' : 'Cancel'}
          </Button>
          {sectionObj[section].doneShown && (
            <Button
              disabled={!selected}
              primary
              style={{ marginLeft: '0.7rem' }}
              onClick={this.onConfirm}
            >
              Confirm
            </Button>
          )}
        </footer>
      </Modal>
    );
  }

  onConfirm = () => {
    const { onConfirm } = this.props;
    const { selected } = this.state;
    onConfirm(selected);
  };
}
{'fraction_non_alphanumeric': 0.13220225096589955, 'fraction_numerical': 0.0006719301192675962, 'mean_word_length': 1.5498929336188436, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 52, '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': '3754696', 'n_tokens_mistral': 1572, 'n_tokens_neox': 1572, 'n_words': 337}