Skip to content

Commit

Permalink
feat: support de la 3248 dans l'ancien format des contributions (#5477)
Browse files Browse the repository at this point in the history
Co-authored-by: Victor <[email protected]>
Co-authored-by: Martial Maillot <[email protected]>
Co-authored-by: Maxime Golfier <[email protected]>
Co-authored-by: carolineBda <[email protected]>
Co-authored-by: maxgfr <[email protected]>
Co-authored-by: Caroline <[email protected]>
  • Loading branch information
6 people authored Dec 15, 2023
1 parent 916cdbc commit bcffbd4
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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"
Expand All @@ -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;
Expand Down Expand Up @@ -201,18 +207,34 @@ const Contribution = ({ answers, content }) => {
</a>
</p>
</>
) : (
) : convention.num !== 3248 ||
(convention.num === 3248 &&
router.query.slug ===
"quest-ce-quune-rupture-conventionnelle") ? (
<Section>
Désolé, nous n’avons pas de réponse pour cette convention
collective.
</Section>
) : (
<></>
)}
{!isConventionalAnswer && (
<ButtonWrapper>
<Button variant="primary" onClick={() => setConvention()}>
Changer de convention collective
<StyledCloseIcon />
</Button>
{convention.num === 3248 &&
router.query.slug !==
"quest-ce-quune-rupture-conventionnelle" ? (
<Button
variant="primary"
onClick={() => openNewContributionPage()}
>
Afficher les informations
</Button>
) : (
<Button variant="primary" onClick={() => setConvention()}>
Changer de convention collective
<StyledCloseIcon />
</Button>
)}
</ButtonWrapper>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -82,7 +82,6 @@ export const SearchAgreementInput = ({
l’entreprise (Ex : 4752A).
</p>
</InfoBulle>

<Autosuggest
theme={suggesterTheme}
suggestions={state.data ?? []}
Expand All @@ -95,7 +94,7 @@ export const SearchAgreementInput = ({
}
return true;
}}
getSuggestionValue={(suggestion) => suggestion}
getSuggestionValue={(suggestion) => suggestion as any}
renderSuggestion={renderSuggestion}
renderSuggestionsContainer={renderSuggestionsContainer}
renderInputComponent={renderInputComponent}
Expand All @@ -115,14 +114,27 @@ const SuggestionsContainer = styled.div`
}
`;

const renderSuggestion = (suggestion) => (
<div>
{suggestion.shortTitle} <IDCC>(IDCC {formatIdcc(suggestion.num)})</IDCC>
</div>
);
const renderSuggestion = (suggestion: Agreement) => {
return (
<SuggestionContainer>
{suggestion.shortTitle} <IDCC>(IDCC {formatIdcc(suggestion.num)})</IDCC>
<Paragraph noMargin variant="secondary">
{suggestion.highlight?.searchInfo &&
`(${suggestion.highlight?.searchInfo})`}
</Paragraph>
</SuggestionContainer>
);
};

const IDCC = styled.span`
font-weight: normal;
`;

const SuggestionContainer = styled.div`
display: flex;
flex-direction: column;
`;

const renderSuggestionsContainer = ({ containerProps, children }) => (
<SuggestionsContainer {...containerProps}>{children}</SuggestionsContainer>
);
Expand Down
Loading

0 comments on commit bcffbd4

Please sign in to comment.