<commit_before>import React, { Component, PropTypes } from 'react';
import s from './SettingsPage.scss';
import withStyles from '../../decorators/withStyles';

const title = 'Settings';

@withStyles(s)
class SettingsPage extends Component {
  static contextTypes = {
    onSetTitle: PropTypes.func.isRequired,
  };

  componentWillMount() {
    this.context.onSetTitle(title);
  }

  render() {
    return (
      <div>
        <header>
          <h2>Settings</h2>
        </header>
        <form>
          <div className={s.field}>
            <label htmlFor="hue_bridge_ip">Philips Hue bridge IP address:</label>
            <input type="text" id="hue_bridge_ip" placeholder="e.g., 192.168.1.182" />
          </div>
          <div className={s.field}>
            <label htmlFor="hue_bridge_user">Philips Hue bridge user:</label>
            <input type="text" id="hue_bridge_user" placeholder="e.g., 165131875f4bdff60d7f3dd05d46bd48" />
          </div><commit_msg>Save settings on form submit<commit_after>import React, { Component, PropTypes } from 'react';
import s from './SettingsPage.scss';
import withStyles from '../../decorators/withStyles';
import LocalStorage from '../../stores/localStorage';

const title = 'Settings';

@withStyles(s)
class SettingsPage extends Component {
  static contextTypes = {
    onSetTitle: PropTypes.func.isRequired,
  };

  constructor(props) {
    super(props);
    const settings = LocalStorage.getJSON();
    console.log('settings', settings);
    this.state = {
      hueBridgeUser: settings.hueBridgeUser,
      hueBridgeIp: settings.hueBridgeIp,
    };
  }

  componentWillMount() {
    this.context.onSetTitle(title);
  }

  handleBridgeIpChange(e) {
    this.setState({ hueBridgeIp: e.target.value });
  }

  handleBridgeUserChange(e) {
    this.setState({ hueBridgeUser: e.target.value });
  }

  handleSubmit(e) {
    e.preventDefault();
    LocalStorage.setMany({
      hueBridgeUser: this.state.hueBridgeUser,
      hueBridgeIp: this.state.hueBridgeIp,
    });
  }

  render() {
    return (
      <div>
        <header>
          <h2>Settings</h2>
        </header>
        <form onSubmit={this.handleSubmit.bind(this)}>
          <div className={s.field}>
            <label htmlFor="hue_bridge_ip">Philips Hue bridge IP address:</label>
            <input type="text" id="hue_bridge_ip"
              value={this.state.hueBridgeIp}
              onChange={this.handleBridgeIpChange.bind(this)}
              placeholder="e.g., 192.168.1.182"
            />
          </div>
          <div className={s.field}>
            <label htmlFor="hue_bridge_user">Philips Hue bridge user:</label>
            <input type="text" id="hue_bridge_user"
              value={this.state.hueBridgeUser}
              onChange={this.handleBridgeUserChange.bind(this)}
              placeholder="e.g., 165131875f4bdff60d7f3dd05d46bd48"
            />
          </div>
{'fraction_non_alphanumeric': 0.13578549329666553, 'fraction_numerical': 0.022000687521485048, 'mean_word_length': 2.6375, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1358943', 'n_tokens_mistral': 953, 'n_tokens_neox': 910, 'n_words': 163}