<commit_before>import React, { Component, PropTypes } from 'react';
import Helmet from 'react-helmet';
import { Grid, Row, Col, Glyphicon, Input } from 'react-bootstrap';
import { GuestList } from 'components';
import { connect } from 'react-redux';
import DayPicker from 'react-day-picker';
require('react-day-picker/lib/style.css');
const FormModal = require('components/FormModal/FormModal');
const CheckinForm = require('components/Checkin/checkinForm');
const GuestForm = require('components/GuestList/GuestForm');
const CheckinList = require('components/CheckinList/CheckinList');
const ButlerPopover = require('components/ButlerPopover/ButlerPopover');
const Notification = require('components/CheckinNotification/CheckinNotification');
const { startCheckin, finishCheckin, checkinGuest } = require('redux/modules/checkin');
const { updateGuest } = require('redux/modules/guests');
const moment = require('moment');
const { loadCheckins } = require('redux/modules/checkin');

function select(state) {
  return {
    guestNotification: state.guests.notification,
    guests: state.guests.idBasedData,
    checkins: state.checkin.checkins,
    showCheckinModal: state.checkin.showCheckinModal,
    checkinNotification: state.checkin.notification,
    selectedGuest: state.checkin.selectedGuest,
    checkinLoaded: state.checkin.loaded,
  };
}

@connect(select)
export default class Checkin extends Component {

  static propTypes = {
    guestNotification: PropTypes.shape({
      status: PropTypes.string,
      data: PropTypes.object
    }),
    checkinNotification: PropTypes.shape({
      status: PropTypes.string,
      data: PropTypes.object
    }),
    selectedGuest: PropTypes.object,
    showCheckinModal: PropTypes.bool.isRequired,
    guests: PropTypes.object,
    checkins: PropTypes.array,
    dispatch: PropTypes.func.isRequired,
    checkinLoaded: PropTypes.bool.isRequired,
  };

  static defaultProps = {
    notificationMessage: '',
    selectedGuest: null,
    showCheckinModal: false,
    checkins: [],
    checkinLoaded: false,
  };

  constructor(props) {
    super(props);
    this.state = {
      checkinDate: moment(),
      showUpdateGuest: false
    };
  }

  onClickCheckinLinkHandler(guest) {
    return (event) => {
      event.preventDefault();
      this.props.dispatch(startCheckin(guest));
    };
  }

  closeCheckin() {
    // Reset showUpdateGuest flag
    this.setState({ showUpdateGuest: false });
    this.props.dispatch(finishCheckin());
  }

  checkinHandler() {
    if (this.state.showUpdateGuest) {
      this.refs.guestForm.submit();
    }
    this.refs.checkinForm.submit();
    this.closeCheckin();
  }

  toggleUpdateGuest() {
    this.setState({ showUpdateGuest: !this.state.showUpdateGuest });
  }

  handleCheckinDateChange(event, date) {
    event.preventDefault();
    // Hide popover
    this.refs.butlerPopover.togglePopover();
    this.setState({ checkinDate: date });
    this.props.dispatch(loadCheckins(date));
  }

  render() {
    const { showCheckinModal, selectedGuest, guestNotification, checkinNotification, dispatch, checkinLoaded } = this.props;

    let guestId = null;
    let guestFirstName = null;
    let guestLastName = null;
    if (selectedGuest) {
      guestId = selectedGuest.id;
      guestFirstName = selectedGuest.firstName;
      guestLastName = selectedGuest.lastName;
    }
    const formattedCheckinDate = moment(this.state.checkinDate).format('MM-DD-YYYY');
    const style = require('./Checkin.scss');<commit_msg>Close checkin is not needed in the submit action. Upon successful submit, it will automatically dismiss the checkin window.<commit_after>import React, { Component, PropTypes } from 'react';
import Helmet from 'react-helmet';
import { Grid, Row, Col, Glyphicon, Input } from 'react-bootstrap';
import { GuestList } from 'components';
import { connect } from 'react-redux';
import DayPicker from 'react-day-picker';
require('react-day-picker/lib/style.css');
const FormModal = require('components/FormModal/FormModal');
const CheckinForm = require('components/Checkin/checkinForm');
const GuestForm = require('components/GuestList/GuestForm');
const CheckinList = require('components/CheckinList/CheckinList');
const ButlerPopover = require('components/ButlerPopover/ButlerPopover');
const Notification = require('components/CheckinNotification/CheckinNotification');
const { startCheckin, finishCheckin, checkinGuest } = require('redux/modules/checkin');
const { updateGuest } = require('redux/modules/guests');
const moment = require('moment');
const { loadCheckins } = require('redux/modules/checkin');

function select(state) {
  return {
    guestNotification: state.guests.notification,
    guests: state.guests.idBasedData,
    checkins: state.checkin.checkins,
    showCheckinModal: state.checkin.showCheckinModal,
    checkinNotification: state.checkin.notification,
    selectedGuest: state.checkin.selectedGuest,
    checkinLoaded: state.checkin.loaded,
  };
}

@connect(select)
export default class Checkin extends Component {

  static propTypes = {
    guestNotification: PropTypes.shape({
      status: PropTypes.string,
      data: PropTypes.object
    }),
    checkinNotification: PropTypes.shape({
      status: PropTypes.string,
      data: PropTypes.object
    }),
    selectedGuest: PropTypes.object,
    showCheckinModal: PropTypes.bool.isRequired,
    guests: PropTypes.object,
    checkins: PropTypes.array,
    dispatch: PropTypes.func.isRequired,
    checkinLoaded: PropTypes.bool.isRequired,
  };

  static defaultProps = {
    notificationMessage: '',
    selectedGuest: null,
    showCheckinModal: false,
    checkins: [],
    checkinLoaded: false,
  };

  constructor(props) {
    super(props);
    this.state = {
      checkinDate: moment(),
      showUpdateGuest: false
    };
  }

  onClickCheckinLinkHandler(guest) {
    return (event) => {
      event.preventDefault();
      this.props.dispatch(startCheckin(guest));
    };
  }

  closeCheckin() {
    // Reset showUpdateGuest flag
    this.setState({ showUpdateGuest: false });
    this.props.dispatch(finishCheckin());
  }

  checkinHandler() {
    if (this.state.showUpdateGuest) {
      this.refs.guestForm.submit();
    }
    this.refs.checkinForm.submit();
  }

  toggleUpdateGuest() {
    this.setState({ showUpdateGuest: !this.state.showUpdateGuest });
  }

  handleCheckinDateChange(event, date) {
    event.preventDefault();
    // Hide popover
    this.refs.butlerPopover.togglePopover();
    this.setState({ checkinDate: date });
    this.props.dispatch(loadCheckins(date));
  }

  render() {
    const { showCheckinModal, selectedGuest, guestNotification, checkinNotification, dispatch, checkinLoaded } = this.props;

    let guestId = null;
    let guestFirstName = null;
    let guestLastName = null;
    if (selectedGuest) {
      guestId = selectedGuest.id;
      guestFirstName = selectedGuest.firstName;
      guestLastName = selectedGuest.lastName;
    }
    const formattedCheckinDate = moment(this.state.checkinDate).format('MM-DD-YYYY');
    const style = require('./Checkin.scss');
{'fraction_non_alphanumeric': 0.11997744254899197, 'fraction_numerical': 0.0, 'mean_word_length': 4.1220216606498195, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '109042', 'n_tokens_mistral': 2101, 'n_tokens_neox': 2076, 'n_words': 406}