-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(contributions): modification des events sur les contribs generiqu…
…es pour être ISO avec ce qu'on avait avant le passage au DSFR (#6443)
- Loading branch information
1 parent
397232c
commit d26db43
Showing
27 changed files
with
674 additions
and
313 deletions.
There are no files selected for viewing
2 changes: 0 additions & 2 deletions
2
packages/code-du-travail-frontend/app/outils/convention-collective/convention/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/code-du-travail-frontend/src/modules/common/BlueCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from "react"; | ||
import { css } from "@styled-system/css"; | ||
import { fr } from "@codegouvfr/react-dsfr"; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
const BlueCard = ({ children, ...props }: Props): JSX.Element => { | ||
return ( | ||
<div | ||
{...props} | ||
className={`${fr.cx("fr-px-1w", "fr-px-md-3w", "fr-py-3w", "fr-mb-6w")} ${block}`} | ||
> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export default BlueCard; | ||
|
||
const block = css({ | ||
background: "var(--background-alt-blue-cumulus)", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 0 additions & 54 deletions
54
packages/code-du-travail-frontend/src/modules/contributions/ContributionAgreemeentSelect.tsx
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
packages/code-du-travail-frontend/src/modules/contributions/ContributionAgreement.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
"use client"; | ||
import React from "react"; | ||
import { css } from "@styled-system/css"; | ||
import { fr } from "@codegouvfr/react-dsfr"; | ||
import { ContributionAgreementContent } from "./ContributionAgreementContent"; | ||
import { Contribution } from "./type"; | ||
import { removeCCNumberFromSlug } from "../common/utils"; | ||
import BlueCard from "../common/BlueCard"; | ||
import Card from "@codegouvfr/react-dsfr/Card"; | ||
import Button from "@codegouvfr/react-dsfr/Button"; | ||
|
||
type Props = { | ||
contribution: Contribution; | ||
}; | ||
|
||
export function ContributionAgreement({ contribution }: Props) { | ||
const { slug, relatedItems } = contribution; | ||
|
||
return ( | ||
<> | ||
<BlueCard> | ||
<p className={fr.cx("fr-h3", "fr-mt-1w")}> | ||
Votre convention collective | ||
</p> | ||
<Card | ||
title={`${contribution.ccnShortTitle} (IDCC ${contribution.idcc})`} | ||
size="small" | ||
titleAs="h2" | ||
className={fr.cx("fr-mt-2w")} | ||
classes={{ | ||
content: fr.cx("fr-p-2w"), | ||
title: cardTitle, | ||
start: fr.cx("fr-m-0"), | ||
end: fr.cx("fr-p-0", "fr-m-0"), | ||
}} | ||
/> | ||
<Button | ||
className={fr.cx("fr-mt-2w")} | ||
linkProps={{ | ||
href: `/contribution/${removeCCNumberFromSlug(slug)}`, | ||
}} | ||
priority="secondary" | ||
iconId="fr-icon-arrow-go-back-line" | ||
iconPosition="right" | ||
> | ||
Modifier | ||
</Button> | ||
</BlueCard> | ||
|
||
<ContributionAgreementContent | ||
contribution={contribution} | ||
relatedItems={relatedItems} | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
const cardTitle = css({ | ||
fontWeight: "normal!", | ||
}); |
105 changes: 105 additions & 0 deletions
105
packages/code-du-travail-frontend/src/modules/contributions/ContributionGeneric.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
"use client"; | ||
import React, { useState } from "react"; | ||
import { useContributionTracking } from "./tracking"; | ||
import { isAgreementSupported, isAgreementValid } from "./contributionUtils"; | ||
import { ContributionGenericContent } from "./ContributionGenericContent"; | ||
import { Contribution } from "./type"; | ||
import { useLocalStorageForAgreement } from "../common/useLocalStorage"; | ||
import { ContributionGenericAgreementSearch } from "./ContributionGenericAgreementSearch"; | ||
import { Button } from "@codegouvfr/react-dsfr/Button"; | ||
import { fr } from "@codegouvfr/react-dsfr"; | ||
|
||
type Props = { | ||
contribution: Contribution; | ||
}; | ||
|
||
export function ContributionGeneric({ contribution }: Props) { | ||
const getTitle = () => `/contribution/${slug}`; | ||
const { slug, isNoCDT, relatedItems } = contribution; | ||
|
||
const [displayGeneric, setDisplayGeneric] = useState(false); | ||
|
||
const [selectedAgreement, setSelectedAgreement] = | ||
useLocalStorageForAgreement(); | ||
const { | ||
emitAgreementTreatedEvent, | ||
emitAgreementUntreatedEvent, | ||
emitDisplayAgreementContent, | ||
emitDisplayGeneralContent, | ||
emitDisplayGenericContent, | ||
emitClickP3, | ||
} = useContributionTracking(); | ||
|
||
return ( | ||
<> | ||
<ContributionGenericAgreementSearch | ||
contribution={contribution} | ||
onAgreementSelect={(agreement) => { | ||
setSelectedAgreement(agreement); | ||
setDisplayGeneric(false); | ||
if (!agreement) return; | ||
|
||
if (isAgreementSupported(contribution, agreement)) { | ||
emitAgreementTreatedEvent(agreement.num); | ||
} else { | ||
emitAgreementUntreatedEvent(agreement.num); | ||
} | ||
}} | ||
onDisplayClick={(ev) => { | ||
setDisplayGeneric(!displayGeneric); | ||
if ( | ||
!isAgreementValid(contribution, selectedAgreement) || | ||
!selectedAgreement | ||
) { | ||
ev.preventDefault(); | ||
setDisplayGeneric(true); | ||
if (selectedAgreement) { | ||
emitDisplayGeneralContent(getTitle()); | ||
} else { | ||
emitDisplayGenericContent(getTitle()); | ||
} | ||
} else { | ||
emitDisplayAgreementContent(getTitle()); | ||
} | ||
}} | ||
defaultAgreement={selectedAgreement} | ||
trackingActionName={getTitle()} | ||
/> | ||
|
||
{!isNoCDT && !isAgreementValid(contribution, selectedAgreement) && ( | ||
<> | ||
{!displayGeneric && ( | ||
<Button | ||
className={fr.cx("fr-mb-6w")} | ||
priority="tertiary no outline" | ||
onClick={() => { | ||
setDisplayGeneric(true); | ||
emitClickP3(getTitle()); | ||
}} | ||
> | ||
Afficher les informations sans sélectionner une convention | ||
collective | ||
</Button> | ||
)} | ||
<ContributionGenericContent | ||
contribution={contribution} | ||
relatedItems={relatedItems} | ||
displayGeneric={displayGeneric} | ||
alertText={ | ||
selectedAgreement && | ||
!isAgreementSupported(contribution, selectedAgreement) && ( | ||
<p> | ||
<strong> | ||
Cette réponse correspond à ce que prévoit le code du | ||
travail, elle ne tient pas compte des spécificités de la{" "} | ||
{selectedAgreement.shortTitle} | ||
</strong> | ||
</p> | ||
) | ||
} | ||
/> | ||
</> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.