diff --git a/src/components/CookieConsent/components/ConsentPopup/ConsentPopup.tsx b/src/components/CookieConsent/components/ConsentPopup/ConsentPopup.tsx index 4d464973..7e1806f8 100644 --- a/src/components/CookieConsent/components/ConsentPopup/ConsentPopup.tsx +++ b/src/components/CookieConsent/components/ConsentPopup/ConsentPopup.tsx @@ -180,9 +180,20 @@ export const ConsentPopup = ({ ...buttonsParams }: ConsentPopupProps) => { const mobile = useMobile(); - const [currentConsents, setCurrentConsents] = React.useState( - consentManager.getConsents(), - ); + const [currentConsents, setCurrentConsents] = React.useState(() => { + const existingConsents = consentManager.getConsents(); + + if (cookieList) { + return cookieList.reduce((acc: Consents, item) => { + if (item.defaultChecked) { + return {...acc, [item.type]: true}; + } + return acc; + }, existingConsents); + } + + return existingConsents; + }); const [currentStep, setCurrentStep] = React.useState<`${ConsentPopupStep}`>(step); const onChangeStep = (newStep: `${ConsentPopupStep}`) => { setCurrentStep(newStep);