diff --git a/packages/code-du-travail-frontend/src/api/modules/agreements/service.ts b/packages/code-du-travail-frontend/src/api/modules/agreements/service.ts index b5bb9d18c8..c879e3e25b 100644 --- a/packages/code-du-travail-frontend/src/api/modules/agreements/service.ts +++ b/packages/code-du-travail-frontend/src/api/modules/agreements/service.ts @@ -79,10 +79,10 @@ const orderByAlphaAndMetalurgieLast = (a, b) => { if (!a.url && b.url) { return 1; } - if (a.title < b.title) { + if (a.shortTitle < b.shortTitle) { return -1; } - if (a.title > b.title) { + if (a.shortTitle > b.shortTitle) { return 1; } diff --git a/packages/code-du-travail-frontend/src/contributions/Contribution.tsx b/packages/code-du-travail-frontend/src/contributions/Contribution.tsx index a61718b608..9248e5f6b4 100644 --- a/packages/code-du-travail-frontend/src/contributions/Contribution.tsx +++ b/packages/code-du-travail-frontend/src/contributions/Contribution.tsx @@ -16,6 +16,7 @@ import { } from "@socialgouv/cdtn-ui"; import React from "react"; import styled from "styled-components"; +import { useRouter } from "next/router"; import Mdx from "../../src/common/Mdx"; import SearchConvention from "../../src/conventions/Search"; @@ -31,6 +32,7 @@ const Contribution = ({ answers, content }) => { * only one a single ccn answer * this allows us to set conventional answer directly for a given ccn */ + const router = useRouter(); const isConventionalAnswer = Object.prototype.hasOwnProperty.call( answers, "conventionAnswer" @@ -45,6 +47,10 @@ const Contribution = ({ answers, content }) => { const isConventionDetected = () => convention && convention.id && convention.num && convention.title; + const openNewContributionPage = async () => { + router.push(`/contribution/${convention.num}-${router.query.slug}`); + }; + let conventionAnswer; if (isConventionalAnswer) { conventionAnswer = answers.conventionAnswer; @@ -201,18 +207,34 @@ const Contribution = ({ answers, content }) => {

- ) : ( + ) : convention.num !== 3248 || + (convention.num === 3248 && + router.query.slug === + "quest-ce-quune-rupture-conventionnelle") ? (
Désolé, nous n’avons pas de réponse pour cette convention collective.
+ ) : ( + <> )} {!isConventionalAnswer && ( - + {convention.num === 3248 && + router.query.slug !== + "quest-ce-quune-rupture-conventionnelle" ? ( + + ) : ( + + )} )} diff --git a/packages/code-du-travail-frontend/src/outils/common/Agreement/AgreementSearch/AgreementInput/SearchAgreementInput.tsx b/packages/code-du-travail-frontend/src/outils/common/Agreement/AgreementSearch/AgreementInput/SearchAgreementInput.tsx index 853dd9504b..0410a3fc79 100644 --- a/packages/code-du-travail-frontend/src/outils/common/Agreement/AgreementSearch/AgreementInput/SearchAgreementInput.tsx +++ b/packages/code-du-travail-frontend/src/outils/common/Agreement/AgreementSearch/AgreementInput/SearchAgreementInput.tsx @@ -1,4 +1,4 @@ -import { Input, Label, Text, theme } from "@socialgouv/cdtn-ui"; +import { Input, Label, Text, theme, Paragraph } from "@socialgouv/cdtn-ui"; import React, { useState } from "react"; import styled from "styled-components"; import Autosuggest from "react-autosuggest"; @@ -82,7 +82,6 @@ export const SearchAgreementInput = ({ l’entreprise (Ex : 4752A).

- suggestion} + getSuggestionValue={(suggestion) => suggestion as any} renderSuggestion={renderSuggestion} renderSuggestionsContainer={renderSuggestionsContainer} renderInputComponent={renderInputComponent} @@ -115,14 +114,27 @@ const SuggestionsContainer = styled.div` } `; -const renderSuggestion = (suggestion) => ( -
- {suggestion.shortTitle} (IDCC {formatIdcc(suggestion.num)}) -
-); +const renderSuggestion = (suggestion: Agreement) => { + return ( + + {suggestion.shortTitle} (IDCC {formatIdcc(suggestion.num)}) + + {suggestion.highlight?.searchInfo && + `(${suggestion.highlight?.searchInfo})`} + + + ); +}; + const IDCC = styled.span` font-weight: normal; `; + +const SuggestionContainer = styled.div` + display: flex; + flex-direction: column; +`; + const renderSuggestionsContainer = ({ containerProps, children }) => ( {children} ); diff --git a/packages/code-du-travail-frontend/src/outils/common/__tests__/__snapshots__/Wizard.test.tsx.snap b/packages/code-du-travail-frontend/src/outils/common/__tests__/__snapshots__/Wizard.test.tsx.snap index 8787a4a536..8e29ce7da7 100644 --- a/packages/code-du-travail-frontend/src/outils/common/__tests__/__snapshots__/Wizard.test.tsx.snap +++ b/packages/code-du-travail-frontend/src/outils/common/__tests__/__snapshots__/Wizard.test.tsx.snap @@ -6,35 +6,35 @@ exports[` should call navigate the previous step when click on précé class="sc-iGgWBj biWgIW" >

test H1

Étape s   1/2 @@ -45,21 +45,21 @@ exports[` should call navigate the previous step when click on précé >
  • 1 First Step
  • 2 @@ -71,15 +71,15 @@ exports[` should call navigate the previous step when click on précé Premiere Etape