Skip to content

Commit

Permalink
Merge pull request #381 from mission-apprentissage/ui-infra/get-ifram…
Browse files Browse the repository at this point in the history
…e-ready

[UI - infra] Prépare l'exposition de l'iframe sur l'Onisep
  • Loading branch information
yohanngab authored Dec 16, 2024
2 parents 6859acc + 2c6c846 commit 50da543
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ location / {

client_max_body_size 0;

add_header Content-Security-Policy "frame-ancestors 'self' *.onisep.fr *.onisep.fr:8000 *.beta.gouv.fr *.incubateur.net";
add_header Content-Security-Policy "frame-ancestors 'self' *.onisep.fr *.onisep.fr:8000 *.onisep-preprod.fr *.beta.gouv.fr *.incubateur.net";
}
13 changes: 12 additions & 1 deletion ui/src/iframes/Components/TrouverUneEntrepriseRating.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import school from "../../assets/images/school-small.svg";
import search from "../../assets/images/search.svg";
import selfTraining from "../../assets/images/self-training.svg";
import useBreakpoints from "../../hooks/useBreakpoints";
import useMatomoEvent from "../../hooks/useMatomoEvent";
import { MATOMO_ACTION, MATOMO_CATEGORY } from "../../matomo";
import {
CardsContainer,
DidYouKnowContainer,
Expand Down Expand Up @@ -53,6 +55,7 @@ const TrouverEntrepriseCard = ({ percentage, count, label, position, seeMore })

const TrouverUneEntrepriseRating = ({ data, etablissementsCount }) => {
const [seeMore, setSeeMore] = useState(false);
const trackEvent = useMatomoEvent();

return (
<TrouverUneEntrepriseRatingContainer>
Expand Down Expand Up @@ -81,7 +84,15 @@ const TrouverUneEntrepriseRating = ({ data, etablissementsCount }) => {
<TrouverEntrepriseCard key={item.label} {...item} position={index + 1} seeMore={seeMore} />
))}
</CardsContainer>
<p onClick={() => setSeeMore((prevValue) => !prevValue)}>
<p
onClick={() => {
trackEvent(
MATOMO_CATEGORY.IFRAME_FORMATION,
seeMore ? MATOMO_ACTION.CLICK_TROUVER_ENTREPRISE_SEE_LESS : MATOMO_ACTION.CLICK_TROUVER_ENTREPRISE_SEE_MORE
);
setSeeMore((prevValue) => !prevValue);
}}
>
{seeMore ? "Voir moins" : "Voir plus"}{" "}
<span className={fr.cx(seeMore ? "fr-icon-arrow-up-s-line" : "fr-icon-arrow-down-s-line")} />
</p>
Expand Down
18 changes: 16 additions & 2 deletions ui/src/iframes/IframeFormationPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,27 @@ const IframeFormationPage = () => {

useEffect(() => {
if (isSuccess) {
window.parent.postMessage({ siriusHeight: document.body.scrollHeight + 50 }, "*");
window.parent.postMessage(
{
src: window.location.href,
height: document.body.scrollHeight,
siriusHeight: document.body.scrollHeight + 50,
},
"*"
);
}
}, [isSuccess]);

useEffect(() => {
const handleResize = () => {
window.parent.postMessage({ siriusHeight: document.body.scrollHeight + 50 }, "*");
window.parent.postMessage(
{
src: window.location.href,
height: document.body.scrollHeight,
siriusHeight: document.body.scrollHeight + 50,
},
"*"
);
};

document.addEventListener("click", handleResize);
Expand Down
4 changes: 3 additions & 1 deletion ui/src/matomo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const MATOMO_ACTION = {
CLICK_CAROUSEL_PREVIOUS: "Click carousel précédent",
CLICK_CAROUSEL_NEXT: "Click carousel suivant",
CLICK_CAROUSEL_SEE_MORE: "Click carousel voir plus de témoignages",
CLICK_THEMATIC_FROM_GRAPH: "Click thématique depuis graphique", //todo
CLICK_THEMATIC_FROM_GRAPH: "Click thématique depuis graphique",
CLICK_GRAPHIC_VIEW: "Click passage en mode graphique",
CLICK_TABLE_VIEW: "Click passage en mode tableau",
CLICK_VERBATIM_SEE_MORE: "Click voir plus",
Expand All @@ -16,4 +16,6 @@ export const MATOMO_ACTION = {
CLICK_QUESTION: "Click question",
CLICK_GO_BACK_THEMATICS: "Click revenir en arrière thématiques",
CLICK_GO_BACK_QUESTIONS: "Click revenir en arrière questions",
CLICK_TROUVER_ENTREPRISE_SEE_MORE: "Click voir plus trouver une entreprise",
CLICK_TROUVER_ENTREPRISE_SEE_LESS: "Click voir moins trouver une entreprise",
};

0 comments on commit 50da543

Please sign in to comment.