@@ -2,8 +2,6 @@ import React, { useEffect, useState } from 'react'
22import styled , { keyframes } from 'styled-components'
33import { Link } from 'react-router-dom'
44
5- type ConsentValue = 'granted' | 'denied' | null
6-
75const STORAGE_KEY = 'cookie_consent'
86
97function updateGoogleConsent ( value : 'granted' | 'denied' ) {
@@ -18,11 +16,10 @@ function updateGoogleConsent(value: 'granted' | 'denied') {
1816}
1917
2018const CookieBanner = ( ) => {
21- const [ consent , setConsent ] = useState < ConsentValue > ( null )
2219 const [ visible , setVisible ] = useState ( false )
2320
2421 useEffect ( ( ) => {
25- const stored = localStorage . getItem ( STORAGE_KEY ) as ConsentValue
22+ const stored = localStorage . getItem ( STORAGE_KEY ) as 'granted' | 'denied' | null
2623 if ( stored === 'granted' || stored === 'denied' ) {
2724 // Re-apply saved choice on every page load so Consent Mode is always in sync
2825 updateGoogleConsent ( stored )
@@ -36,14 +33,12 @@ const CookieBanner = () => {
3633 const handleAccept = ( ) => {
3734 localStorage . setItem ( STORAGE_KEY , 'granted' )
3835 updateGoogleConsent ( 'granted' )
39- setConsent ( 'granted' )
4036 setVisible ( false )
4137 }
4238
4339 const handleDecline = ( ) => {
4440 localStorage . setItem ( STORAGE_KEY , 'denied' )
4541 updateGoogleConsent ( 'denied' )
46- setConsent ( 'denied' )
4742 setVisible ( false )
4843 }
4944
0 commit comments