<commit_before>// @flow

import React from 'react';
import Modal from 'react-bootstrap/Modal';
import Button from 'react-bootstrap/Button';
import {Glyph, GlyphStyles, GlyphSizes} from '../../utils/glyphs.js';
import _ from 'lodash';

type Props = {|
  showModal: boolean,
  title: string,
  size: string,
  handleClose: () => void
|};
type State = {|
  showModal: boolean,
|};


 /* Modal for showing user biography details */
class BioModal extends React.PureComponent<Props, State> {
  constructor(props: Props): void {
    super(props);
    this.state = {
      showModal: false,
    }
    this.closeModal = this.closeModal.bind(this);
  }

  componentWillReceiveProps(nextProps: Props): void {
    this.setState({ showModal: nextProps.showModal });
  }

  closeModal(): void {
    this.setState({showModal:false});
    this.props.handleClose();
  }

  defaultBiography(): void {
    return `${this.props.person.first_name} ${this.props.person.last_name} is contributing their talents to DemocracyLab, helping to empower a community of people and projects that use technology to advance the public good.`;
  }

  render(): React$Node {
    return this.props.person && (
      <div>
          <Modal show={this.state.showModal} onHide={this.closeModal} size={this.props.size} className="bio-modal-root">
              <Modal.Header closeButton>
                <div className="bio-modal-nametitle-container">
                  <h4 className="bio-modal-name"><a href={"/index/?section=Profile&id=" + this.props.person.id}>{this.props.person.first_name} {this.props.person.last_name}</a></h4>
                  <h5 className="bio-modal-title">{this.props.title}</h5>
                </div>
                <i className={Glyph(GlyphStyles.Close, GlyphSizes.X2)} onClick={this.closeModal}></i>
              </Modal.Header>
              <Modal.Body style={{whiteSpace: "pre-wrap"}}>
                <h5 className="bio-modal-about">About</h5>
                <p>{!_.isEmpty(this.props.person.about_me) ? this.props.person.about_me : this.defaultBiography()}</p>
              </Modal.Body>
              <Modal.Footer>
                <button onClick={this.closeModal} className="btn btn-secondary">Close</button>
              </Modal.Footer>
          </Modal>
      </div>
    );
  }
}

export default BioModal;
<commit_msg>fix bio modal duplicate close x<commit_after>// @flow

import React from 'react';
import Modal from 'react-bootstrap/Modal';
import Button from 'react-bootstrap/Button';
import _ from 'lodash';

type Props = {|
  showModal: boolean,
  title: string,
  size: string,
  handleClose: () => void
|};
type State = {|
  showModal: boolean,
|};


 /* Modal for showing user biography details */
class BioModal extends React.PureComponent<Props, State> {
  constructor(props: Props): void {
    super(props);
    this.state = {
      showModal: false,
    }
    this.closeModal = this.closeModal.bind(this);
  }

  componentWillReceiveProps(nextProps: Props): void {
    this.setState({ showModal: nextProps.showModal });
  }

  closeModal(): void {
    this.setState({showModal:false});
    this.props.handleClose();
  }

  defaultBiography(): void {
    return `${this.props.person.first_name} ${this.props.person.last_name} is contributing their talents to DemocracyLab, helping to empower a community of people and projects that use technology to advance the public good.`;
  }

  render(): React$Node {
    return this.props.person && (
      <div>
          <Modal show={this.state.showModal} onHide={this.closeModal} size={this.props.size} className="bio-modal-root">
              <Modal.Header closeButton>
                <div className="bio-modal-nametitle-container">
                  <h4 className="bio-modal-name"><a href={"/index/?section=Profile&id=" + this.props.person.id}>{this.props.person.first_name} {this.props.person.last_name}</a></h4>
                  <h5 className="bio-modal-title">{this.props.title}</h5>
                </div>
              </Modal.Header>
              <Modal.Body style={{whiteSpace: "pre-wrap"}}>
                <h5 className="bio-modal-about">About</h5>
                <p>{!_.isEmpty(this.props.person.about_me) ? this.props.person.about_me : this.defaultBiography()}</p>
              </Modal.Body>
              <Modal.Footer>
                <button onClick={this.closeModal} className="btn btn-secondary">Close</button>
              </Modal.Footer>
          </Modal>
      </div>
    );
  }
}

export default BioModal;

{'fraction_non_alphanumeric': 0.14717652289906624, 'fraction_numerical': 0.002890173410404624, 'mean_word_length': 2.8062605752961085, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 57, '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': '1459971', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1345, 'n_words': 279}