<commit_before>import React, { useState, useEffect } from 'react';

import { IApi } from '../../model';
import { SearchBar } from '../../uiComponents';

import Link from 'next/link';
import lock from '../../uiComponents/icon/lock';
import { computeSearchResults } from '../searchApis/filtersLogic';

interface IProps {
  allApis: IApi[];
}

const DocumentationLeftMenu: React.FC<IProps> = ({ allApis }) => {
  const [searchTerm, setSearchTerm] = useState('');
  const [results, setResults] = useState(allApis);

  useEffect(() => {
    let res = allApis;
    const cleanedSearchTerms = searchTerm.split(' ').filter(t => !!t);

    if (cleanedSearchTerms.length > 0) {
      res = res
        .map(computeSearchResults(cleanedSearchTerms))
        .filter(api => api.score !== 0);
    }

    const newApiList = res.sort((a, b) =>
      (a.visits_2019 || 0) < (b.visits_2019 || 0) ? 1 : -1
    );

    setResults(newApiList);

    return () => {};
  }, [searchTerm, allApis]);

  return (
    <div id="documentation-left-column">
      <div className="search-wrapper layout-center">
        <SearchBar placeholder="Rechercher une API" onSearch={setSearchTerm} />
      </div>
      <div className="documentation-api-list">
        {results.length === 0 ? (
          <div>Aucun résultat n'a été trouvé.</div>
        ) : (
          results.map(api => (
            <Link
              href="/documentation/[slug]"
              as={`/documentation/${api.slug}`}
              key={api.slug}
            >
              <a>
                <div className="api-title">
                  {api.title}{' '}
                  {!api.doc_tech_link && (
                    <span
                      title="Cette API ne propose pas de documentation au format Open API"
                      className="swagger-label"
                    >
                      Pas&nbsp;de&nbsp;swagger
                    </span>
                  )}
                </div>
                {api.is_open !== 1 && (
                  <span
                    title="Cette API nécessite une habilitation"
                    className="is-open-label"
                  >
                    {lock}
                  </span>
                )}
              </a>
            </Link>
          ))
        )}
      </div>
    </div>
  );
};

export default DocumentationLeftMenu;<commit_msg>fix locker icon<commit_after>import React, { useState, useEffect } from 'react';

import { IApi } from '../../model';
import { SearchBar } from '../../uiComponents';

import Link from 'next/link';
import lock from '../../uiComponents/icon/lock';
import { computeSearchResults } from '../searchApis/filtersLogic';

interface IProps {
  allApis: IApi[];
}

const DocumentationLeftMenu: React.FC<IProps> = ({ allApis }) => {
  const [searchTerm, setSearchTerm] = useState('');
  const [results, setResults] = useState(allApis);

  useEffect(() => {
    let res = allApis;
    const cleanedSearchTerms = searchTerm.split(' ').filter(t => !!t);

    if (cleanedSearchTerms.length > 0) {
      res = res
        .map(computeSearchResults(cleanedSearchTerms))
        .filter(api => api.score !== 0);
    }

    const newApiList = res.sort((a, b) =>
      (a.visits_2019 || 0) < (b.visits_2019 || 0) ? 1 : -1
    );

    setResults(newApiList);

    return () => {};
  }, [searchTerm, allApis]);

  return (
    <div id="documentation-left-column">
      <div className="search-wrapper layout-center">
        <SearchBar placeholder="Rechercher une API" onSearch={setSearchTerm} />
      </div>
      <div className="documentation-api-list">
        {results.length === 0 ? (
          <div>Aucun résultat n'a été trouvé.</div>
        ) : (
          results.map(api => (
            <Link
              href="/documentation/[slug]"
              as={`/documentation/${api.slug}`}
              key={api.slug}
            >
              <a>
                <div className="api-title">
                  {api.title}{' '}
                  {!api.doc_tech_link && (
                    <span
                      title="Cette API ne propose pas de documentation au format Open API"
                      className="swagger-label"
                    >
                      Pas&nbsp;de&nbsp;swagger
                    </span>
                  )}
                </div>
                {api.is_open === -1 && (
                  <span
                    title="Cette API nécessite une habilitation"
                    className="is-open-label"
                  >
                    {lock}
                  </span>
                )}
              </a>
            </Link>
          ))
        )}
      </div>
    </div>
  );
};

export default DocumentationLeftMenu;
{'fraction_non_alphanumeric': 0.1453353078062196, 'fraction_numerical': 0.006769621324307171, 'mean_word_length': 1.5807860262008733, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 59, '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': '5930141', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1336, 'n_words': 279}