From 2299943684e14a16957acd2fc90974ceaa6f0b57 Mon Sep 17 00:00:00 2001 From: carolineBda Date: Thu, 20 Jul 2023 16:30:10 +0200 Subject: [PATCH 1/5] fix(company search): when cc unknown --- .../conventions-collectives.spec.ts | 9 ---- .../steps/AgreementSelection.tsx | 51 ++++++++++++++----- .../SearchEnterpriseInput.tsx | 6 +-- 3 files changed, 40 insertions(+), 26 deletions(-) diff --git a/packages/code-du-travail-frontend/cypress/integration/conventions-collectives.spec.ts b/packages/code-du-travail-frontend/cypress/integration/conventions-collectives.spec.ts index 1fa02a9c83..56603324af 100644 --- a/packages/code-du-travail-frontend/cypress/integration/conventions-collectives.spec.ts +++ b/packages/code-du-travail-frontend/cypress/integration/conventions-collectives.spec.ts @@ -23,13 +23,4 @@ describe("Conventions collectives", () => { "/convention-collective/29-hospitalisation-privee-etablissements-prives-dhospitalisation-de-soins-d" ); }); - it("je vois une 404 si l'iddc n'existe pas", () => { - cy.request({ - failOnStatusCode: false, - method: "GET", - url: "/convention-collective/1234", - }).then((response) => { - expect(response.status).to.equal(404); - }); - }); }); diff --git a/packages/code-du-travail-frontend/src/outils/ConventionCollective/steps/AgreementSelection.tsx b/packages/code-du-travail-frontend/src/outils/ConventionCollective/steps/AgreementSelection.tsx index a811b5174a..a2aa38e47f 100644 --- a/packages/code-du-travail-frontend/src/outils/ConventionCollective/steps/AgreementSelection.tsx +++ b/packages/code-du-travail-frontend/src/outils/ConventionCollective/steps/AgreementSelection.tsx @@ -1,4 +1,4 @@ -import { SOURCES } from "@socialgouv/cdtn-utils"; +import { getLabelBySource, SOURCES } from "@socialgouv/cdtn-utils"; import { Button, FlatList, Paragraph, theme } from "@socialgouv/cdtn-ui"; import Link from "next/link"; import React from "react"; @@ -9,6 +9,7 @@ import { ScreenType, useNavContext } from "../common/NavContext"; import { TrackingProps } from "../types"; import { AgreementTile } from "../../common/Agreement/AgreementSearch/AgreementInput/AgreementTile"; import { useRouter } from "next/router"; +import { Tile } from "@socialgouv/cdtn-ui/lib"; type EnterpriseSearchStepProps = { onBackClick: () => void; @@ -32,27 +33,40 @@ const AgreementSelectionStep = ({ return ( <> Convention collective - - {(enterprise?.conventions?.length ?? 0) > 1 - ? `${enterprise?.conventions.length} conventions collectives trouvées pour ` + + {(enterprise.conventions.length ?? 0) > 1 + ? `${enterprise.conventions.length} conventions collectives trouvées pour ` : `${ - enterprise?.conventions.length ?? 0 + enterprise.conventions.length ?? 0 } convention collective trouvée pour `} - « {enterprise?.simpleLabel} - {enterprise?.address && - ` , ${enterprise?.firstMatchingEtablissement?.address}`}{" "} + « {enterprise.simpleLabel} + {enterprise.address && + ` , ${enterprise.firstMatchingEtablissement?.address}`}{" "} » - {enterprise?.conventions.map((agreement) => ( + {enterprise.conventions.map((agreement) => (
  • - + {agreement.slug ? ( + + ) : ( + +

    + Cette convention collective déclarée par l’entreprise n’est + pas reconnue par notre site +

    +
    + )}
  • ))}
    @@ -93,3 +107,12 @@ const Li = styled.li` margin-bottom: ${theme.spacings.large}; } `; + +const DisabledTile = styled(Tile)` + cursor: auto; + color: ${theme.colors.placeholder}; + :hover { + transform: none; + color: ${theme.colors.placeholder}; + } +`; diff --git a/packages/code-du-travail-frontend/src/outils/common/Agreement/EnterpriseSearch/EntrepriseSearchInput/SearchEnterpriseInput.tsx b/packages/code-du-travail-frontend/src/outils/common/Agreement/EnterpriseSearch/EntrepriseSearchInput/SearchEnterpriseInput.tsx index 6356a8de0d..2cc80633c5 100644 --- a/packages/code-du-travail-frontend/src/outils/common/Agreement/EnterpriseSearch/EntrepriseSearchInput/SearchEnterpriseInput.tsx +++ b/packages/code-du-travail-frontend/src/outils/common/Agreement/EnterpriseSearch/EntrepriseSearchInput/SearchEnterpriseInput.tsx @@ -46,8 +46,8 @@ export const SearchEnterpriseInput = ({ searchParams.query, searchParams.address ); - const [query, setQuery] = useState(""); - const [address, setAddress] = useState(""); + const [query, setQuery] = useState(searchParams.query); + const [address, setAddress] = useState(searchParams.address); const searchInputHandler = () => { onSearchParamsChange({ ...searchParams, query: query, address: address }); }; @@ -57,7 +57,7 @@ export const SearchEnterpriseInput = ({ - Nom de votre entreprise ou numéro Siret + Nom de votre entreprise ou numéro Siret OO Date: Thu, 20 Jul 2023 20:32:49 +0200 Subject: [PATCH 2/5] revert --- .../EntrepriseSearchInput/SearchEnterpriseInput.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/code-du-travail-frontend/src/outils/common/Agreement/EnterpriseSearch/EntrepriseSearchInput/SearchEnterpriseInput.tsx b/packages/code-du-travail-frontend/src/outils/common/Agreement/EnterpriseSearch/EntrepriseSearchInput/SearchEnterpriseInput.tsx index 2cc80633c5..6b9b20bd67 100644 --- a/packages/code-du-travail-frontend/src/outils/common/Agreement/EnterpriseSearch/EntrepriseSearchInput/SearchEnterpriseInput.tsx +++ b/packages/code-du-travail-frontend/src/outils/common/Agreement/EnterpriseSearch/EntrepriseSearchInput/SearchEnterpriseInput.tsx @@ -57,7 +57,7 @@ export const SearchEnterpriseInput = ({ - Nom de votre entreprise ou numéro Siret OO + Nom de votre entreprise ou numéro Siret Date: Mon, 24 Jul 2023 16:00:37 +0200 Subject: [PATCH 3/5] default shortTitle --- .../src/api/__tests__/enterprise.test.ts | 12 +++++++----- .../src/api/modules/enterprises/service.ts | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/code-du-travail-frontend/src/api/__tests__/enterprise.test.ts b/packages/code-du-travail-frontend/src/api/__tests__/enterprise.test.ts index 4eb958ef58..dd0ebdbd23 100644 --- a/packages/code-du-travail-frontend/src/api/__tests__/enterprise.test.ts +++ b/packages/code-du-travail-frontend/src/api/__tests__/enterprise.test.ts @@ -203,11 +203,13 @@ describe("Test enterprise endpoint", () => { "1090-services-de-lautomobile-commerce-et-reparation-de-lautomobile-du-cycle" ); - expect( - response.body.entreprises[0].conventions.find( - (agreement) => agreement.num === 99999 - ).slug - ).toBeUndefined(); + const agreementNoSlug = response.body.entreprises[0].conventions.find( + (agreement) => agreement.num === 99999 + ); + expect(agreementNoSlug.slug).toBeUndefined(); + expect(agreementNoSlug.shortTitle).toEqual( + "Convention collective non reconnue" + ); }); test("Call retrieving agreement not in elastic from an enterprise", async () => { diff --git a/packages/code-du-travail-frontend/src/api/modules/enterprises/service.ts b/packages/code-du-travail-frontend/src/api/modules/enterprises/service.ts index 02e8594c75..cfed6e786d 100644 --- a/packages/code-du-travail-frontend/src/api/modules/enterprises/service.ts +++ b/packages/code-du-travail-frontend/src/api/modules/enterprises/service.ts @@ -7,7 +7,7 @@ import { IDCC_TO_REPLACE } from "../../config"; const toAgreement = (convention: Convention): Agreement => ({ id: convention.id, num: convention.idcc, - shortTitle: convention.shortTitle, + shortTitle: convention.shortTitle ?? "Convention collective non reconnue", title: convention.title, ...(convention.url ? { url: convention.url } : {}), }); From 7f3e36acf718c61eea3ee91f1e97771ecac5fa36 Mon Sep 17 00:00:00 2001 From: carolineBda Date: Mon, 24 Jul 2023 16:30:40 +0200 Subject: [PATCH 4/5] fix test --- .../src/api/__tests__/enterprise.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/code-du-travail-frontend/src/api/__tests__/enterprise.test.ts b/packages/code-du-travail-frontend/src/api/__tests__/enterprise.test.ts index dd0ebdbd23..27803c4305 100644 --- a/packages/code-du-travail-frontend/src/api/__tests__/enterprise.test.ts +++ b/packages/code-du-travail-frontend/src/api/__tests__/enterprise.test.ts @@ -234,6 +234,7 @@ describe("Test enterprise endpoint", () => { conventions: [ { num: 123456, + shortTitle: "Convention collective non reconnue", }, ], }, From 2da69ddb8552ed0198847e0cfab61e1fec89ce6e Mon Sep 17 00:00:00 2001 From: carolineBda Date: Mon, 24 Jul 2023 16:39:38 +0200 Subject: [PATCH 5/5] update id --- .../src/api/__tests__/enterprise.test.ts | 1 + .../src/api/modules/enterprises/service.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/code-du-travail-frontend/src/api/__tests__/enterprise.test.ts b/packages/code-du-travail-frontend/src/api/__tests__/enterprise.test.ts index 27803c4305..c3fbc3f564 100644 --- a/packages/code-du-travail-frontend/src/api/__tests__/enterprise.test.ts +++ b/packages/code-du-travail-frontend/src/api/__tests__/enterprise.test.ts @@ -235,6 +235,7 @@ describe("Test enterprise endpoint", () => { { num: 123456, shortTitle: "Convention collective non reconnue", + id: 123456, }, ], }, diff --git a/packages/code-du-travail-frontend/src/api/modules/enterprises/service.ts b/packages/code-du-travail-frontend/src/api/modules/enterprises/service.ts index cfed6e786d..5a2e79a6d8 100644 --- a/packages/code-du-travail-frontend/src/api/modules/enterprises/service.ts +++ b/packages/code-du-travail-frontend/src/api/modules/enterprises/service.ts @@ -5,7 +5,7 @@ import { EnterpriseApiResponse, ApiEnterpriseData, Convention } from "./types"; import { IDCC_TO_REPLACE } from "../../config"; const toAgreement = (convention: Convention): Agreement => ({ - id: convention.id, + id: convention.id ?? convention.idcc, num: convention.idcc, shortTitle: convention.shortTitle ?? "Convention collective non reconnue", title: convention.title,