File tree 2 files changed +10
-4
lines changed
2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import { useRerenderOnChange } from "../tools/StatefulObservable/hooks";
9
9
import { createConsentBannerAndConsentManagement } from "./ConsentBannerAndConsentManagement" ;
10
10
import { isBrowser } from "../tools/isBrowser" ;
11
11
12
- export const localStorageKeyPrefix = "@codegouvfr/react-dsfr finalityConsent" ;
12
+ export const defaultLocalStorageKeyPrefix = "@codegouvfr/react-dsfr finalityConsent" ;
13
13
14
14
export function createConsentManagement <
15
15
FinalityDescription extends Record <
@@ -21,10 +21,16 @@ export function createConsentManagement<
21
21
consentCallback ?: ConsentCallback < ExtractFinalityFromFinalityDescription < FinalityDescription > > ;
22
22
/** Optional: If you have a dedicated page that provides comprehensive information about your website's GDPR policies. */
23
23
personalDataPolicyLinkProps ?: RegisteredLinkProps ;
24
+ localStorageKeyPrefix ?: string ;
24
25
} ) {
25
26
type Finality = ExtractFinalityFromFinalityDescription < FinalityDescription > ;
26
27
27
- const { finalityDescription, personalDataPolicyLinkProps, consentCallback } = params ;
28
+ const {
29
+ finalityDescription,
30
+ personalDataPolicyLinkProps,
31
+ consentCallback,
32
+ localStorageKeyPrefix = defaultLocalStorageKeyPrefix
33
+ } = params ;
28
34
29
35
const finalities = getFinalitiesFromFinalityDescription ( {
30
36
"finalityDescription" :
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import React from "react";
2
2
import { sectionName } from "./sectionName" ;
3
3
import { getStoryFactory } from "./getStory" ;
4
4
import { createConsentManagement } from "../dist/consentManagement" ;
5
- import { localStorageKeyPrefix } from "../dist/consentManagement/createConsentManagement" ;
5
+ import { defaultLocalStorageKeyPrefix } from "../dist/consentManagement/createConsentManagement" ;
6
6
import { Placeholder } from "../dist/consentManagement/Placeholder" ;
7
7
import { Footer } from "../dist/Footer" ;
8
8
import { Button } from "../dist/Button" ;
@@ -284,7 +284,7 @@ function Story() {
284
284
< Button
285
285
onClick = { ( ) => {
286
286
Object . keys ( localStorage )
287
- . filter ( key => key . startsWith ( localStorageKeyPrefix ) )
287
+ . filter ( key => key . startsWith ( defaultLocalStorageKeyPrefix ) )
288
288
. forEach ( key => localStorage . removeItem ( key ) ) ;
289
289
290
290
location . reload ( ) ;
You can’t perform that action at this time.
0 commit comments