<commit_before>import React from 'react';
import BigCalendar from 'react-big-calendar';
import Toolbar from './Toolbar';
import events from '../../events';
import physicians from './data/physicians';
import getAppts from './data/appts';


const formats = {
  dayFormat: (date, culture, localizer) => {
    return localizer.format(date, 'dddd MM/dd', culture);
  },
  dayHeaderFormat: (date, culture, localizer) => {
    return localizer.format(date, 'ddd, MMM dd, yyyy', culture);
  },
  dayRangeHeaderFormat: ({ start, end }, culture, localizer) => {
    return localizer.format(start, 'MMM dd', culture) + ' - ' +
      localizer.format(end, 'MMM dd, yyyy', culture);
  }
}

export default class Elation extends React.Component {

  state = {
    currentPhysicianId: physicians[0],
    appts: getAppts(physicians[0])
  }

  componentDidUpdate(prevProps, prevState) {
    if (prevState.currentPhysicianId !== this.state.currentPhysicianId) {
      this.setState({ appts: getAppts(this.state.currentPhysicianId) });
    }
  }

  render(){
    return (
      <BigCalendar
        {...this.props}
        events={this.state.appts}
        singleDayEventsOnly
        formats={formats}
        step={10}
        rightOffset={10}
        groupHeight={140}
        timeslots={6}
        views={['week', 'day']}
        messages={{
          week: '7 Days',
          day: 'Multi-Providers'
        }}
        defaultView="week"
        defaultDate={new Date(2015, 3, 12)}
        titleAccessor="_patientName"
        startAccessor={(event) => new Date(event._apptTime)}
        endAccessor={(event) => new Date(event._apptEnd)}
        components={{
          toolbar: Toolbar
        }}
        componentProps={{
          toolbar: {
            onCurrentPhysicianChange: (event) => {
              this.setState({ currentPhysicianId: event.target.value })
            }
          }
        }}
      />
    )
  }
}<commit_msg>Moved getAppts call to a callback instead of componentDidUpdate to prevent double-rendering<commit_after>import React from 'react';
import BigCalendar from 'react-big-calendar';
import Toolbar from './Toolbar';
import events from '../../events';
import physicians from './data/physicians';
import getAppts from './data/appts';


const formats = {
  dayFormat: (date, culture, localizer) => {
    return localizer.format(date, 'dddd MM/dd', culture);
  },
  dayHeaderFormat: (date, culture, localizer) => {
    return localizer.format(date, 'ddd, MMM dd, yyyy', culture);
  },
  dayRangeHeaderFormat: ({ start, end }, culture, localizer) => {
    return localizer.format(start, 'MMM dd', culture) + ' - ' +
      localizer.format(end, 'MMM dd, yyyy', culture);
  }
}

export default class Elation extends React.Component {

  state = {
    currentPhysicianId: physicians[0],
    appts: getAppts(physicians[0])
  }

  render(){
    return (
      <BigCalendar
        {...this.props}
        events={this.state.appts}
        singleDayEventsOnly
        formats={formats}
        step={10}
        rightOffset={10}
        groupHeight={140}
        timeslots={6}
        views={['week', 'day']}
        messages={{
          week: '7 Days',
          day: 'Multi-Providers'
        }}
        defaultView="week"
        defaultDate={new Date(2015, 3, 12)}
        titleAccessor="_patientName"
        startAccessor={(event) => new Date(event._apptTime)}
        endAccessor={(event) => new Date(event._apptEnd)}
        components={{
          toolbar: Toolbar
        }}
        componentProps={{
          toolbar: {
            onCurrentPhysicianChange: (event) => {
              this.setState({
                currentPhysicianId: event.target.value,
                appts: getAppts(event.target.value)
              })
            }
          }
        }}
      />
    )
  }
}
{'fraction_non_alphanumeric': 0.13861125723303525, 'fraction_numerical': 0.009468700683850605, 'mean_word_length': 2.4138240574506282, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '6626638', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1131, 'n_words': 247}