From 22ed3164cfd97e0c538c4de5bdbd3d1cbf614c69 Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Mon, 18 Mar 2019 12:10:13 +0100 Subject: [PATCH] :bug: corrige le comportement de la recherche d'entreprise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enlève le filtre coté front, on affiche tout les résultats de l'API maintenant --- .../mycompanyinfrance.fr/pages/Company/Find.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/source/sites/mycompanyinfrance.fr/pages/Company/Find.js b/source/sites/mycompanyinfrance.fr/pages/Company/Find.js index 9510f49f5..c9cbc8dff 100644 --- a/source/sites/mycompanyinfrance.fr/pages/Company/Find.js +++ b/source/sites/mycompanyinfrance.fr/pages/Company/Find.js @@ -3,7 +3,7 @@ import { saveExistingCompanyDetails } from 'Actions/existingCompanyActions' import { React, T } from 'Components' import withSitePaths from 'Components/utils/withSitePaths' import { compose } from 'ramda' -import {Helmet} from 'react-helmet' +import { Helmet } from 'react-helmet' import { withTranslation } from 'react-i18next' import { connect } from 'react-redux' import { withRouter } from 'react-router' @@ -11,10 +11,10 @@ import { Link } from 'react-router-dom' import ReactSelect from 'react-select' // $FlowFixMe import 'react-select/dist/react-select.css' -import type { SitePaths } from 'Components/utils/withSitePaths' -import type { TFunction } from 'react-i18next' import './Find.css' import { CompanyDetails as Company } from './YourCompany' +import type { SitePaths } from 'Components/utils/withSitePaths' +import type { TFunction } from 'react-i18next' import type { RouterHistory } from 'react-router' const goToNextStep = (history: RouterHistory, sitePaths: Object) => { @@ -28,7 +28,7 @@ type OwnProps = {} type Props = { history: RouterHistory, t: TFunction, - sitePaths: SitePaths, + sitePaths: SitePaths } class Search extends React.Component { @@ -42,7 +42,9 @@ class Search extends React.Component { fetch(`https://sirene.entreprise.api.gouv.fr/v1/full_text/${input}`) .then(response => { if (response.ok) { - return response.json().then(json => ({ options: json.etablissement })) + return response + .json() + .then(json => console.log(json) || { options: json.etablissement }) } }) .catch(function(error) { @@ -95,6 +97,8 @@ class Search extends React.Component { searchPromptText={null} loadingPlaceholder={t('Recherche en cours...')} loadOptions={this.getOptions} + // We don't filter the API answer, the fulltext is more powerful than blind fuzzy matching + filterOption={() => true} /> {!!this.state.input && ( <>