<commit_before>import React, {Component} from 'react'
import BigCalendar from 'react-big-calendar';
import moment from 'moment';
import {connect} from 'react-redux'
import Dropdown from './../Dropdown'
import {FormGroup, ControlLabel, FormControl} from 'react-bootstrap';

import Tags from './../ReactTags'
import TtnButton from './../Button/btn';
import '../../components/Calendar/style.css'
import TsmsForm from './../Form';
import {TimeEntryStatus} from './../../../constants/Index'
import {postActivities} from './../../actions/activity.actions'
import {getDate} from './../../../utils/common'

BigCalendar.setLocalizer(
    BigCalendar.momentLocalizer(moment)
);


class ModalContent extends Component{
    constructor(props){
        super(props);
        this.state = {
            showCalendar:false,
            activityType:'Select',
            hh:'Select',
            mm:0,
            collaborators:[],
            description:'',
            repeatActivity : [],
            events:[{
                "title":'today',
                "start":new Date(),
                "end":new Date()
            }]
        }
    }

   selectSlot(slot) {
        if( JSON.stringify(slot.start) === JSON.stringify(this.props.message)){
            alert("Sorry...You cannot repeat event on same date")
        } else{
            let newRepeatedDates = this.state.repeatActivity;
            let newevents = this.state.events;

            if(newRepeatedDates.indexOf(+new Date(getDate(slot.start)))>=0){
                console.log(newRepeatedDates.indexOf(+new Date(getDate(slot.start))))
                newRepeatedDates.splice((newRepeatedDates.indexOf(+new Date(getDate(slot.start)))),1)
                newevents.map((item,index) => {
                    if(item.start===getDate(slot.start)&&item.end===getDate(slot.start)){
                        newevents.splice(index,1)
                    }
                })
            }else{
                newRepeatedDates.push(+new Date(getDate(slot.start)));
                newevents.push({
                    "title": " ",
                    "start": getDate(slot.start),
                    "end": getDate(slot.start)
                })
            }

            this.setState({
                repeatActivity:newRepeatedDates,
                events:newevents
            },()=>{
                console.log(this.state.repeatActivity)
            });
        }
    } // todo : change color of selected slot

    setSelectedValue = (item, property) => {
        this.setState({
            [property]: item
        })
    };

    repeatEvent = () => {
        if(this.state.hh === 'Select' || this.state.activityType === 'Select')
            alert("First fill all the fields!!!")
        else{
            this.setState({
                showCalendar:true,
            })
        }
    };

    saveEvent = (event) => {
        event.preventDefault();
        console.log("type is ",typeof (this.state.hh),typeof (this.state.mm));
        console.log("this.state.repeatActivity",this.state.repeatActivity)
        if(this.state.hh === 'Select' || this.state.activityType === 'Select'){
            alert("Fields cannot be empty")
        }else{
            let dated = getDate(this.props.message);
            let activityLog = {
                "activityType":this.state.activityType,
                "status":TimeEntryStatus.Submitted,
                "hh":this.state.hh,
                "mm":this.state.mm,
                "collaborators":this.state.collaborators,
                "description":this.state.description,
                "date":+ new Date(dated),
                "repeatActivity":this.state.repeatActivity
            };

            this.props.postActivities(activityLog);
            this.props.close(event);

        }
    };


    onInputChange = (event) => {
        this.setState({
            [event.target.name] : event.target.value
        })
    };

    getTags = (tags) => {
        let empSet = new Set();
        tags.forEach(obj => {
            empSet.add(obj.id);
        });
        this.setState({
            collaborators: [...empSet]
        });
    }

    eventStyleGetterRepeat(event, start, end, isSelected) {
        console.log('event-------------------->>>>>>>>>>',event);
        let cssClass = "repeat-icon";
        if(event.title === " "){

            return {
                className:cssClass,
            };
        }else{
            return{
                className:cssClass
            }
        }<commit_msg>code refactored-useless consoles removed.<commit_after>import React, {Component} from 'react'
import BigCalendar from 'react-big-calendar';
import moment from 'moment';
import {connect} from 'react-redux'
import Dropdown from './../Dropdown'
import {FormGroup, ControlLabel, FormControl} from 'react-bootstrap';

import Tags from './../ReactTags'
import TtnButton from './../Button/btn';
import '../../components/Calendar/style.css'
import TsmsForm from './../Form';
import {TimeEntryStatus} from './../../../constants/Index'
import {postActivities} from './../../actions/activity.actions'
import {getDate} from './../../../utils/common'

BigCalendar.setLocalizer(
    BigCalendar.momentLocalizer(moment)
);


class ModalContent extends Component{
    constructor(props){
        super(props);
        this.state = {
            showCalendar:false,
            activityType:'Select',
            hh:'Select',
            mm:0,
            collaborators:[],
            description:'',
            repeatActivity : [],
            events:[{
                "title":'today',
                "start":new Date(),
                "end":new Date()
            }]
        }
    }

    selectSlot(slot) {
        if( JSON.stringify(slot.start) === JSON.stringify(this.props.message)){
            alert("Sorry...You cannot repeat event on same date")
        } else{
            let newRepeatedDates = this.state.repeatActivity;
            let newevents = this.state.events;

            if(newRepeatedDates.indexOf(+new Date(getDate(slot.start)))>=0){
                console.log(newRepeatedDates.indexOf(+new Date(getDate(slot.start))))
                newRepeatedDates.splice((newRepeatedDates.indexOf(+new Date(getDate(slot.start)))),1)
                newevents.map((item,index) => {
                    if(item.start===getDate(slot.start)&&item.end===getDate(slot.start)){
                        newevents.splice(index,1)
                    }
                })
            }else{
                newRepeatedDates.push(+new Date(getDate(slot.start)));
                newevents.push({
                    "title": " ",
                    "start": getDate(slot.start),
                    "end": getDate(slot.start)
                })
            }

            this.setState({
                repeatActivity:newRepeatedDates,
                events:newevents
            },()=>{
                console.log(this.state.repeatActivity)
            });
        }
    } // todo : change color of selected slot

    setSelectedValue = (item, property) => {
        this.setState({
            [property]: item
        })
    };

    repeatEvent = () => {
        if(this.state.hh === 'Select' || this.state.activityType === 'Select')
            alert("First fill all the fields!!!")
        else{
            this.setState({
                showCalendar:true,
            })
        }
    };

    saveEvent = (event) => {
        event.preventDefault();
        console.log("type is ",typeof (this.state.hh),typeof (this.state.mm));
        console.log("this.state.repeatActivity",this.state.repeatActivity)
        if(this.state.hh === 'Select' || this.state.activityType === 'Select'){
            alert("Fields cannot be empty")
        }else{
            let dated = getDate(this.props.message);
            let activityLog = {
                "activityType":this.state.activityType,
                "status":TimeEntryStatus.Submitted,
                "hh":this.state.hh,
                "mm":this.state.mm,
                "collaborators":this.state.collaborators,
                "description":this.state.description,
                "date":+ new Date(dated),
                "repeatActivity":this.state.repeatActivity
            };

            this.props.postActivities(activityLog);
            this.props.close(event);

        }
    };


    onInputChange = (event) => {
        this.setState({
            [event.target.name] : event.target.value
        })
    };

    getTags = (tags) => {
        let empSet = new Set();
        tags.forEach(obj => {
            empSet.add(obj.id);
        });
        this.setState({
            collaborators: [...empSet]
        });
    }

    eventStyleGetterRepeat(event, start, end, isSelected) {
        let cssClass = "repeat-icon";
        if(event.title === " "){

            return {
                className:cssClass,
            };
        }else{
            return{
                className:cssClass
            }
        }
{'fraction_non_alphanumeric': 0.14456895595251304, 'fraction_numerical': 0.000887606790191945, 'mean_word_length': 1.6613522291113079, 'pattern_counts': {'":': 28, '<': 3, '<?xml version=': 0, '>': 31, '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': '3624313', 'n_tokens_mistral': 2467, 'n_tokens_neox': 2391, 'n_words': 416}