<commit_before>import React from 'react'
import DropdownButton from 'react-bootstrap/lib/DropdownButton';
import MenuItem from 'react-bootstrap/lib/MenuItem';
import request from 'request';
import Select from 'react-select';
import _ from 'underscore'

export default React.createClass({
  getInitialState: function() {
    return {
      selectedCoteacher: this.props.selected_teacher_id,
      selectedTeachersClassroomIds: this.props.selected_teachers_classrooms,
      classroomsToShow: this.classroomsToShow(),
      firstLoad: true,
      changesToSave: false
    }
  },

  componentDidMount: function(){
    this.handleSelect(this.props.selected_teacher_id)
  },

  classroomsToShow: function(){
    return this.props.classrooms.map((c)=>{
      return {label: c.name, value: c.id}
    })
  },

  markExtantClassrooms: function(teacherClassrooms, invitation, selectedClassrooms){
    this.props.classrooms.forEach((classroom)=>{
      let name = classroom.name
      const matchingClassroom = teacherClassrooms.find((id)=> classroom.id === id)
      if (matchingClassroom) {
        name += invitation ? ' (pending)' : '';
        selectedClassrooms.push({label: name, value: classroom.id})
      }
    })
  },

  matchSelectedClassroomIds: function() {
    const selectedClassrooms = [];
    console.log(this.state.selectedTeachersClassroomIds);
    this.markExtantClassrooms(this.state.selectedTeachersClassroomIds.invited_to_coteach, true, selectedClassrooms)
    this.markExtantClassrooms(this.state.selectedTeachersClassroomIds.is_coteacher, false, selectedClassrooms)
    this.setState({selectedClassrooms, originallySelectedClassrooms: selectedClassrooms, firstLoad: false, changesToSave: false})
  },

  getSelectedTeachersClassroomIds: function(coteacherId){
      const that = this;
      request.get({<commit_msg>clear pending from dropdown upon changing classrooms<commit_after>import React from 'react'
import DropdownButton from 'react-bootstrap/lib/DropdownButton';
import MenuItem from 'react-bootstrap/lib/MenuItem';
import request from 'request';
import Select from 'react-select';
import _ from 'underscore'

export default React.createClass({
  getInitialState: function() {
    return {
      selectedCoteacher: this.props.selected_teacher_id,
      selectedTeachersClassroomIds: this.props.selected_teachers_classrooms,
      firstLoad: true,
      changesToSave: false
    }
  },

  componentDidMount: function(){
    this.handleSelect(this.props.selected_teacher_id)
  },

  classroomsToShow: function(){
    return this.props.classrooms.map((c)=>{
      return {label: c.name, value: c.id}
    })
  },

  markExtantClassrooms: function(teacherClassrooms, invitation, selectedClassrooms){
    this.props.classrooms.forEach((classroom)=>{
      let name = classroom.name
      const matchingClassroom = teacherClassrooms.find((id)=> classroom.id === id)
      if (matchingClassroom) {
        name += invitation ? ' (pending)' : '';
        selectedClassrooms.push({label: name, value: classroom.id})
      }
    })
  },

  matchSelectedClassroomIds: function() {
    const selectedClassrooms = [];
    console.log(this.state.selectedTeachersClassroomIds);
    this.markExtantClassrooms(this.state.selectedTeachersClassroomIds.invited_to_coteach, true, selectedClassrooms)
    this.markExtantClassrooms(this.state.selectedTeachersClassroomIds.is_coteacher, false, selectedClassrooms)
    this.setState({selectedClassrooms, originallySelectedClassrooms: selectedClassrooms, firstLoad: false, changesToSave: false, classroomsToShow: this.classroomsToShow()})
  },

  getSelectedTeachersClassroomIds: function(coteacherId){
      const that = this;
      request.get({
{'fraction_non_alphanumeric': 0.10663058186738836, 'fraction_numerical': 0.0, 'mean_word_length': 4.642748091603053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '254176', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1048, 'n_words': 199}