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

fix(front): cosmetics #122

Merged
merged 1 commit into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion front/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Hero = () => (

const ForkRibbon = () => (
<a
class="github-fork-ribbon"
className="github-fork-ribbon"
href="https://github.com/socialgouv/recherche-entreprises"
data-ribbon="Code source"
title="Code source du projet"
Expand Down
66 changes: 38 additions & 28 deletions front/src/Result.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import { Badge, Card } from "react-bootstrap";
import { Map } from "react-feather";
import { Map, ExternalLink } from "react-feather";

type ConventionCollective = { idcc: string; url: string; shortTitle: string };

Expand Down Expand Up @@ -32,39 +32,18 @@ export const Result = ({
}: ApiResult) => {
const otherEtablissements = etablissements > 1;
return (
<Card style={{ margin: "10px 0" }}>
<Card style={{ minHeight: 250 }}>
<Card.Header
style={{ fontSize: "1.5em" }}
dangerouslySetInnerHTML={{ __html: simpleLabel }}
/>
<Card.Body>
<Card.Title dangerouslySetInnerHTML={{ __html: simpleLabel }} />
{simpleLabel !== label && (
<div dangerouslySetInnerHTML={{ __html: highlightLabel }} />
)}
{activitePrincipale && <div>{activitePrincipale}</div>}
<a
title="Ouvrir la fiche sur Annuaire Entreprises"
target="_blank"
rel="noopener noreferrer"
href={`https://annuaire-entreprises.data.gouv.fr/entreprise/${siren}`}
style={{ fontSize: "1.4em" }}
>
<Badge bg="info">SIREN: {siren}</Badge>
</a>
&nbsp;
{matchingEtablissement && (
<a
title="Ouvrir la fiche sur Annuaire Entreprises"
target="_blank"
rel="noopener noreferrer"
style={{ fontSize: "1.4em" }}
href={`https://annuaire-entreprises.data.gouv.fr/etablissement/${matchingEtablissement.siret}`}
>
<Badge bg="info">SIRET : {matchingEtablissement.siret}</Badge>
&nbsp;
</a>
)}
{otherEtablissements &&
`+${etablissements - 1} établissement${
etablissements > 2 ? "s" : ""
}`}
`${etablissements} établissement${etablissements >= 2 ? "s" : ""}`}
<br />
<br />
{matchingEtablissement && (
Expand Down Expand Up @@ -101,6 +80,37 @@ export const Result = ({
)) ||
null}
</Card.Body>
<Card.Footer style={{ textAlign: "right" }}>
<a
title="Ouvrir la fiche sur Annuaire Entreprises"
target="_blank"
rel="noopener noreferrer"
href={`https://annuaire-entreprises.data.gouv.fr/entreprise/${siren}`}
style={{ fontSize: "1.4em" }}
>
<Badge bg="primary">
SIREN: {siren}{" "}
<ExternalLink
size={20}
style={{ verticalAlign: "bottom", marginLeft: 5 }}
/>
</Badge>
</a>
{matchingEtablissement && (
<a
title="Ouvrir la fiche sur Annuaire Entreprises"
target="_blank"
rel="noopener noreferrer"
style={{ fontSize: "1.4em" }}
href={`https://annuaire-entreprises.data.gouv.fr/etablissement/${matchingEtablissement.siret}`}
>
<Badge bg="info">
SIRET : {matchingEtablissement.siret} <ExternalLink />
</Badge>
&nbsp;
</a>
)}
</Card.Footer>
</Card>
);
};
22 changes: 15 additions & 7 deletions front/src/Search.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import useSWR from "swr";
import { Row, Col, Spinner, Form, Alert } from "react-bootstrap";
import { Row, Col, Spinner, Form, Alert, CardGroup } from "react-bootstrap";
import { useDebounce } from "use-debounce";

import { Result } from "./Result";
Expand All @@ -11,13 +11,13 @@ const API_URL =

// make the API call and show results accordingly
// using SWR magic https://swr.vercel.app
const Results = ({ query, address, open, convention, employer }) => {
const Results = ({ query, address, open, convention, employer, ranked }) => {
const { data, error } = useSWR(
`${API_URL}/search?query=${encodeURIComponent(
query
)}&address=${encodeURIComponent(
address
)}&open=${open}&convention=${convention}&employer=${employer}`
)}&open=${open}&convention=${convention}&employer=${employer}&ranked=${ranked}`
);
if (error)
return (
Expand All @@ -36,19 +36,21 @@ const Results = ({ query, address, open, convention, employer }) => {
</div>
);
return (
<div style={{ marginTop: 20 }}>
<Row style={{ marginTop: 20 }} className="g-4">
{(data &&
data.entreprises &&
data.entreprises.length &&
data.entreprises.map((entreprise) => (
<Result key={entreprise.siren} {...entreprise} />
<Col className="col-12 col-md-6 col-xl-4" key={entreprise.siren}>
<Result {...entreprise} />
</Col>
))) || (
<div>
<br />
Aucun résultat avec cette recherche 😢
</div>
)}
</div>
</Row>
);
};

Expand All @@ -62,6 +64,7 @@ export const Search = () => {
open: false,
convention: false,
employer: false,
ranked: false,
});

// const [debouncedQuery] = useDebounce(query, 250);
Expand Down Expand Up @@ -138,12 +141,17 @@ export const Search = () => {
onChange={onCheckBoxChange("employer")}
label="Uniquement les entreprises avec des employés"
/>

<Form.Check
type="checkbox"
id="convention"
onChange={onCheckBoxChange("convention")}
label="Uniquement les entreprises avec une convention collective connue"
/>{" "}
<Form.Check
type="checkbox"
id="ranked"
onChange={onCheckBoxChange("ranked")}
label="Trier par effectif décroissant"
/>
</Col>
</Row>
Expand Down