From df768a3cffc5d029d98c2833ac3270322b2b6a17 Mon Sep 17 00:00:00 2001 From: Alexandre Valsamou-Stanislawski Date: Wed, 8 Dec 2021 17:01:05 +0100 Subject: [PATCH] =?UTF-8?q?Affine=20les=20types=20(et=20r=C3=A9pare=20les?= =?UTF-8?q?=20checks)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/source/api/fabrique-social.ts | 6 ++++-- site/source/hooks/useSearchCompany.ts | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/site/source/api/fabrique-social.ts b/site/source/api/fabrique-social.ts index 568183b65..8041573be 100644 --- a/site/source/api/fabrique-social.ts +++ b/site/source/api/fabrique-social.ts @@ -52,11 +52,13 @@ type FabriqueSocialSearchPayload = { const makeSearchUrl = (query: string) => `https://search-recherche-entreprises.fabrique.social.gouv.fr/api/v1/search?query=${query}&open=false&convention=false&employer=false&ranked=false&limit=10` -async function searchFullText(text: string): Promise | null> { +} + +async function searchFullText(text: string): Promise | null> { const response = await fetch(makeSearchUrl(text)) if (!response.ok) { diff --git a/site/source/hooks/useSearchCompany.ts b/site/source/hooks/useSearchCompany.ts index bc9161562..d0767bd13 100644 --- a/site/source/hooks/useSearchCompany.ts +++ b/site/source/hooks/useSearchCompany.ts @@ -1,16 +1,16 @@ -import { Etablissement, searchDenominationOrSiren } from 'API/fabrique-social' +import { Entreprise, searchDenominationOrSiren } from 'API/fabrique-social' import { useEffect, useState } from 'react' import { useDebounce } from './useDebounce' export default function useSearchCompany( value: string -): [boolean, Array] { - const [result, setResult] = useState>([]) - const [searchPending, setSearchPending] = useState(!!value) +): [boolean, Array] { + const [result, setResult] = useState>([]) + const [searchPending, setSearchPending] = useState(Boolean(value)) const debouncedValue = useDebounce(value, 300) useEffect(() => { - setSearchPending(!!value) + setSearchPending(Boolean(value)) if (!value) { setResult([])