From 44e515f23a8ad008d8b5ff9ddac40e0e2dbd28f2 Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Mon, 12 Oct 2020 18:24:19 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Cache=20le=20widget=20Ch=C3=B4ma?= =?UTF-8?q?ge=20Partiel=20quand=20on=20quitte=20le=20simulateur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/Simulateurs/ChômagePartiel.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ChômagePartiel.tsx b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ChômagePartiel.tsx index 1a5601a42..e6c011f0c 100644 --- a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ChômagePartiel.tsx +++ b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ChômagePartiel.tsx @@ -9,18 +9,23 @@ import React, { useContext, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { DottedName } from 'Rules' import styled from 'styled-components' -import { productionMode } from '../../../../utils' declare global { interface Window { STONLY_WID: string + StonlyWidget?: { + open: () => void + close: () => void + launcherShow: () => void + launcherHide: () => void + } } } export default function ChômagePartiel() { const inIframe = useContext(IsEmbeddedContext) useEffect(() => { - if (inIframe || !productionMode) { + if (inIframe) { return } const script = document.createElement('script') @@ -28,10 +33,12 @@ export default function ChômagePartiel() { script.src = 'https://stonly.com/js/widget/stonly-widget.js' script.async = true document.body.appendChild(script) + window.StonlyWidget?.launcherShow() return () => { + window.StonlyWidget?.launcherHide() document.body.removeChild(script) } - }, []) + }, [inIframe]) return ( <>