Affine les types (et répare les checks)
parent
626c4a07da
commit
df768a3cff
|
@ -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<Array<{
|
||||
export type Entreprise = {
|
||||
siren: string
|
||||
address?: string
|
||||
denomination?: string
|
||||
}> | null> {
|
||||
}
|
||||
|
||||
async function searchFullText(text: string): Promise<Array<Entreprise> | null> {
|
||||
const response = await fetch(makeSearchUrl(text))
|
||||
|
||||
if (!response.ok) {
|
||||
|
|
|
@ -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<Etablissement>] {
|
||||
const [result, setResult] = useState<Array<Etablissement>>([])
|
||||
const [searchPending, setSearchPending] = useState(!!value)
|
||||
): [boolean, Array<Entreprise>] {
|
||||
const [result, setResult] = useState<Array<Entreprise>>([])
|
||||
const [searchPending, setSearchPending] = useState(Boolean(value))
|
||||
const debouncedValue = useDebounce(value, 300)
|
||||
|
||||
useEffect(() => {
|
||||
setSearchPending(!!value)
|
||||
setSearchPending(Boolean(value))
|
||||
|
||||
if (!value) {
|
||||
setResult([])
|
||||
|
|
Loading…
Reference in New Issue