<commit_before>
import React from 'react';


class WaypointLinks extends React.Component {

  constructor(props) {
    super(props);
    
    this.state = {
      link: null
    };

    this.handleChange = this.handleChange.bind(this);
  } 

  handleChange(event) {

    var value = undefined;
    if (event.target.value)
      value = parseInt(event.target.value);
    this.setState({link: value});
  }

  render() {

    const { links, value, onChange, input } = this.props;

    const linksTo = input.value.map(pid => {
      const p = links.find(ln => ln.id === pid);
      return <div>{p.floor} - {p.roomName}</div>});

    var linkOptions = links.map(p => <option value={p.id} key={p.id}>{p.floor} - {p.roomName}</option>);

    return (
          <div class="form-group">
            <label htmlFor="linkTo">Link to</label>
            <select name="linkTo" component="select" class="form-control" onChange={this.handleChange}>
              <option value="">---</option>
              {linkOptions}
            </select>
            {this.state.link && <button type="button" class="btn btn-default" onClick={() => input.onChange([...input.value, this.state.link])}>add link</button>}
            {linksTo}
          </div>
    );
  }
}

export default WaypointLinks;<commit_msg>Fix the Waypoint Details for nodes without links.<commit_after>
import React from 'react';


class WaypointLinks extends React.Component {

  constructor(props) {
    super(props);
    
    this.state = {
      link: null
    };

    this.handleChange = this.handleChange.bind(this);
  } 

  handleChange(event) {

    var value = undefined;
    if (event.target.value)
      value = parseInt(event.target.value);
    this.setState({link: value});
  }

  render() {

    const { links, value, onChange, input } = this.props;

    const linksTo = (input.value||[]).map(pid => {
      const p = links.find(ln => ln.id === pid);
      return <div>{p.floor} - {p.roomName}</div>});

    var linkOptions = links.map(p => <option value={p.id} key={p.id}>{p.floor} - {p.roomName}</option>);

    return (
          <div class="form-group">
            <label htmlFor="linkTo">Link to other Floorplan</label>
            <select name="linkTo" component="select" class="form-control" onChange={this.handleChange}>
              <option value="">---</option>
              {linkOptions}
            </select>
            {this.state.link && <button type="button" class="btn btn-default" onClick={() => input.onChange([...input.value, this.state.link])}>add link</button>}
            {linksTo}
          </div>
    );
  }
}

export default WaypointLinks;
{'fraction_non_alphanumeric': 0.16692015209125474, 'fraction_numerical': 0.0, 'mean_word_length': 2.531543624161074, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 39, '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': '4900847', 'n_tokens_mistral': 823, 'n_tokens_neox': 807, 'n_words': 168}