<commit_before>'use strict';

var React = require('react');
var AppActions = require('../actions/app-actions');
var AppStore = require('../stores/app-store');

var ReactBootstrap = require('react-bootstrap');

/*Renders a scheduler component based on user input appointments*/
var Scheduler = React.createClass({
	/*
		@workingDays	
	*/

	getInitialState: function(){
		return {
			selectedDay: {},

			workingDays: ['Monday', 
						  'Tuesday', 
						  'Wednesday', 
						  'Thursday', 
						  'Friday', 
						  'Saturday'],

			workingHours: [	{hour:9,  text:'09:00 a.m'}, 
							{hour:10, text:'10:00 a.m'}, 
							{hour:11, text:'11:00 a.m'}, 
							{hour:12, text:'12:00 p.m'}, 
							{hour:13, text:'01:00 p.m'},
							{hour:14, text:'02:00 p.m'},
							{hour:15, text:'03:00 p.m'},
							{hour:16, text:'04:00 p.m'}],
			patientName: '',
			patientNumber: '',
			showModal: false
		}
	},

	closeModal: function(){
		 this.setState({ showModal: false });
	},

	clearInputs: function(){

	},

	//clear modal and focus
	//https://facebook.github.io/react/docs/more-about-refs.html#completing-the-example
	resetModal: function(cb){
		this.setState({patientName: ''}, function(){
			 React.findDOMNode(this.refs.patientName).focus();  
		});
		this.setState({patientNumber: ''});
		cb();
	},

	handleClick: function(e){
	 
	 var node = React.findDOMNode(this.refs[e.hour]);
	 console.log(node.childNodes[e.day]);
	 this.setState({selectedDay: e});
	 this.setState({ showModal: true });
	},

	handleSaveClick: function(){
		AppActions.createAppointment({details: this.state.selectedDay, 
			patientInfo: {	name: this.state.patientName,
			 				phone: this.state.patientNumber
			}
		});

		this.resetModal(this.closeModal);
	},

	patientNamehandleChange: function(){
		this.setState({patientName : this.refs.patientName.getValue()});
	},

	patientNumberhandleChange: function(){
		this.setState({patientNumber : this.refs.patientNumber.getValue()});
	},

	render: function(){

		var Table = ReactBootstrap.Table;
		var Modal = ReactBootstrap.Modal;
		var Input = ReactBootstrap.Input;
		var Button = ReactBootstrap.Button;

		//creates the header for the scheduler
		var _workingdays = this.state.workingDays.map(function(day, i){
			return(
				<th>{day}</th>
			);
		});
		//creates the schedule slots for the days
		var _slots = function(id, h, handleClick){

			return(
				<span>
					<td>{h.text}</td>
				  	<td id='1' onClick={handleClick.bind(null, {hour: h.hour, day:1})}></td>
				  	<td id='2' onClick={handleClick.bind(null, {hour: h.hour, day:2})}></td>
			      	<td id='3' onClick={handleClick.bind(null, {hour: h.hour, day:3})}></td>
				  	<td id='4' onClick={handleClick.bind(null, {hour: h.hour, day:4})}></td>
				  	<td id='5' onClick={handleClick.bind(null, {hour: h.hour, day:5})}></td>
				</span>
			)

		};

		//creates the working hours for the days and bind the click
		//handler to the schedule slots
		var _schedule = this.state.workingHours.map(function(h, i){
			return (
					<tr key={i} ref={h.hour}><commit_msg>daysForSlot function<commit_after>'use strict';

var React = require('react');
var AppActions = require('../actions/app-actions');
var AppStore = require('../stores/app-store');

var ReactBootstrap = require('react-bootstrap');

/*Renders a scheduler component based on user input appointments*/
var Scheduler = React.createClass({
	/*
		@workingDays	
	*/

	getInitialState: function(){
		return {
			selectedDay: {},

			workingDays: ['Monday', 
						  'Tuesday', 
						  'Wednesday', 
						  'Thursday', 
						  'Friday'],

			workingHours: [	{hour:9,  text:'09:00 a.m'}, 
							{hour:10, text:'10:00 a.m'}, 
							{hour:11, text:'11:00 a.m'}, 
							{hour:12, text:'12:00 p.m'}, 
							{hour:13, text:'01:00 p.m'},
							{hour:14, text:'02:00 p.m'},
							{hour:15, text:'03:00 p.m'},
							{hour:16, text:'04:00 p.m'}],
			patientName: '',
			patientNumber: '',
			showModal: false
		}
	},

	closeModal: function(){
		 this.setState({ showModal: false });
	},

	clearInputs: function(){

	},

	//clear modal and focus
	//https://facebook.github.io/react/docs/more-about-refs.html#completing-the-example
	resetModal: function(cb){
		this.setState({patientName: ''}, function(){
			 React.findDOMNode(this.refs.patientName).focus();  
		});
		this.setState({patientNumber: ''});
		cb();
	},

	handleClick: function(e){
	 
	 var node = React.findDOMNode(this.refs[e.hour]);
	 console.log(node.childNodes[e.day]);
	 this.setState({selectedDay: e});
	 this.setState({ showModal: true });
	},

	handleSaveClick: function(){
		AppActions.createAppointment({details: this.state.selectedDay, 
			patientInfo: {	name: this.state.patientName,
			 				phone: this.state.patientNumber
			}
		});

		this.resetModal(this.closeModal);
	},

	patientNamehandleChange: function(){
		this.setState({patientName : this.refs.patientName.getValue()});
	},

	patientNumberhandleChange: function(){
		this.setState({patientNumber : this.refs.patientNumber.getValue()});
	},

	render: function(){

		var Table = ReactBootstrap.Table;
		var Modal = ReactBootstrap.Modal;
		var Input = ReactBootstrap.Input;
		var Button = ReactBootstrap.Button;

		//creates the header for the scheduler
		var _workingdays = this.state.workingDays.map(function(day, i){
			return(
				<th>{day}</th>
			);
		});

		//creates the schedule slots for the days
		var _slots = function(id, h, handleClick){

			//react way to do this
			var daysforSlot = this.state.workingDays.map(function(day, i){
				return (
					<td id={i} onClick={handleClick.bind(null, {hour: h.hour, day:i})}></td>
				)
			});

				// <td id='1' onClick={handleClick.bind(null, {hour: h.hour, day:1})}></td>
				  	// <td id='2' onClick={handleClick.bind(null, {hour: h.hour, day:2})}></td>
			    //   	<td id='3' onClick={handleClick.bind(null, {hour: h.hour, day:3})}></td>
				  	// <td id='4' onClick={handleClick.bind(null, {hour: h.hour, day:4})}></td>
				  	// <td id='5' onClick={handleClick.bind(null, {hour: h.hour, day:5})}></td>

			return(
				<span>
					<td>{h.text}</td>
					{daysforSlot}
				</span>
			)

		}.bind(this);

		//creates the working hours for the days and bind the click
		//handler to the schedule slots
		var _schedule = this.state.workingHours.map(function(h, i){
			return (
					<tr key={i} ref={h.hour}>
{'fraction_non_alphanumeric': 0.18229084606900897, 'fraction_numerical': 0.017961241531432172, 'mean_word_length': 3.4329608938547485, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 2, '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': '3285750', 'n_tokens_mistral': 2635, 'n_tokens_neox': 2166, 'n_words': 439}