<commit_before>import React from 'react';
import {AsyncTypeahead} from 'react-bootstrap-typeahead';
import Navbar from 'react-bootstrap/lib/Navbar';

export default class Search extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      searchSuggestions: [],
      searchQuery: ''
    };
  }

  doSearch(searchQuery) {
    if (!searchQuery) {
      return;
    }
    this.setState({ searchQuery });

    const { lat, lon, zoom } = this.props;

    // fetch(`https://www.freemap.sk/api/0.1/q/${encodeURIComponent(searchQuery)}&lat=${lat}&lon=${lon}&zoom=${zoom}`, {
    fetch(`https://nominatim.openstreetmap.org/search/${encodeURIComponent(searchQuery)}`
        + `?format=jsonv2&lat=${lat}&lon=${lon}&zoom=${zoom}&namedetails=1&extratags=1&countrycodes=SK`, {
      method: 'GET'
    }).then(res => res.json()).then(data => {
      const searchSuggestions = data.map((d, id) => {
        const name = d.namedetails.name;
        const tags = { name, type: d.type };
        return { id, label: name, lat: d.lat, lon: d.lon, tags };
      });
      this.setState({ searchSuggestions });
    });
  }

  onSelectionChange(selectedResults) {
    this.props.onSelectSearchResult(selectedResults[0]);
  }

  onSuggestionHighlightChange(result) {
    if (result && result.lat) {
      result.lat = parseFloat(result.lat);
    }
    if (result && result.lon) {
      result.lon = parseFloat(result.lon);
    }
    this.props.onSearchSuggestionHighlightChange(result);
  }

  render() {
    const b = (fn, ...args) => fn.bind(this, ...args);

    return (
      <Navbar.Form pullLeft>
          <AsyncTypeahead<commit_msg>moved search result fixing to correct place<commit_after>import React from 'react';
import {AsyncTypeahead} from 'react-bootstrap-typeahead';
import Navbar from 'react-bootstrap/lib/Navbar';

export default class Search extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      searchSuggestions: [],
      searchQuery: ''
    };
  }

  doSearch(searchQuery) {
    if (!searchQuery) {
      return;
    }
    this.setState({ searchQuery });

    const { lat, lon, zoom } = this.props;

    // fetch(`https://www.freemap.sk/api/0.1/q/${encodeURIComponent(searchQuery)}&lat=${lat}&lon=${lon}&zoom=${zoom}`, {
    fetch(`https://nominatim.openstreetmap.org/search/${encodeURIComponent(searchQuery)}`
        + `?format=jsonv2&lat=${lat}&lon=${lon}&zoom=${zoom}&namedetails=1&extratags=1&countrycodes=SK`, {
      method: 'GET'
    }).then(res => res.json()).then(data => {
      const searchSuggestions = data.map((d, id) => {
        const name = d.namedetails.name;
        const tags = { name, type: d.type };
        return { id, label: name, lat: parseFloat(d.lat), lon: parseFloat(d.lon), tags };
      });
      this.setState({ searchSuggestions });
    });
  }

  onSelectionChange(selectedResults) {
    this.props.onSelectSearchResult(selectedResults[0]);
  }

  onSuggestionHighlightChange(result) {
    this.props.onSearchSuggestionHighlightChange(result);
  }

  render() {
    const b = (fn, ...args) => fn.bind(this, ...args);

    return (
      <Navbar.Form pullLeft>
          <AsyncTypeahead
{'fraction_non_alphanumeric': 0.16604010025062657, 'fraction_numerical': 0.0037593984962406013, 'mean_word_length': 3.251664447403462, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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': '1518510', 'n_tokens_mistral': 1046, 'n_tokens_neox': 1023, 'n_words': 173}