Skip to content

Commit

Permalink
fix hybridization problem
Browse files Browse the repository at this point in the history
  • Loading branch information
asanchezyali committed Aug 10, 2023
1 parent ae24c96 commit 7139892
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions morpheus-client/components/CookiesConset/CookiesConsent.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import { useEffect } from "react";
import { useEffect, useState } from "react";
import { useAnalytics } from "@/context/GoogleAnalyticsContext";
import { deleteAllCookies } from "@/utils/cookies";
import { useLocalStorage } from "@/hooks/useLocalStorage";
import styles from "./CookiesConsent.module.scss";

const CookiesConsent = () => {
const [finalStatus, setFinalStatus] = useState("");
const { cookiesStatus, setCookiesStatus } = useAnalytics();

const [localCookies, setLocalCookies] = useLocalStorage<string | null>("cp:cookies", null);
const finalStatus = localCookies || cookiesStatus || "";


useEffect(() => {
if (localCookies && localCookies !== "") setCookiesStatus(localCookies);
}, [localCookies, setCookiesStatus]);
const newStatus = localCookies || cookiesStatus || "";
setFinalStatus(newStatus);
if (newStatus !== "") {
if (localCookies && localCookies !== "") setCookiesStatus(localCookies);
}
}, [localCookies, setCookiesStatus, cookiesStatus]);

const handleActionCookies = (event: any, status: string) => {
event.preventDefault();
Expand Down

0 comments on commit 7139892

Please sign in to comment.