🐛 Filtre les SIREN non diffusibles
parent
3c82147f49
commit
7c5de02d2d
|
@ -85,17 +85,22 @@ const fetchCommuneDetails = async function (codeCommune: string) {
|
|||
export const useSetEntreprise = () => {
|
||||
const dispatch = useDispatch()
|
||||
return async (siren: string) => {
|
||||
dispatch(setSiren(siren))
|
||||
const companyDetails = await fetchCompanyDetails(siren)
|
||||
if (companyDetails === null) {
|
||||
return
|
||||
}
|
||||
dispatch(setSiren(siren))
|
||||
dispatch(
|
||||
setCompanyDetails(
|
||||
companyDetails.categorie_juridique,
|
||||
companyDetails.date_creation
|
||||
)
|
||||
)
|
||||
const communeDetails: ApiCommuneJson = await fetchCommuneDetails(
|
||||
companyDetails.etablissement_siege.code_commune
|
||||
)
|
||||
dispatch(addCommuneDetails(communeDetails))
|
||||
if (companyDetails.etablissement_siege) {
|
||||
const communeDetails: ApiCommuneJson = await fetchCommuneDetails(
|
||||
companyDetails.etablissement_siege.code_commune
|
||||
)
|
||||
dispatch(addCommuneDetails(communeDetails))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,13 @@ const isSIREN = (input: string) => /^[\s]*([\d][\s]*){9}$/.exec(input)
|
|||
const isSIRET = (input: string) => /^[\s]*([\d][\s]*){14}$/.exec(input)
|
||||
|
||||
export async function fetchCompanyDetails(siren: string) {
|
||||
// Le paramètre `statut_diffusion` filtre les SIREN non diffusibles, cf.
|
||||
// https://github.com/betagouv/mon-entreprise/issues/1399#issuecomment-770736525
|
||||
const response = await fetch(
|
||||
`https://entreprise.data.gouv.fr/api/sirene/v3/unites_legales/${siren.replace(
|
||||
/[\s]/g,
|
||||
''
|
||||
)}`
|
||||
)}?statut_diffusion=O`
|
||||
)
|
||||
if (!response.ok) {
|
||||
return null
|
||||
|
|
|
@ -30,6 +30,15 @@ export default function CompanyDetails({ siren, denomination }: Etablissement) {
|
|||
fetchCompanyDetails(siren).then(setCompany)
|
||||
}, [siren])
|
||||
|
||||
if (company === null) {
|
||||
return (
|
||||
<p className="ui__ notice">
|
||||
{siren}
|
||||
<Trans>est un SIREN non diffusable</Trans>
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<h3>
|
||||
|
|
|
@ -261,7 +261,7 @@ export function RadioLabelContent({
|
|||
/>
|
||||
<span>
|
||||
{icônes && <>{emoji(icônes)} </>}
|
||||
<Trans>{label}</Trans>
|
||||
{label}
|
||||
</span>
|
||||
</label>
|
||||
)
|
||||
|
|
|
@ -655,6 +655,7 @@ entreprise:
|
|||
titre: Write the company's articles
|
||||
titre: The to-do list for creating your business
|
||||
titre2: Recommended before starting your activity
|
||||
est un SIREN non diffusable: is a non-distributable SIREN
|
||||
examples: Examples
|
||||
expected: the expected result was
|
||||
facteur: multiplier
|
||||
|
|
Loading…
Reference in New Issue