Skip to content

Commit

Permalink
feat: Add cookie system for PolicyImpactPopup (#1899)
Browse files Browse the repository at this point in the history
Co-authored-by: PolicyEngine[bot] <[email protected]>
  • Loading branch information
anth-volk and PolicyEngine[bot] authored Jun 28, 2024
1 parent fdcd833 commit 67d72c4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/modals/PolicyImpactPopup.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import { Modal } from "antd";
import { useState } from "react";
import Button from "../controls/Button";
import { useAuth0 } from "@auth0/auth0-react";
import { getCookie, setCookie } from "../data/cookies";

export default function PolicyImpactPopup(props) {
const [needToOpenModal, setNeedToOpenModal] = useState(true);
const { metadata, showPolicyImpactPopup } = props;

const { isAuthenticated } = useAuth0();

function handleSubmit() {
// For authed users who accepted cookies, log cookie
// to prevent re-display
const consentCookie = getCookie("consent");
if (isAuthenticated && consentCookie === "granted") {
setCookie("policyImpactPopup", "disabled");
}

// Destroy modal
setNeedToOpenModal(false);
}
Expand Down
7 changes: 6 additions & 1 deletion src/modals/SignupModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Button from "../controls/Button";
import { useAuth0 } from "@auth0/auth0-react";
import { loginOptions } from "../auth/authUtils";
import useCountryId from "../hooks/useCountryId";
import { getCookie } from "../data/cookies";

export default function SignupModal(props) {
const { setShowPolicyImpactPopup } = props;
Expand All @@ -28,7 +29,11 @@ export default function SignupModal(props) {
}

if (isLoading || isAuthenticated) {
setShowPolicyImpactPopup(true);
if (getCookie("policyImpactPopup") === "disabled") {
setShowPolicyImpactPopup(false);
} else {
setShowPolicyImpactPopup(true);
}
return null;
}

Expand Down

0 comments on commit 67d72c4

Please sign in to comment.