Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced search #120

Merged
merged 14 commits into from
Jun 8, 2022
1 change: 0 additions & 1 deletion clients/ping-api-clients.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { verifyIdRna } from '../utils/helpers/id-rna';
import { verifySiren } from '../utils/helpers/siren-and-siret';
import { HttpServerError } from './exceptions';
import { fetchAssociation } from './rna';
import { fetchRNCSImmatriculation } from './rncs';
import { fetchRnmImmatriculation } from './rnm';
Expand Down
12 changes: 8 additions & 4 deletions clients/sirene-ouverte/recherche.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { IEtablissement } from '../../models';
import constants from '../../models/constants';
import { ISearchResults } from '../../models/search';
import constants from '../../models/constants';
import {
formatAdresse,
parseIntWithDefaultValue,
Expand All @@ -9,6 +8,7 @@ import { libelleFromCodeNaf } from '../../utils/labels';
import { httpGet } from '../../utils/network';
import { HttpNotFound } from '../exceptions';
import routes from '../routes';
import SearchFilterParams from '../../models/search-filter-params';

interface ISireneOuverteUniteLegaleResultat {
siren: string;
Expand Down Expand Up @@ -57,15 +57,19 @@ export interface ISireneOuverteSearchResults {
*/
const getResults = async (
searchTerms: string,
page: number
page: number,
searchFilterParams?: SearchFilterParams
): Promise<ISearchResults> => {
const encodedTerms = encodeURI(searchTerms);

const route =
process.env.ALTERNATIVE_SEARCH_ROUTE ||
routes.sireneOuverte.rechercheUniteLegale;

const url = `${route}?per_page=10&page=${page}&q=${encodedTerms}`;
let url = `${route}?per_page=10&page=${page}&q=${encodedTerms}${
searchFilterParams?.toURI() || ''
}`;

const response = await httpGet(url, { timeout: constants.timeout.long });

const results = (response.data || []) as any;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IUniteLegale } from '../../models';
import { INSEE, MI } from '../administrations';
import { INSEE, MI } from '../../components/administrations';
import Warning from './warning';

const AssociationAdressAlert: React.FC<{ uniteLegale: IUniteLegale }> = ({
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { INPI } from '../administrations';
import { INPI } from '../../components/administrations';
import Warning from './warning';

const InpiPartiallyDownWarning: React.FC<{ missing?: string }> = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IUniteLegale } from '../../models';
import { formatIntFr } from '../../utils/helpers/formatting';
import { INSEE } from '../administrations';
import { INSEE } from '../../components/administrations';
import Warning from './warning';

const MultipleSirenAlert: React.FC<{ uniteLegale: IUniteLegale }> = ({
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions components-ui/select/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';

const Select: React.FC<{
placeholder?: string;
label?: string;
name?: string;
options: { value: string; label: string }[];
defaultValue?: string;
}> = ({
label,
options,
placeholder = 'Selectionnez une option',
name = '',
defaultValue = null,
}) => (
<div className="fr-select-group">
{label && (
<label className="fr-label" htmlFor="select">
{label}
</label>
)}
<select
name={name}
className="fr-select"
id="select"
defaultValue={defaultValue || ''}
>
<option value="">{placeholder}</option>
{options.map((option) => (
<option key={option.value} value={option.value}>
{option.label}
</option>
))}
</select>
</div>
);

export default Select;
24 changes: 24 additions & 0 deletions components-ui/select/select-section-naf.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import Select from '.';
import { codesSectionNaf } from '../../utils/labels/codes-section-NAF';

const SelectCodeSectionNaf: React.FC<{
placeholder?: string;
label?: string;
name?: string;
maxWidth?: number;
defaultValue?: string;
}> = ({ label, placeholder, name, defaultValue = undefined }) => (
<Select
label={label}
name={name}
defaultValue={defaultValue}
placeholder={placeholder}
options={Object.keys(codesSectionNaf).map((k) => {
//@ts-ignore
return { value: k, label: codesSectionNaf[k] };
})}
/>
);

export default SelectCodeSectionNaf;
File renamed without changes.
2 changes: 1 addition & 1 deletion components/administration-api-monitoring/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { IMonitoring, IRatio } from '../../models/monitoring';
import InformationTooltip from '../information-tooltip';
import InformationTooltip from '../../components-ui/information-tooltip';
import { Section } from '../section';

const getUptimeColor = (ratio: IRatio) => {
Expand Down
2 changes: 1 addition & 1 deletion components/administration-not-responding/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { administrationsMetaData } from '../../models/administration';
import { IAPINotRespondingError } from '../../models/api-not-responding';
import ButtonLink from '../button';
import ButtonLink from '../../components-ui/button';
import { Section } from '../section';

interface IProps extends IAPINotRespondingError {
Expand Down
6 changes: 3 additions & 3 deletions components/annonces-section/bodacc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import {
isAPINotResponding,
} from '../../models/api-not-responding';
import { IAnnoncesBodacc } from '../../models/annonces';
import { Tag } from '../tag';
import ButtonLink from '../button';
import { Tag } from '../../components-ui/tag';
import ButtonLink from '../../components-ui/button';
import { DILA } from '../administrations';
import routes from '../../clients/routes';
import { IUniteLegale } from '../../models';
import { formatDate } from '../../utils/helpers/formatting';
import Info from '../alerts/info';
import Info from '../../components-ui/alerts/info';

const AnnoncesBodaccSection: React.FC<{
uniteLegale: IUniteLegale;
Expand Down
6 changes: 3 additions & 3 deletions components/annonces-section/jo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import {
isAPINotResponding,
} from '../../models/api-not-responding';
import { IAnnoncesJO } from '../../models/annonces';
import { Tag } from '../tag';
import ButtonLink from '../button';
import { Tag } from '../../components-ui/tag';
import ButtonLink from '../../components-ui/button';
import { DILA } from '../administrations';
import routes from '../../clients/routes';
import { IUniteLegale } from '../../models';
import { formatDate } from '../../utils/helpers/formatting';
import AssociationCreationNotFoundAlert from '../alerts/association-creation-not-found-alert';
import AssociationCreationNotFoundAlert from '../../components-ui/alerts/association-creation-not-found-alert';

const AnnoncesJOSection: React.FC<{
uniteLegale: IUniteLegale;
Expand Down
6 changes: 3 additions & 3 deletions components/association-section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { IUniteLegale } from '../../models';
import { EAdministration } from '../../models/administration';
import { isTwoMonthOld } from '../../utils/helpers/checks';
import { formatIntFr } from '../../utils/helpers/formatting';
import Warning from '../alerts/warning';
import BreakPageForPrint from '../print-break-page';
import HorizontalSeparator from '../horizontal-separator';
import Warning from '../../components-ui/alerts/warning';
import BreakPageForPrint from '../../components-ui/print-break-page';
import HorizontalSeparator from '../../components-ui/horizontal-separator';
import { Section } from '../section';
import { TwoColumnTable } from '../table/simple';

Expand Down
2 changes: 1 addition & 1 deletion components/banner/entreprise-data.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { PrintNever } from '../print-visibility';
import { PrintNever } from '../../components-ui/print-visibility';

export const MigrationBanner: React.FC<{}> = () => (
<PrintNever>
Expand Down
2 changes: 1 addition & 1 deletion components/banner/nps.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { PrintNever } from '../print-visibility';
import { PrintNever } from '../../components-ui/print-visibility';

export const NPSBanner: React.FC<{}> = () => (
<PrintNever>
Expand Down
4 changes: 2 additions & 2 deletions components/button-inpi-pdf/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import randomId from '../../utils/helpers/randomId';
import ButtonLink from '../button';
import { download } from '../icon';
import ButtonLink from '../../components-ui/button';
import { download } from '../../components-ui/icon';

/**
* Render both a static version of the component and a Alpine component that clean static if it succesfully mount
Expand Down
4 changes: 2 additions & 2 deletions components/convention-collectives-section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';

import { FullTable } from '../table/full';
import { EAdministration } from '../../models/administration';
import { Tag } from '../tag';
import { Tag } from '../../components-ui/tag';
import { Section } from '../section';
import ButtonLink from '../button';
import ButtonLink from '../../components-ui/button';
import { IConventionCollective } from '../../models/convention-collective';
import AdministrationNotResponding from '../administration-not-responding';
import {
Expand Down
4 changes: 2 additions & 2 deletions components/dirigeants-section/beneficiaires.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import HorizontalSeparator from '../horizontal-separator';
import HorizontalSeparator from '../../components-ui/horizontal-separator';
import { Section } from '../section';
import { TwoColumnTable } from '../table/simple';
import { EAdministration } from '../../models/administration';
Expand All @@ -16,7 +16,7 @@ import {
IBeneficiaire,
IImmatriculationRNCS,
} from '../../models/immatriculation/rncs';
import InpiPartiallyDownWarning from '../alerts/inpi-partially-down';
import InpiPartiallyDownWarning from '../../components-ui/alerts/inpi-partially-down';

interface IProps {
immatriculationRNCS: IImmatriculationRNCS | IAPINotRespondingError;
Expand Down
2 changes: 1 addition & 1 deletion components/dirigeants-section/insee-dirigeant.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import HorizontalSeparator from '../horizontal-separator';
import HorizontalSeparator from '../../components-ui/horizontal-separator';
import { Section } from '../section';
import { TwoColumnTable } from '../table/simple';
import { EAdministration } from '../../models/administration';
Expand Down
2 changes: 1 addition & 1 deletion components/dirigeants-section/rncs-dirigeants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
IImmatriculationRNCS,
IPersonneMorale,
} from '../../models/immatriculation/rncs';
import InpiPartiallyDownWarning from '../alerts/inpi-partially-down';
import InpiPartiallyDownWarning from '../../components-ui/alerts/inpi-partially-down';

/**
* Weird bug happennig here. Webpack build fail when this function is in model/dirigeants.ts
Expand Down
2 changes: 1 addition & 1 deletion components/download-manager/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PrintNever } from '../print-visibility';
import { PrintNever } from '../../components-ui/print-visibility';

const DownloadManager = () => (
<PrintNever>
Expand Down
2 changes: 1 addition & 1 deletion components/error-explanations/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PropsWithChildren } from 'react';
import constants from '../../models/constants';
import ButtonLink from '../button';
import ButtonLink from '../../components-ui/button';

const ErrorTemplate: React.FC<PropsWithChildren<{}>> = ({ children }) => (
<div className="content-container text-wrapper">
Expand Down
4 changes: 2 additions & 2 deletions components/etablissement-liste-section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import constants from '../../models/constants';
import { IEtablissement, IUniteLegale } from '../../models';
import { EAdministration } from '../../models/administration';
import { formatSiret } from '../../utils/helpers/siren-and-siret';
import IsActiveTag from '../is-active-tag';
import IsActiveTag from '../../components-ui/is-active-tag';
import PageCounter from '../results-page-counter';
import { Section } from '../section';
import { FullTable } from '../table/full';
import { Tag } from '../tag';
import { Tag } from '../../components-ui/tag';

const EtablissementListeSection: React.FC<{
uniteLegale: IUniteLegale;
Expand Down
10 changes: 5 additions & 5 deletions components/etablissement-section/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React from 'react';
import { IEtablissement, IUniteLegale } from '../../models';
import { map, pin } from '../icon';
import { map, pin } from '../../components-ui/icon';
import { formatDate, formatIntFr } from '../../utils/helpers/formatting';
import ButtonLink from '../button';
import HorizontalSeparator from '../horizontal-separator';
import ButtonLink from '../../components-ui/button';
import HorizontalSeparator from '../../components-ui/horizontal-separator';
import { Section } from '../section';
import { TwoColumnTable } from '../table/simple';
import { formatSiret } from '../../utils/helpers/siren-and-siret';
import { EAdministration } from '../../models/administration';
import AvisSituationLink from '../avis-situation-link';
import { EtablissementDescription } from '../etablissement-description';
import BreakPageForPrint from '../print-break-page';
import { PrintNever } from '../print-visibility';
import BreakPageForPrint from '../../components-ui/print-break-page';
import { PrintNever } from '../../components-ui/print-visibility';

interface IProps {
etablissement: IEtablissement;
Expand Down
Loading