@@ -327,49 +327,13 @@ function createConsentManagement<
327327 </ div >
328328 </ fieldset >
329329 </ div >
330-
331- < div className = "fr-consent-service" >
332- < fieldset className = "fr-fieldset fr-fieldset--inline" >
333- < legend
334- aria-describedby = "finality-0-desc"
335- className = "fr-consent-service__title"
336- >
337- Cookies obligatoires
338- </ legend >
339- < div className = "fr-consent-service__radios" >
340- < div className = "fr-radio-group" >
341- < input
342- checked = { true }
343- disabled = { true }
344- type = "radio"
345- id = "consent-finality-0-accept"
346- name = "consent-finality-0"
347- data-fr-js-radio-actionee = "true"
348- />
349- < label htmlFor = "consent-finality-0-accept" className = "fr-label" >
350- Accepter
351- </ label >
352- </ div >
353- < div className = "fr-radio-group" >
354- < input
355- disabled = { true }
356- type = "radio"
357- id = "consent-finality-0-refuse"
358- name = "consent-finality-0"
359- data-fr-js-radio-actionee = "true"
360- /> { " " }
361- < label htmlFor = "consent-finality-0-refuse" className = "fr-label" >
362- Refuser
363- </ label >
364- </ div >
365- </ div >
366- < p id = "finality-0-desc" className = "fr-consent-service__desc" >
367- Ce site utilise des cookies nécessaires à son bon fonctionnement qui
368- ne peuvent pas être désactivés.
369- </ p >
370- </ fieldset >
371- </ div >
372-
330+ < ConsentService
331+ title = { t ( "mandatory cookies" ) }
332+ description = { t ( "mandatory cookies - description" ) }
333+ finalityConsent = { true }
334+ onChange = { undefined }
335+ subFinalities = { undefined }
336+ />
373337 { objectKeys ( finalityDescription )
374338 . map ( finality => ( {
375339 "finality" : ( assert ( typeof finality === "string" ) , finality ) ,
@@ -412,7 +376,7 @@ function createConsentManagement<
412376 disabled = { isProcessingChanges }
413377 onClick = { createOnClick ( "apply local changes" ) }
414378 >
415- Confirmer mes choix
379+ { t ( "confirm choices" ) }
416380 </ button >
417381 </ li >
418382 </ ul >
@@ -430,10 +394,15 @@ function createConsentManagement<
430394 | ( {
431395 isFullConsent : boolean ;
432396 } & Record < string , boolean > ) ;
433- onChange : ( params : { subFinality : string | undefined ; isConsentGiven : boolean } ) => void ;
397+ /** Undefined when not modifiable */
398+ onChange :
399+ | ( ( params : { subFinality : string | undefined ; isConsentGiven : boolean } ) => void )
400+ | undefined ;
434401 } ) {
435402 const { title, description, subFinalities, finalityConsent, onChange } = props ;
436403
404+ const { t } = useTranslation ( ) ;
405+
437406 const { legendId, descriptionId, acceptInputId, refuseInputId, subFinalityDivId } =
438407 ( function useClosure ( ) {
439408 const id = useId ( ) ;
@@ -484,25 +453,47 @@ function createConsentManagement<
484453 type = "radio"
485454 id = { acceptInputId }
486455 checked = { macroState === "full consent" }
487- onChange = { ( ) =>
488- onChange ( { "subFinality" : undefined , "isConsentGiven" : true } )
489- }
456+ { ...( ( ) => {
457+ if ( onChange === undefined )
458+ return {
459+ "disabled" : true
460+ } ;
461+
462+ return {
463+ "onChange" : ( ) =>
464+ onChange ( {
465+ "subFinality" : undefined ,
466+ "isConsentGiven" : true
467+ } )
468+ } ;
469+ } ) ( ) }
490470 />
491471 < label className = "fr-label" htmlFor = { acceptInputId } >
492- Accepter
472+ { t ( "accept" ) }
493473 </ label >
494474 </ div >
495475 < div className = { fr . cx ( "fr-radio-group" ) } >
496476 < input
497477 type = "radio"
498478 id = { refuseInputId }
499479 checked = { macroState === "full refusal" }
500- onChange = { ( ) =>
501- onChange ( { "subFinality" : undefined , "isConsentGiven" : false } )
502- }
480+ { ...( ( ) => {
481+ if ( onChange === undefined )
482+ return {
483+ "disabled" : true
484+ } ;
485+
486+ return {
487+ "onChange" : ( ) =>
488+ onChange ( {
489+ "subFinality" : undefined ,
490+ "isConsentGiven" : false
491+ } )
492+ } ;
493+ } ) ( ) }
503494 />
504495 < label className = { fr . cx ( "fr-label" ) } htmlFor = { refuseInputId } >
505- Refuser
496+ { t ( "refuse" ) }
506497 </ label >
507498 </ div >
508499 </ div >
@@ -513,6 +504,7 @@ function createConsentManagement<
513504 ) }
514505 { subFinalities !== undefined &&
515506 ( assert ( typeof finalityConsent !== "boolean" ) ,
507+ assert ( onChange !== undefined ) ,
516508 (
517509 < >
518510 < div className = { fr . cx ( "fr-consent-service__collapse" ) } >
@@ -522,7 +514,7 @@ function createConsentManagement<
522514 aria-describedby = { legendId }
523515 aria-controls = { subFinalityDivId }
524516 >
525- Voir plus de détails
517+ { t ( "see more details" ) }
526518 </ button >
527519 </ div >
528520 < div
@@ -557,6 +549,8 @@ function createConsentManagement<
557549 } ) {
558550 const { title, onChange, isConsentGiven } = props ;
559551
552+ const { t } = useTranslation ( ) ;
553+
560554 const { acceptInputId, refuseInputId } = ( function useClosure ( ) {
561555 const id = useId ( ) ;
562556
@@ -579,7 +573,7 @@ function createConsentManagement<
579573 onChange = { ( ) => onChange ( { "isConsentGiven" : true } ) }
580574 />
581575 < label className = { fr . cx ( "fr-label" ) } htmlFor = { acceptInputId } >
582- Accepter
576+ { t ( "accept" ) }
583577 </ label >
584578 </ div >
585579 < div className = { fr . cx ( "fr-radio-group" ) } >
@@ -590,7 +584,7 @@ function createConsentManagement<
590584 onChange = { ( ) => onChange ( { "isConsentGiven" : false } ) }
591585 />
592586 < label className = { fr . cx ( "fr-label" ) } htmlFor = { refuseInputId } >
593- Refuser
587+ { t ( "refuse" ) }
594588 </ label >
595589 </ div >
596590 </ div >
@@ -718,7 +712,12 @@ const { useTranslation, addGdprTranslations } = createComponentI18nApi({
718712 ) }
719713 </ >
720714 ) ;
721- }
715+ } ,
716+ "see more details" : "Voir plus de détails" ,
717+ "mandatory cookies" : "Cookies obligatoires" ,
718+ "mandatory cookies - description" :
719+ "Ce site utilise des cookies nécessaires à son bon fonctionnement qui ne peuvent pas être désactivés." ,
720+ "confirm my choices" : "Confirmer mes choix"
722721 /** cspell: enable */
723722 }
724723} ) ;
@@ -772,7 +771,12 @@ addGdprTranslations({
772771 ) }
773772 </ >
774773 ) ;
775- }
774+ } ,
775+ "see more details" : "See more details" ,
776+ "mandatory cookies" : "Mandatory cookies" ,
777+ "mandatory cookies - description" :
778+ "This site uses cookies necessary for its proper functioning which cannot be deactivated." ,
779+ "confirm my choices" : "Confirm my choices"
776780 }
777781} ) ;
778782
0 commit comments