diff --git a/.replit b/.replit index 9eb5d4c..2d8a3dc 100644 --- a/.replit +++ b/.replit @@ -40,4 +40,4 @@ args = "npm run dev" waitForPort = 5000 [agent] -integrations = ["javascript_google_analytics==1.0.0", "javascript_database==1.0.0"] +integrations = ["javascript_database==1.0.0", "javascript_google_analytics==1.0.0"] diff --git a/client/src/components/CookieConsent.tsx b/client/src/components/CookieConsent.tsx index ce4f71c..559fcfb 100644 --- a/client/src/components/CookieConsent.tsx +++ b/client/src/components/CookieConsent.tsx @@ -18,9 +18,22 @@ export default function CookieConsent() { }); useEffect(() => { - // Clear old consent to show new banner - localStorage.removeItem('cookie_consent'); - setShowBanner(true); + // Check if user has already given consent + const savedConsent = localStorage.getItem('cookie_consent'); + if (savedConsent) { + try { + const parsedConsent = JSON.parse(savedConsent); + setConsent(parsedConsent); + updateGoogleConsent(parsedConsent); + setShowBanner(false); // Don't show banner if consent already exists + } catch (error) { + // If parsing fails, show banner + setShowBanner(true); + } + } else { + // No saved consent, show banner + setShowBanner(true); + } }, []); const updateGoogleConsent = (consentState: ConsentState) => {