<commit_before>import React from 'react';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import values from 'object.values';
import { getFirebaseApp } from './db/FirebaseApp';
import Loading from './Loading';

const propTypes = {
  location: PropTypes.object.isRequired,
};

const getSlug = () => location.pathname.slice(1);

class UserContactForm extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      what: '',
      where: '',
      slug: getSlug(),
      how: '',
      sending: false,
      messageSent: false,
    };

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

  handleSubmit(e) {
    e.preventDefault();
    this.setState({
      sending: true
    })
    fetch('https://us-central1-lost-item-ba357.cloudfunctions.net/notifyUser', {
      method: "POST", // *GET, POST, PUT, DELETE, etc.
      mode: "cors", // no-cors, cors, *same-origin
      cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
      credentials: "same-origin", // include, *same-origin, omit
      headers: {
        "Content-Type": "application/json; charset=utf-8",
      },
      redirect: "follow", // manual, *follow, error
      referrer: "no-referrer", // no-referrer, *client
      body: JSON.stringify(this.state), // body data type must match "Content-Type" header
    })
      .then(response => {
        if (response.status === 200) {
          this.setState({
            messageSent: true
          });

          // We found the item, scroll to top!
          window.scrollTo(0, 0);
        }

        this.setState({
          sending: false
        });
      }); // parses response to JSON
  }

  handleChange(name, e) {
    const change = {};
    change[name] = e.target.value;
    this.setState(change);
  }
  render() {
    const buttonText = 'Send';

    return (
      <div className="container">
        {this.state.messageSent &&
          <div>
            <div className="row">
              <div className="col-md-8 offset-md-2 shadow nomargin">
                <img src="images/moon.svg" />

                <div className="content">
                  <h2 className="big-title color-blue"><span>Hooray!</span></h2>

                  <br />

                  <p><strong>Thanks for helping get that item back to its rightful owner!</strong></p>

                  <p>By the way, do you want your own link that you can put on any of your items in case you ever lose them?</p>

                  <p>It's free, easy, and safer than writing your personal information on items!</p>

                  <p className="cta"><commit_msg>Show username when returning item<commit_after>import React from 'react';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import values from 'object.values';
import { getFirebaseApp } from './db/FirebaseApp';
import Loading from './Loading';

const propTypes = {
  location: PropTypes.object.isRequired,
};

const getSlug = () => location.pathname.slice(1);

class UserContactForm extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      what: '',
      where: '',
      slug: getSlug(),
      how: '',
      sending: false,
      messageSent: false,
    };

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

  handleSubmit(e) {
    e.preventDefault();
    this.setState({
      sending: true
    })
    fetch('https://us-central1-lost-item-ba357.cloudfunctions.net/notifyUser', {
      method: "POST", // *GET, POST, PUT, DELETE, etc.
      mode: "cors", // no-cors, cors, *same-origin
      cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
      credentials: "same-origin", // include, *same-origin, omit
      headers: {
        "Content-Type": "application/json; charset=utf-8",
      },
      redirect: "follow", // manual, *follow, error
      referrer: "no-referrer", // no-referrer, *client
      body: JSON.stringify(this.state), // body data type must match "Content-Type" header
    })
      .then(response => {
        if (response.status === 200) {
          this.setState({
            messageSent: true
          });

          // We found the item, scroll to top!
          window.scrollTo(0, 0);
        }

        this.setState({
          sending: false
        });
      }); // parses response to JSON
  }

  handleChange(name, e) {
    const change = {};
    change[name] = e.target.value;
    this.setState(change);
  }
  render() {
    const buttonText = 'Send';

    return (
      <div className="container">
        {this.state.messageSent &&
          <div>
            <div className="row">
              <div className="col-md-8 offset-md-2 shadow nomargin">
                <img src="images/moon.svg" />

                <div className="content">
                  <h2 className="big-title color-blue"><span>Hooray!</span></h2>

                  <br />

                  <p><strong>Thanks for helping get that item back to {this.props.user.name}!</strong></p>

                  <p>By the way, do you want your own link that you can put on any of your items in case you ever lose them?</p>

                  <p>It's free, easy, and safer than writing your personal information on items!</p>

                  <p className="cta">
{'fraction_non_alphanumeric': 0.1430456087448172, 'fraction_numerical': 0.005653976630229929, 'mean_word_length': 2.1589285714285715, 'pattern_counts': {'":': 2, '<': 43, '<?xml version=': 0, '>': 47, 'https://': 2, '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': '1179236', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1566, 'n_words': 409}