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/api/__tests__/enterprise.test.ts b/packages/code-du-travail-frontend/src/api/__tests__/enterprise.test.ts index 4eb958ef58..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 @@ -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 () => { @@ -232,6 +234,8 @@ describe("Test enterprise endpoint", () => { conventions: [ { 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 02e8594c75..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,9 +5,9 @@ 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, + shortTitle: convention.shortTitle ?? "Convention collective non reconnue", title: convention.title, ...(convention.url ? { url: convention.url } : {}), }); 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..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 @@ -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 }); };