Skip to content

Commit f0b5916

Browse files
feat(my-space): update company info banner to match new design (#3168)
1 parent ea2374d commit f0b5916

4 files changed

Lines changed: 84 additions & 40 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
11
.banner {
22
background-color: var(--background-alt-blue-france);
33
}
4+
5+
.infoRow {
6+
display: flex;
7+
flex-wrap: wrap;
8+
gap: 0.5rem 1.5rem;
9+
align-items: center;
10+
}
11+
12+
.datapoint {
13+
display: inline-flex;
14+
align-items: center;
15+
gap: 0.25rem;
16+
margin: 0;
17+
}

packages/app/src/modules/my-space/CompanyInfoBanner.tsx

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Breadcrumb } from "~/modules/layout";
33

44
import { MODAL_ID as COMPANY_EDIT_MODAL_ID } from "./CompanyEditModal";
55
import styles from "./CompanyInfoBanner.module.scss";
6+
import { formatAddress } from "./formatAddress";
67
import { formatSiren } from "./formatSiren";
78
import { StatusBadge } from "./StatusBadge";
89
import type { CompanyDetail } from "./types";
@@ -15,7 +16,7 @@ export function CompanyInfoBanner({ company }: Props) {
1516
const currentYear = getCurrentYear();
1617

1718
return (
18-
<div className={`fr-py-4w ${styles.banner}`}>
19+
<div className={`fr-pt-3w fr-pb-4w ${styles.banner}`}>
1920
<div className="fr-container">
2021
<Breadcrumb
2122
items={[
@@ -24,59 +25,54 @@ export function CompanyInfoBanner({ company }: Props) {
2425
]}
2526
/>
2627

27-
<div className="fr-mt-3w">
28+
<div className="fr-mt-4w">
2829
<div className="fr-grid-row fr-grid-row--middle fr-mb-1w">
2930
<div className="fr-col">
30-
<h2 className="fr-mb-0">{company.name}</h2>
31+
<h2 className="fr-h4 fr-mb-0">{company.name}</h2>
3132
</div>
3233
<div className="fr-col-auto">
3334
<button
3435
aria-controls={COMPANY_EDIT_MODAL_ID}
35-
className="fr-btn fr-btn--tertiary-no-outline fr-btn--sm fr-icon-edit-line fr-btn--icon-left"
36+
className="fr-btn fr-btn--tertiary-no-outline fr-icon-edit-line fr-btn--icon-left"
3637
data-fr-opened="false"
3738
type="button"
3839
>
39-
Modifier les informations
40+
Modifier
4041
</button>
4142
</div>
4243
</div>
4344

44-
<p className="fr-text--bold fr-mb-1w">{formatSiren(company.siren)}</p>
45-
46-
{company.address && (
47-
<p className="fr-text--bold fr-mb-1w">{company.address}</p>
48-
)}
45+
<div className={`${styles.infoRow} fr-mb-1w`}>
46+
<p className={styles.datapoint}>
47+
SIREN : <strong>{formatSiren(company.siren)}</strong>
48+
</p>
49+
{company.address && (
50+
<p className={styles.datapoint}>
51+
Adresse : <strong>{formatAddress(company.address)}</strong>
52+
</p>
53+
)}
54+
</div>
4955

50-
<div className="fr-grid-row fr-grid-row--gutters fr-mt-1w">
56+
<div className={styles.infoRow}>
5157
{company.nafCode && (
52-
<div className="fr-col-auto">
53-
<p className="fr-mb-0">
54-
Code NAF : <strong>{company.nafCode}</strong>
55-
</p>
56-
</div>
58+
<p className={styles.datapoint}>
59+
Code NAF : <strong>{company.nafCode}</strong>
60+
</p>
5761
)}
5862
{company.workforce !== null && (
59-
<div className="fr-col-auto">
60-
<p className="fr-mb-0">
61-
Effectif annuel moyen en {currentYear} :{" "}
62-
<strong>{company.workforce}</strong>
63-
</p>
64-
</div>
65-
)}
66-
<div className="fr-col-auto">
67-
<p className="fr-mb-0 fr-flex fr-flex--align-center">
68-
Existence d'un CSE :{" "}
69-
{company.hasCse !== null ? (
70-
<strong className="fr-ml-1v">
71-
{company.hasCse ? "Oui" : "Non"}
72-
</strong>
73-
) : (
74-
<span className="fr-ml-1v">
75-
<StatusBadge status="to_complete" />
76-
</span>
77-
)}
63+
<p className={styles.datapoint}>
64+
Effectif annuel moyen en {currentYear} :{" "}
65+
<strong>{company.workforce}</strong>
7866
</p>
79-
</div>
67+
)}
68+
<p className={styles.datapoint}>
69+
Existence d'un CSE :{" "}
70+
{company.hasCse !== null ? (
71+
<strong>{company.hasCse ? "Oui" : "Non"}</strong>
72+
) : (
73+
<StatusBadge status="to_complete" />
74+
)}
75+
</p>
8076
</div>
8177
</div>
8278
</div>

packages/app/src/modules/my-space/__tests__/CompanyInfoBanner.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ describe("CompanyInfoBanner", () => {
3636
it("renders the address when provided", () => {
3737
render(
3838
<CompanyInfoBanner
39-
company={{ ...baseCompany, address: "12 rue de Paris, 75001 Paris" }}
39+
company={{ ...baseCompany, address: "12 RUE DE PARIS, 75001 PARIS" }}
4040
/>,
4141
);
4242
expect(
43-
screen.getByText("12 rue de Paris, 75001 Paris"),
43+
screen.getByText("12 Rue de Paris, 75001 Paris"),
4444
).toBeInTheDocument();
4545
});
4646

@@ -86,10 +86,10 @@ describe("CompanyInfoBanner", () => {
8686
expect(screen.queryByText(/Effectif annuel moyen/)).not.toBeInTheDocument();
8787
});
8888

89-
it("renders the 'Modifier les informations' button", () => {
89+
it("renders the 'Modifier' button", () => {
9090
render(<CompanyInfoBanner company={baseCompany} />);
9191
expect(
92-
screen.getByRole("button", { name: "Modifier les informations" }),
92+
screen.getByRole("button", { name: "Modifier" }),
9393
).toBeInTheDocument();
9494
});
9595
});
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Addresses from INSEE/Weez come fully uppercased. Render them in title case
2+
// while keeping digits and short connector words (de, du, la, le, les…) lowercase.
3+
const LOWERCASE_WORDS = new Set([
4+
"de",
5+
"du",
6+
"des",
7+
"la",
8+
"le",
9+
"les",
10+
"et",
11+
"en",
12+
"aux",
13+
"sur",
14+
"sous",
15+
"d",
16+
"l",
17+
]);
18+
19+
/**
20+
* Converts a fully-uppercased INSEE/Weez address to title case.
21+
* Short French connector words (de, du, la, le, …) are kept lowercase
22+
* unless they appear as the first word of the address.
23+
*
24+
* @param address - The raw uppercase address string.
25+
* @returns The address formatted in title case.
26+
*/
27+
export function formatAddress(address: string): string {
28+
return address
29+
.toLocaleLowerCase("fr-FR")
30+
.replace(/\p{L}+/gu, (word, offset: number) => {
31+
if (offset > 0 && LOWERCASE_WORDS.has(word)) return word;
32+
return word[0]!.toLocaleUpperCase("fr-FR") + word.slice(1);
33+
});
34+
}

0 commit comments

Comments
 (0)