<commit_before>// @flow

import React from "react";
import {LocationInfo} from "../common/location/LocationInfo.js";
import {CountryData} from "../constants/Countries.js";
import type {Dictionary} from "../types/Generics.jsx";
import HiddenFormFields from "./HiddenFormFields.jsx";
import LocationAutocomplete from "../common/location/LocationAutocomplete.jsx";
import _ from "lodash";

export const LocationFormInputsByEntity: Dictionary<(LocationInfo) => string> = {
  Projects: {
    project_location: (location: LocationInfo) => location.location_id,
    project_country: (location: LocationInfo) => location.country,
    project_state: (location: LocationInfo) => location.state,
    project_city: (location: LocationInfo) => location.city,
    project_latitude: (location: LocationInfo) => location.latitude,
    project_longitude: (location: LocationInfo) => location.longitude
  }
};

type Props = {|
  location: ?LocationInfo,
  country: ?CountryData,
  formInputs: Dictionary<(LocationInfo) => string>,
  onSelect: (LocationInfo) => null
|};

type State = {|
  location: ?LocationInfo
|};

export class LocationAutocompleteForm extends React.PureComponent<Props, State> {
  constructor(props: Props): void {
    super();
    this.state = {
      location: props.location
    };
  }
  
  componentWillReceiveProps(nextProps: Props): void {
    if(!_.isEqual(nextProps.location, this.state.location)) {
      this.setState({location: nextProps.location});<commit_msg>Create/Edit Project bugfix: Was saving country code from location field rather than country field<commit_after>// @flow

import React from "react";
import {LocationInfo} from "../common/location/LocationInfo.js";
import {CountryData} from "../constants/Countries.js";
import type {Dictionary} from "../types/Generics.jsx";
import HiddenFormFields from "./HiddenFormFields.jsx";
import LocationAutocomplete from "../common/location/LocationAutocomplete.jsx";
import _ from "lodash";

export const LocationFormInputsByEntity: Dictionary<(LocationInfo) => string> = {
  Projects: {
    project_location: (location: LocationInfo) => location.location_id,
    project_state: (location: LocationInfo) => location.state,
    project_city: (location: LocationInfo) => location.city,
    project_latitude: (location: LocationInfo) => location.latitude,
    project_longitude: (location: LocationInfo) => location.longitude
  }
};

type Props = {|
  location: ?LocationInfo,
  country: ?CountryData,
  formInputs: Dictionary<(LocationInfo) => string>,
  onSelect: (LocationInfo) => null
|};

type State = {|
  location: ?LocationInfo
|};

export class LocationAutocompleteForm extends React.PureComponent<Props, State> {
  constructor(props: Props): void {
    super();
    this.state = {
      location: props.location
    };
  }
  
  componentWillReceiveProps(nextProps: Props): void {
    if(!_.isEqual(nextProps.location, this.state.location)) {
      this.setState({location: nextProps.location});
{'fraction_non_alphanumeric': 0.13077182339063026, 'fraction_numerical': 0.0, 'mean_word_length': 4.971830985915493, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 26, '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': '6981997', 'n_tokens_mistral': 853, 'n_tokens_neox': 848, 'n_words': 200}