diff --git a/test/integration/cra/src/Home.tsx b/test/integration/cra/src/Home.tsx index b0b74791d..45f6fda8c 100644 --- a/test/integration/cra/src/Home.tsx +++ b/test/integration/cra/src/Home.tsx @@ -3,9 +3,7 @@ import { fr } from "@codegouvfr/react-dsfr"; import { useIsDark } from "@codegouvfr/react-dsfr/useIsDark"; import { SideMenu } from "@codegouvfr/react-dsfr/SideMenu"; import { Table } from "@codegouvfr/react-dsfr/Table"; -import { useGdprStore } from "@codegouvfr/react-dsfr/useGdprStore" import { ButtonsGroup } from '@codegouvfr/react-dsfr/ButtonsGroup'; -import { consentModalNativeButtonProps } from '@codegouvfr/react-dsfr/ConsentBanner'; const sideMenuItems = [ { @@ -109,7 +107,6 @@ export function Home() { /> - ); } @@ -131,25 +128,3 @@ function TableExample() { ); } - -export const GdprStoreViewer = () => { - const {consents, firstChoiceMade } = useGdprStore(); - - return <> - -
{JSON.stringify({consents, firstChoiceMade})}
- ; -} \ No newline at end of file diff --git a/test/integration/cra/src/index.tsx b/test/integration/cra/src/index.tsx index b2d594ffb..5fe5a990e 100644 --- a/test/integration/cra/src/index.tsx +++ b/test/integration/cra/src/index.tsx @@ -9,19 +9,12 @@ import { Header } from "@codegouvfr/react-dsfr/Header"; import { fr } from "@codegouvfr/react-dsfr"; import { routes } from "./router"; import { headerFooterDisplayItem } from "@codegouvfr/react-dsfr/Display"; -import { GdprStoreProvider } from "@codegouvfr/react-dsfr/gdpr"; -import { ConsentBanner } from '@codegouvfr/react-dsfr/ConsentBanner'; startReactDsfr({ "defaultColorScheme": "system" }); -declare module "@codegouvfr/react-dsfr/gdpr" { - interface RegisterGdprServices { - matomo: never; - } -} createRoot(document.getElementById("root")!).render( @@ -46,62 +39,53 @@ function Root() { } }} /> - - +
+
INTITULE
OFFICIEL} + serviceTitle="Nom du site / service" + quickAccessItems={[ + headerFooterDisplayItem, + { + iconId: "ri-mail-line", + linkProps: { + href: `mailto:${"joseph.garrone@code.gouv.fr"}`, + }, + text: "Nous contacter", + } + ]} + homeLinkProps={{ ...routes.home().link, "title": "Accueil - Nom de l’entité (ministère, secrétariat d‘état, gouvernement)" }} + navigation={[ + { + "text": "Home", + "linkProps": routes.home().link, + "isActive": route.name === "home" + }, + { + "text": "Mui playground", + "linkProps": routes.mui().link, + "isActive": route.name === "mui" + } + ]} + />
-
INTITULE
OFFICIEL} - serviceTitle="Nom du site / service" - quickAccessItems={[ - headerFooterDisplayItem, - { - iconId: "ri-mail-line", - linkProps: { - href: `mailto:${"joseph.garrone@code.gouv.fr"}`, - }, - text: "Nous contacter", - } - ]} - homeLinkProps={{ ...routes.home().link, "title": "Accueil - Nom de l’entité (ministère, secrétariat d‘état, gouvernement)" }} - navigation={[ - { - "text": "Home", - "linkProps": routes.home().link, - "isActive": route.name === "home" - }, - { - "text": "Mui playground", - "linkProps": routes.mui().link, - "isActive": route.name === "mui" - } - ]} - /> -
- {(() => { - switch (route.name) { - case "mui": return ; - case "home": return ; - case false: return

404

- } - })()} -
+ {(() => { + switch (route.name) { + case "mui": return ; + case "home": return ; + case false: return

404

+ } + })()}
- +
); diff --git a/test/integration/vite/src/Home.tsx b/test/integration/vite/src/Home.tsx index 02df4fc19..e3600e468 100644 --- a/test/integration/vite/src/Home.tsx +++ b/test/integration/vite/src/Home.tsx @@ -9,8 +9,6 @@ import { fr } from "@codegouvfr/react-dsfr"; import { useIsDark } from "@codegouvfr/react-dsfr/useIsDark"; import { useState } from "react"; import { Table } from "@codegouvfr/react-dsfr/Table"; -import { useGdprStore } from "@codegouvfr/react-dsfr/useGdprStore" -import { consentModalNativeButtonProps } from '@codegouvfr/react-dsfr/ConsentBanner'; export function Home() { const { isDark, setIsDark } = useIsDark(); @@ -68,8 +66,6 @@ export function Home() {
- - ); } @@ -207,24 +203,3 @@ function TableExample() { } -export const GdprStoreViewer = () => { - const {consents, firstChoiceMade } = useGdprStore(); - - return <> - -
{JSON.stringify({consents, firstChoiceMade})}
- ; -} diff --git a/test/integration/vite/src/gdpr.tsx b/test/integration/vite/src/gdpr.tsx new file mode 100644 index 000000000..64bf5c4c1 --- /dev/null +++ b/test/integration/vite/src/gdpr.tsx @@ -0,0 +1,46 @@ +"use client"; + +import { createGdprApi } from "@codegouvfr/react-dsfr/gdpr"; + +export const { + ConsentBannerAndConsentManagement, + useGdpr, + FooterConsentManagementItem, + FooterPersonalDataPolicyItem +} = createGdprApi({ + "finalityDescription": ({ lang }) => ({ + "advertising": { + "title": "Publicité", + "description": "Nous utilisons des cookies pour vous proposer des publicités adaptées à vos centres d’intérêts et mesurer leur efficacité." + }, + "analytics": { + "title": "Analyse", + "description": "Nous utilisons des cookies pour mesurer l’audience de notre site et améliorer son contenu." + }, + "personalization": { + "title": "Personnalisation", + "description": "Nous utilisons des cookies pour vous proposer des contenus adaptés à vos centres d’intérêts." + }, + "statistics": { + "title": "Statistiques", + "description": "Nous utilisons des cookies pour mesurer l’audience de notre site et améliorer son contenu.", + "subFinalities": { + "deviceInfo": "Informations sur votre appareil", + "traffic": "Informations sur votre navigation", + } + } + }), + "personalDataPolicyLinkProps": { + "to": "#", + "onClick": ()=> { + alert("Navigate or display your data policy"); + } + }, + "consentCallback": async ({ finalityConsent, finalityConsent_prev })=> { + console.log("callback from gdpr hook", { finalityConsent, finalityConsent_prev }); + } +}); + + + + diff --git a/test/integration/vite/src/main.tsx b/test/integration/vite/src/main.tsx index 4f67f9f98..f9719f8da 100644 --- a/test/integration/vite/src/main.tsx +++ b/test/integration/vite/src/main.tsx @@ -10,8 +10,7 @@ import { Routes, Route, Link, useLocation } from "react-router-dom"; import { headerFooterDisplayItem } from "@codegouvfr/react-dsfr/Display"; import { GlobalStyles } from "tss-react"; import { fr } from "@codegouvfr/react-dsfr"; -import { GdprStoreProvider } from "@codegouvfr/react-dsfr/gdpr"; -import { ConsentBanner } from '@codegouvfr/react-dsfr/ConsentBanner'; +import { ConsentBannerAndConsentManagement, FooterConsentManagementItem, FooterPersonalDataPolicyItem } from "./gdpr"; startReactDsfr({ "defaultColorScheme": "system", Link }); @@ -21,11 +20,6 @@ declare module "@codegouvfr/react-dsfr/spa" { } } -declare module "@codegouvfr/react-dsfr/gdpr" { - interface RegisterGdprServices { - matomo: never; - } -} ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( @@ -52,21 +46,15 @@ function Root() { const location = useLocation(); return ( - - + <> +
INTITULE
OFFICIEL} serviceTitle="Nom du site / service" - homeLinkProps={{ - "to": "/", - "title": "Accueil - Nom de l’entité (ministère, secrétariat d‘état, gouvernement)" + homeLinkProps={{ + "to": "/", + "title": "Accueil - Nom de l’entité (ministère, secrétariat d‘état, gouvernement)" }} quickAccessItems={[ headerFooterDisplayItem, @@ -123,10 +111,14 @@ function Root() { Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. `} - bottomItems={[headerFooterDisplayItem]} + bottomItems={[ + headerFooterDisplayItem, + , + + ]} />
-
+ ); }