diff --git a/.env.sample b/.env.sample index d3a6454de..4ca24c5a5 100644 --- a/.env.sample +++ b/.env.sample @@ -19,4 +19,4 @@ NEXT_PUBLIC_GHOST_URL_IMAGES_SOURCE=ghost.adresse.data.gouv.fr NEXT_PUBLIC_BAL_ADMIN_API_URL=https://bal-admin.adresse.data.gouv.fr/api NEXT_PUBLIC_BAL_API_URL=https://api-bal.adresse.data.gouv.fr/v1 NEXT_PUBLIC_MES_ADRESSES=https://mes-adresses.data.gouv.fr -NEXT_PUBLIC_BAL_WIDGET_URL=http://localhost:3003 \ No newline at end of file +NEXT_PUBLIC_BAL_WIDGET_URL=https://plateforme-bal.adresse.data.gouv.fr/bal-widget \ No newline at end of file diff --git a/hooks/bal-widget.js b/hooks/bal-widget.js index ae4767a92..f6fd2499d 100644 --- a/hooks/bal-widget.js +++ b/hooks/bal-widget.js @@ -1,21 +1,16 @@ -import {useEffect, useRef} from 'react' - -const BAL_WIDGET_URL = process.env.NEXT_PUBLIC_BAL_WIDGET_URL +import {useEffect} from 'react' export function useBALWidget() { - const balWidgetRootElement = useRef(null) - useEffect(() => { + if (!process.env.NEXT_PUBLIC_BAL_WIDGET_URL) { + return + } const script = document.createElement('script') - script.src = `${BAL_WIDGET_URL}/bal-widget.js` + script.src = `${process.env.NEXT_PUBLIC_BAL_WIDGET_URL}/bal-widget.js` script.async = true script.defer = true document.body.appendChild(script) - script.onload = () => { - balWidgetRootElement.current = document.getElementById('bal-widget') - } - return () => { document.body.removeChild(script) } diff --git a/pages/_app.js b/pages/_app.js index 7c2c2cbb3..d62f79657 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -14,7 +14,6 @@ import { useBALWidget } from '@/hooks/bal-widget' const MATOMO_URL = process.env.NEXT_PUBLIC_MATOMO_URL const MATOMO_SITE_ID = process.env.NEXT_PUBLIC_MATOMO_SITE_ID - const { withDsfr, dsfrDocumentApi