<commit_before>import React, { Component } from 'react';
import moment from 'moment';
import DatePicker from 'react-datepicker';
import {Button, Input, Form} from 'semantic-ui-react'
import 'react-datepicker/dist/react-datepicker.css';
import './Main.css';
import logo from '../airplane.svg';

const cities=[{value:'BOG', text:'Bogotá'} ,{value:'MDE', text:'Medellín'} ]

class Main extends Component {
  constructor(props){
    super(props);
    moment.locale('es');
    moment(new Date()).format("DD/MM/YYYY");
    this.state = {
      departureDate: moment(),
      arrivalDate: '',
      origin: '',
      destination: '',
      passengers: 1,
      roundTrip: true,
    }
    this.changeDepartureDate = this.changeDepartureDate.bind(this);
    this.changeArrivalDate = this.changeArrivalDate.bind(this);
    this.changeDestination = this.changeDestination.bind(this);
    this.changeOrigin = this.changeOrigin.bind(this);
    this.changePassengers = this.changePassengers.bind(this);
    this.changeCheck = this.changeCheck.bind(this);
  }
  changeDestination(event){
    this.setState({
      destination: event.target.value
    });
  }
  changeOrigin(event){
    this.setState({
      origin: event.target.value
    });
  }
  changeDepartureDate(date){
    //let localDate = moment(date, "MM/DD/YYYY hh:mm:ss A");
    if(date.isValid()){
      this.setState({
        departureDate: date //localDate.format('DD-MM-YYYY')
      });
    }
  }
  changeArrivalDate(date){
    if(date.isValid()){
      this.setState({
        arrivalDate: date
      });
    }
  }
  changePassengers(event){
    let aux = parseInt(event.target.value);
    if(Number.isInteger(aux) && aux>0 && aux < 1000){
      this.setState({
        passengers: +aux
      });
    }
  }
  changeCheck(event){
    console.info( event.target.checked);
    this.setState({
      roundTrip: event.target.checked
    });
  }

  submitStatus(){
    let filters = {
      departureDate: this.state.departureDate.format('DD-MM-YYYY'),
      origin: this.state.origin,
      destination: this.state.destination,
      passengers: this.state.passengers,

    }
    if(this.state.arrivalDate != ''){
      filters.arrivalDate = this.state.arrivalDate.format('DD-MM-YYYY');
      filters.roundTrip = this.state.roundTrip;
    } else {
      filters.roundTrip = false;
    }
    this.props.onChange(filters);
  }

  render() {
    return (<commit_msg>Date validations<commit_after>import React, { Component } from 'react';
import moment from 'moment';
import DatePicker from 'react-datepicker';
// import {Button, Input, Form} from 'semantic-ui-react'
import 'react-datepicker/dist/react-datepicker.css';
import './Main.css';
import logo from '../airplane.svg';

const cities=[{value:'BOG', text:'Bogotá'} ,{value:'MDE', text:'Medellín'} ];

class Main extends Component {
  constructor(props){
    super(props);
    moment.locale('es');
    moment(new Date()).format("DD/MM/YYYY");
    this.state = {
      departureDate: moment(),
      arrivalDate: '',
      origin: '',
      destination: '',
      passengers: 1,
      roundTrip: true
    }
    this.changeDepartureDate = this.changeDepartureDate.bind(this);
    this.changeArrivalDate = this.changeArrivalDate.bind(this);
    this.changeDestination = this.changeDestination.bind(this);
    this.changeOrigin = this.changeOrigin.bind(this);
    this.changePassengers = this.changePassengers.bind(this);
    this.changeCheck = this.changeCheck.bind(this);
  }
  changeDestination(event){
    this.setState({
      destination: event.target.value
    });
  }
  changeOrigin(event){
    this.setState({
      origin: event.target.value
    });
  }
  changeDepartureDate(date){
    //let localDate = moment(date, "MM/DD/YYYY hh:mm:ss A");
    if(date.isValid() && (date > moment().startOf('day'))){
      this.setState({
        departureDate: date //localDate.format('DD-MM-YYYY')
      });
    }
  }
  changeArrivalDate(date){
    if(date.isValid() && (date > moment().startOf('day'))){
      this.setState({
        arrivalDate: date
      });
    }
  }
  changePassengers(event){
    let aux = parseInt(event.target.value);
    if(Number.isInteger(aux) && aux>0 && aux < 1000){
      this.setState({
        passengers: +aux
      });
    }else if(!event.target.value){
      this.setState({
        passengers: ''
      });
    }
  }
  changeCheck(event){
    console.info( event.target.checked);
    this.setState({
      roundTrip: event.target.checked
    });
  }

  submitStatus(){
    let filters = {
      departureDate: this.state.departureDate.format('DD-MM-YYYY'),
      origin: this.state.origin,
      destination: this.state.destination,
      passengers: this.state.passengers,

    }
    if(this.state.arrivalDate != ''){
      filters.arrivalDate = this.state.arrivalDate.format('DD-MM-YYYY');
      filters.roundTrip = this.state.roundTrip;
    } else {
      filters.roundTrip = false;
    }
    this.props.onChange(filters);
  }

  render() {
    return (
{'fraction_non_alphanumeric': 0.15437048917401763, 'fraction_numerical': 0.0024057738572574178, 'mean_word_length': 3.0233870967741936, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2308571', 'n_tokens_mistral': 1605, 'n_tokens_neox': 1617, 'n_words': 263}