From dd7ebfad4c4a9550178f18452a4860e7f505eeca Mon Sep 17 00:00:00 2001 From: Allison King Date: Wed, 28 Jun 2023 14:46:38 -0400 Subject: [PATCH] GPC indication on fides-js overlay (#3673) --- CHANGELOG.md | 1 + .../fides-js/src/components/CloseButton.tsx | 10 +- .../fides-js/src/components/ConsentBanner.tsx | 52 ++++++--- .../fides-js/src/components/ConsentModal.tsx | 2 + clients/fides-js/src/components/GpcBadge.tsx | 36 ++++++ clients/fides-js/src/components/GpcInfo.tsx | 29 +++++ .../fides-js/src/components/NoticeToggles.tsx | 3 + .../fides-js/src/components/WarningIcon.tsx | 14 +++ clients/fides-js/src/components/fides.css | 64 +++++++++- clients/fides-js/src/fides.ts | 34 ++++-- clients/fides-js/src/lib/consent-types.ts | 9 ++ clients/fides-js/src/lib/consent-utils.ts | 28 +++++ clients/fides-js/src/lib/consent-value.ts | 5 +- .../consent/ConfigDrivenConsent.tsx | 7 +- .../components/consent/ConsentItem.tsx | 2 +- .../consent/NoticeDrivenConsent.tsx | 5 +- .../cypress/e2e/consent-banner.cy.ts | 110 ++++++++++++++++++ .../privacy-center/cypress/e2e/consent.cy.ts | 3 +- .../features/consent/GpcMessages.tsx | 2 +- .../features/consent/helpers.ts | 25 +--- .../privacy-center/features/consent/types.ts | 9 -- 21 files changed, 372 insertions(+), 78 deletions(-) create mode 100644 clients/fides-js/src/components/GpcBadge.tsx create mode 100644 clients/fides-js/src/components/GpcInfo.tsx create mode 100644 clients/fides-js/src/components/WarningIcon.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d1d039e33e..479c5e5817b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ The types of changes are: ### Added - Empty state for when there are no relevant privacy notices in the privacy center [#3640](https://github.com/ethyca/fides/pull/3640) +- GPC indicators in fides-js banner and modal [#3673](https://github.com/ethyca/fides/pull/3673) - Set `sslmode` to `prefer` if connecting to Redshift via ssh [#3685](https://github.com/ethyca/fides/pull/3685) ### Fixed diff --git a/clients/fides-js/src/components/CloseButton.tsx b/clients/fides-js/src/components/CloseButton.tsx index 92eb4bbb26b..987026c8165 100644 --- a/clients/fides-js/src/components/CloseButton.tsx +++ b/clients/fides-js/src/components/CloseButton.tsx @@ -13,16 +13,10 @@ const CloseButton = ({ className="fides-close-button" onClick={onClick} > - + diff --git a/clients/fides-js/src/components/ConsentBanner.tsx b/clients/fides-js/src/components/ConsentBanner.tsx index 8a71139fa13..42438321dbc 100644 --- a/clients/fides-js/src/components/ConsentBanner.tsx +++ b/clients/fides-js/src/components/ConsentBanner.tsx @@ -1,6 +1,8 @@ import { h, FunctionComponent, VNode } from "preact"; +import { getConsentContext } from "../lib/consent-context"; import { ExperienceConfig } from "../lib/consent-types"; import CloseButton from "./CloseButton"; +import { GpcBadge } from "./GpcBadge"; interface BannerProps { experience: ExperienceConfig; @@ -14,26 +16,40 @@ const ConsentBanner: FunctionComponent = ({ buttonGroup, onClose, bannerIsOpen, -}) => ( -
-
-
- -
- {experience.title} +}) => { + const showGpcBadge = getConsentContext().globalPrivacyControl; + return ( +
+
+
+ +
+
+ {experience.title} +
+ {showGpcBadge ? ( + + ) : null} +
+
+ {experience.description} +
+ {buttonGroup}
-
- {experience.description} -
- {buttonGroup}
-
-); + ); +}; export default ConsentBanner; diff --git a/clients/fides-js/src/components/ConsentModal.tsx b/clients/fides-js/src/components/ConsentModal.tsx index 7e2f0b60d47..a7a10358053 100644 --- a/clients/fides-js/src/components/ConsentModal.tsx +++ b/clients/fides-js/src/components/ConsentModal.tsx @@ -3,6 +3,7 @@ import { Attributes } from "../lib/a11y-dialog"; import { PrivacyNotice, ExperienceConfig } from "../lib/consent-types"; import NoticeToggles from "./NoticeToggles"; import CloseButton from "./CloseButton"; +import GpcInfo from "./GpcInfo"; type NoticeKeys = Array; @@ -51,6 +52,7 @@ const ConsentModal = ({ > {experience.description}

+
( + + {label}{" "} + + {status} + + +); + +export const GpcBadgeForNotice = ({ + value, + notice, +}: { + value: boolean; + notice: PrivacyNotice; +}) => { + const consentContext = getConsentContext(); + const status = getGpcStatusFromNotice({ value, notice, consentContext }); + + if (status === GpcStatus.NONE) { + return null; + } + + return ; +}; diff --git a/clients/fides-js/src/components/GpcInfo.tsx b/clients/fides-js/src/components/GpcInfo.tsx new file mode 100644 index 00000000000..2c3aee6289f --- /dev/null +++ b/clients/fides-js/src/components/GpcInfo.tsx @@ -0,0 +1,29 @@ +import { h } from "preact"; +import WarningIcon from "./WarningIcon"; +import { getConsentContext } from "../lib/consent-context"; + +const GpcInfo = () => { + const context = getConsentContext(); + + if (!context.globalPrivacyControl) { + return null; + } + + return ( +
+
+ +
+
+

Global Privacy Control detected

+

+ Your global privacy control preference has been honored. You have been + automatically opted out of data uses cases which adhere to global + privacy control. +

+
+
+ ); +}; + +export default GpcInfo; diff --git a/clients/fides-js/src/components/NoticeToggles.tsx b/clients/fides-js/src/components/NoticeToggles.tsx index e97af5f6b0d..b073743d642 100644 --- a/clients/fides-js/src/components/NoticeToggles.tsx +++ b/clients/fides-js/src/components/NoticeToggles.tsx @@ -4,6 +4,7 @@ import { ConsentMechanism, PrivacyNotice } from "../lib/consent-types"; import Toggle from "./Toggle"; import Divider from "./Divider"; import { useDisclosure } from "../lib/hooks"; +import { GpcBadgeForNotice } from "./GpcBadge"; const NoticeToggle = ({ notice, @@ -46,7 +47,9 @@ const NoticeToggle = ({ className="fides-notice-toggle-trigger" > {notice.name} + + ( + + + +); + +export default WarningIcon; diff --git a/clients/fides-js/src/components/fides.css b/clients/fides-js/src/components/fides.css index 03272eccce9..0fe1f1ddaa5 100644 --- a/clients/fides-js/src/components/fides.css +++ b/clients/fides-js/src/components/fides.css @@ -8,6 +8,10 @@ --fides-overlay-font-color: #4a5568; --fides-overlay-font-color-dark: #2d3748; --fides-overlay-hover-color: #edf2f7; + --fides-overlay-gpc-applied-background-color: #38a169; + --fides-overlay-gpc-applied-text-color: white; + --fides-overlay-gpc-overridden-background-color: #e53e3e; + --fides-overlay-gpc-overridden-text-color: white; /* Buttons */ --fides-overlay-primary-button-background-color: var( --fides-overlay-primary-color @@ -143,6 +147,12 @@ div#fides-banner-container.fides-banner-top.fides-banner-hidden { } } +div#fides-banner-heading { + display: flex; + margin-right: 0.8em; + align-items: center; +} + div#fides-banner-title { font-size: var(--fides-overlay-font-size-title); font-weight: 600; @@ -286,8 +296,8 @@ div#fides-modal .fides-modal-button-group { .fides-close-button { position: absolute; - top: 1em; - right: 1em; + top: 0.5em; + right: 0.2em; cursor: pointer; background: none; border: none; @@ -423,10 +433,15 @@ div#fides-modal .fides-modal-button-group { padding: 0.5em; display: flex; justify-content: space-between; + min-height: 40px; + align-items: center; } .fides-notice-toggle .fides-notice-toggle-trigger { width: 100%; + display: flex; + justify-content: space-between; + margin-right: 0.5em; } .fides-notice-toggle .fides-notice-toggle-title:hover { @@ -441,3 +456,48 @@ div#fides-modal .fides-modal-button-group { .fides-notice-toggle-expanded { background-color: var(--fides-overlay-row-hover-color); } + +/* GPC */ +.fides-gpc-banner { + border: 1px solid var(--fides-overlay-primary-color); + border-radius: var(--fides-overlay-component-border-radius); + display: flex; + padding: 1.1em; + margin-bottom: 1em; +} + +.fides-gpc-banner p { + margin: 0; +} + +.fides-gpc-warning { + color: var(--fides-overlay-primary-color); + margin-right: 0.5em; +} + +.fides-gpc-header { + font-weight: 700; +} + +.fides-gpc-label { + font-weight: 600; + font-size: 0.9em; +} + +.fides-gpc-badge { + text-transform: uppercase; + padding: 0 4px; + font-weight: 700; + border-radius: var(--fides-overlay-button-border-radius); +} + +.fides-gpc-badge-applied, +.fides-gpc-badge-detected { + background: var(--fides-overlay-gpc-applied-background-color); + color: var(--fides-overlay-gpc-applied-text-color); +} + +.fides-gpc-badge-overridden { + background: var(--fides-overlay-gpc-overridden-background-color); + color: var(--fides-overlay-gpc-overridden-text-color); +} diff --git a/clients/fides-js/src/fides.ts b/clients/fides-js/src/fides.ts index 5afb053f878..7f5feb33163 100644 --- a/clients/fides-js/src/fides.ts +++ b/clients/fides-js/src/fides.ts @@ -66,6 +66,7 @@ import { UserGeolocation, ConsentMethod, SaveConsentPreference, + ConsentMechanism, } from "./lib/consent-types"; import { constructFidesRegionString, @@ -79,6 +80,7 @@ import { fetchExperience } from "./services/fides/api"; import { getGeolocation } from "./services/external/geolocation"; import { OverlayProps } from "./components/Overlay"; import { updateConsentPreferences } from "./lib/preferences"; +import { resolveConsentValue } from "./lib/consent-value"; export type Fides = { consent: CookieKeyConsent; @@ -131,26 +133,40 @@ const automaticallyApplyGPCPreferences = ( fidesApiUrl: string, effectiveExperience?: PrivacyExperience | null ) => { - if (!effectiveExperience) { + if (!effectiveExperience || !effectiveExperience.privacy_notices) { return; } - if (!getConsentContext().globalPrivacyControl) { + const context = getConsentContext(); + if (!context.globalPrivacyControl) { return; } - const consentPreferencesToSave: Array = []; - effectiveExperience.privacy_notices?.forEach((notice) => { - if (notice.has_gpc_flag && !notice.current_preference) { - consentPreferencesToSave.push( - new SaveConsentPreference( + let gpcApplied = false; + const consentPreferencesToSave = effectiveExperience.privacy_notices.map( + (notice) => { + if ( + notice.has_gpc_flag && + !notice.current_preference && + notice.consent_mechanism !== ConsentMechanism.NOTICE_ONLY + ) { + gpcApplied = true; + return new SaveConsentPreference( notice, transformConsentToFidesUserPreference(false, notice.consent_mechanism) + ); + } + return new SaveConsentPreference( + notice, + transformConsentToFidesUserPreference( + resolveConsentValue(notice, context), + notice.consent_mechanism ) ); } - }); - if (consentPreferencesToSave.length > 0) { + ); + + if (gpcApplied) { updateConsentPreferences({ consentPreferencesToSave, experienceId: effectiveExperience.id, diff --git a/clients/fides-js/src/lib/consent-types.ts b/clients/fides-js/src/lib/consent-types.ts index be126828f7b..df9f56cb9f7 100644 --- a/clients/fides-js/src/lib/consent-types.ts +++ b/clients/fides-js/src/lib/consent-types.ts @@ -196,6 +196,15 @@ export enum RequestOrigin { api = "api", } +export enum GpcStatus { + /** GPC is not relevant for the consent option. */ + NONE = "none", + /** GPC is enabled and consent matches the configured default. */ + APPLIED = "applied", + /** GPC is enabled but consent has been set to override the configured default. */ + OVERRIDDEN = "overridden", +} + // ------------------LEGACY TYPES BELOW ------------------- export type ConditionalValue = { diff --git a/clients/fides-js/src/lib/consent-utils.ts b/clients/fides-js/src/lib/consent-utils.ts index c1d1b4bbdb2..f5b0d629de0 100644 --- a/clients/fides-js/src/lib/consent-utils.ts +++ b/clients/fides-js/src/lib/consent-utils.ts @@ -1,8 +1,11 @@ +import { ConsentContext } from "./consent-context"; import { ComponentType, ConsentMechanism, FidesOptions, + GpcStatus, PrivacyExperience, + PrivacyNotice, UserConsentPreference, UserGeolocation, VALID_ISO_3166_LOCATION_REGEX, @@ -187,3 +190,28 @@ export const hasActionNeededNotices = (experience: PrivacyExperience) => (notice) => notice.current_preference == null ) ); + +export const getGpcStatusFromNotice = ({ + value, + notice, + consentContext, +}: { + value: boolean; + notice: PrivacyNotice; + consentContext: ConsentContext; +}) => { + // If GPC is not enabled, it won't be applied at all. + if ( + !consentContext.globalPrivacyControl || + !notice.has_gpc_flag || + notice.consent_mechanism === ConsentMechanism.NOTICE_ONLY + ) { + return GpcStatus.NONE; + } + + if (!value) { + return GpcStatus.APPLIED; + } + + return GpcStatus.OVERRIDDEN; +}; diff --git a/clients/fides-js/src/lib/consent-value.ts b/clients/fides-js/src/lib/consent-value.ts index 15b515e44d4..60dbf1b28d3 100644 --- a/clients/fides-js/src/lib/consent-value.ts +++ b/clients/fides-js/src/lib/consent-value.ts @@ -1,5 +1,5 @@ import { ConsentContext } from "./consent-context"; -import { ConsentValue, PrivacyNotice } from "./consent-types"; +import { ConsentMechanism, ConsentValue, PrivacyNotice } from "./consent-types"; import { transformUserPreferenceToBoolean } from "./consent-utils"; export const resolveLegacyConsentValue = ( @@ -28,6 +28,9 @@ export const resolveConsentValue = ( if (notice.current_preference) { return transformUserPreferenceToBoolean(notice.current_preference); } + if (notice.consent_mechanism === ConsentMechanism.NOTICE_ONLY) { + return true; + } const gpcEnabled = !!notice.has_gpc_flag && context.globalPrivacyControl === true; if (gpcEnabled) { diff --git a/clients/privacy-center/components/consent/ConfigDrivenConsent.tsx b/clients/privacy-center/components/consent/ConfigDrivenConsent.tsx index 9346881a2f1..9ef2382a039 100644 --- a/clients/privacy-center/components/consent/ConfigDrivenConsent.tsx +++ b/clients/privacy-center/components/consent/ConfigDrivenConsent.tsx @@ -1,6 +1,10 @@ import { Divider, Stack, useToast } from "@fidesui/react"; import React, { useCallback, useEffect, useMemo } from "react"; -import { getConsentContext, resolveLegacyConsentValue } from "fides-js"; +import { + getConsentContext, + resolveLegacyConsentValue, + GpcStatus, +} from "fides-js"; import { useAppDispatch, useAppSelector } from "~/app/hooks"; import { changeConsent, @@ -10,7 +14,6 @@ import { import { getGpcStatus } from "~/features/consent/helpers"; import { useConfig } from "~/features/common/config.slice"; -import { GpcStatus } from "~/features/consent/types"; import { inspectForBrowserIdentities } from "~/common/browser-identities"; import { useLocalStorage } from "~/common/hooks"; import { ConsentPreferences } from "~/types/api"; diff --git a/clients/privacy-center/components/consent/ConsentItem.tsx b/clients/privacy-center/components/consent/ConsentItem.tsx index c519a661482..ffeea7337e3 100644 --- a/clients/privacy-center/components/consent/ConsentItem.tsx +++ b/clients/privacy-center/components/consent/ConsentItem.tsx @@ -12,7 +12,7 @@ import { ExternalLinkIcon, } from "@fidesui/react"; -import { GpcStatus } from "~/features/consent/types"; +import { GpcStatus } from "fides-js"; import { GpcBadge, GpcInfo } from "~/features/consent/GpcMessages"; export type ConsentItemProps = { diff --git a/clients/privacy-center/components/consent/NoticeDrivenConsent.tsx b/clients/privacy-center/components/consent/NoticeDrivenConsent.tsx index 73d137d9eba..fd3e7eee18a 100644 --- a/clients/privacy-center/components/consent/NoticeDrivenConsent.tsx +++ b/clients/privacy-center/components/consent/NoticeDrivenConsent.tsx @@ -8,6 +8,8 @@ import { removeCookiesFromBrowser, saveFidesCookie, transformUserPreferenceToBoolean, + getGpcStatusFromNotice, + PrivacyNotice, } from "fides-js"; import { useAppSelector } from "~/app/hooks"; import { @@ -16,7 +18,6 @@ import { selectPrivacyExperience, useUpdatePrivacyPreferencesMutation, } from "~/features/consent/consent.slice"; -import { getGpcStatusFromNotice } from "~/features/consent/helpers"; import { ConsentMechanism, @@ -100,7 +101,7 @@ const NoticeDrivenConsent = () => { const value = transformUserPreferenceToBoolean(preference); const gpcStatus = getGpcStatusFromNotice({ value, - notice, + notice: notice as PrivacyNotice, consentContext, }); diff --git a/clients/privacy-center/cypress/e2e/consent-banner.cy.ts b/clients/privacy-center/cypress/e2e/consent-banner.cy.ts index fa7aca6dbb9..522a8284e21 100644 --- a/clients/privacy-center/cypress/e2e/consent-banner.cy.ts +++ b/clients/privacy-center/cypress/e2e/consent-banner.cy.ts @@ -665,6 +665,23 @@ describe("Consent banner", () => { [PRIVACY_NOTICE_KEY_1]: false, }); }); + + it("shows indicators that GPC has been applied", () => { + // In the banner + cy.get("div#fides-banner").within(() => { + cy.get("span").contains("Global Privacy Control Signal detected"); + }); + // And in the modal + cy.get("button").contains("Manage preferences").click(); + cy.get("div.fides-gpc-banner").contains( + "Global Privacy Control detected" + ); + cy.get("span") + .contains("Test privacy notice with gpc enabled") + .within(() => { + cy.get("span").contains("Global Privacy Control applied"); + }); + }); }); describe("when GPC flag is found, and no notices apply to GPC", () => { @@ -702,6 +719,17 @@ describe("Consent banner", () => { // check that preferences do not exist in cookie cy.getCookie(CONSENT_COOKIE_NAME).should("not.exist"); }); + + it("does not show gpc indicator but does show it was detected and the info banner", () => { + // In the banner + cy.get("div.fides-gpc-banner").contains( + "Global Privacy Control detected" + ); + // And in the modal + cy.get("button").contains("Manage preferences").click(); + cy.get("div.fides-gpc-banner").should("be.visible"); + cy.get("div.fides-gpc-badge").should("not.exist"); + }); }); describe("when no GPC flag is found, and notices apply to GPC", () => { @@ -736,6 +764,17 @@ describe("Consent banner", () => { // check that preferences do not exist in cookie cy.getCookie(CONSENT_COOKIE_NAME).should("not.exist"); }); + + it("does not show any gpc indicators", () => { + // In the banner + cy.get("div#fides-banner").within(() => { + cy.get("span.fides-gpc-badge").should("not.exist"); + }); + // And in the modal + cy.get("button").contains("Manage preferences").click(); + cy.get("div.fides-gpc-banner").should("not.exist"); + cy.get("div.fides-gpc-badge").should("not.exist"); + }); }); describe("when experience component is not an overlay", () => { @@ -1008,6 +1047,18 @@ describe("Consent banner", () => { // check that preferences do not exist in cookie cy.getCookie(CONSENT_COOKIE_NAME).should("not.exist"); }); + + it("shows gpc indicators in modal", () => { + cy.get("#fides-modal-link").click(); + cy.get("div.fides-gpc-banner").contains( + "Global Privacy Control detected" + ); + cy.get("span") + .contains("Test privacy notice") + .within(() => { + cy.get("span").contains("Global Privacy Control overridden"); + }); + }); }); describe("when banner should not be shown but modal link element exists", () => { @@ -1484,4 +1535,63 @@ describe("Consent banner", () => { }); }); }); + + describe("gpc indicators in the modal", () => { + beforeEach(() => { + cy.on("window:before:load", (win) => { + // eslint-disable-next-line no-param-reassign + win.navigator.globalPrivacyControl = true; + }); + }); + it("renders the proper gpc indicator", () => { + stubConfig({ + experience: { + privacy_notices: [ + mockPrivacyNotice({ + name: "Applied", + notice_key: "applied", + has_gpc_flag: true, + consent_mechanism: ConsentMechanism.OPT_OUT, + default_preference: UserConsentPreference.OPT_IN, + current_preference: undefined, + }), + mockPrivacyNotice({ + name: "Notice only", + notice_key: "notice_only", + // notice-only should never have has_gpc_flag true, but just in case, + // make sure the expected behavior still holds if it is somehow true + has_gpc_flag: true, + consent_mechanism: ConsentMechanism.NOTICE_ONLY, + default_preference: UserConsentPreference.ACKNOWLEDGE, + current_preference: UserConsentPreference.ACKNOWLEDGE, + }), + mockPrivacyNotice({ + name: "Overridden", + notice_key: "overridden", + has_gpc_flag: true, + consent_mechanism: ConsentMechanism.OPT_OUT, + default_preference: UserConsentPreference.OPT_IN, + current_preference: UserConsentPreference.OPT_IN, + }), + ], + }, + }); + cy.get("#fides-modal-link").click(); + cy.get(".fides-notice-toggle") + .contains("Applied") + .within(() => { + cy.get(".fides-gpc-label").contains("applied"); + }); + cy.get(".fides-notice-toggle") + .contains("Notice only") + .within(() => { + cy.get(".fides-gpc-label").should("not.exist"); + }); + cy.get(".fides-notice-toggle") + .contains("Overridden") + .within(() => { + cy.get(".fides-gpc-label").contains("overridden"); + }); + }); + }); }); diff --git a/clients/privacy-center/cypress/e2e/consent.cy.ts b/clients/privacy-center/cypress/e2e/consent.cy.ts index 2709fbc9b42..e2d06e7e149 100644 --- a/clients/privacy-center/cypress/e2e/consent.cy.ts +++ b/clients/privacy-center/cypress/e2e/consent.cy.ts @@ -1,5 +1,4 @@ -import { CONSENT_COOKIE_NAME, FidesCookie } from "fides-js"; -import { GpcStatus } from "~/features/consent/types"; +import { CONSENT_COOKIE_NAME, FidesCookie, GpcStatus } from "fides-js"; import { ConsentPreferencesWithVerificationCode } from "~/types/api"; import { API_URL } from "../support/constants"; diff --git a/clients/privacy-center/features/consent/GpcMessages.tsx b/clients/privacy-center/features/consent/GpcMessages.tsx index 73898dc698b..396e2c97718 100644 --- a/clients/privacy-center/features/consent/GpcMessages.tsx +++ b/clients/privacy-center/features/consent/GpcMessages.tsx @@ -7,7 +7,7 @@ import { HStack, WarningTwoIcon, } from "@fidesui/react"; -import { GpcStatus } from "./types"; +import { GpcStatus } from "fides-js"; const BADGE_COLORS = { [GpcStatus.NONE]: undefined, diff --git a/clients/privacy-center/features/consent/helpers.ts b/clients/privacy-center/features/consent/helpers.ts index bc57dd311e6..f79d2722f35 100644 --- a/clients/privacy-center/features/consent/helpers.ts +++ b/clients/privacy-center/features/consent/helpers.ts @@ -2,6 +2,7 @@ import { ConsentContext, CookieKeyConsent, resolveLegacyConsentValue, + GpcStatus, } from "fides-js"; import { @@ -9,8 +10,7 @@ import { LegacyConsentConfig, ConsentConfig, } from "~/types/config"; -import { PrivacyNoticeResponseWithUserPreferences } from "~/types/api"; -import { FidesKeyToConsent, GpcStatus } from "./types"; +import { FidesKeyToConsent } from "./types"; /** * Ascertain whether a consentConfig is V1 or V2 based upon the presence of a `button` key @@ -102,24 +102,3 @@ export const getGpcStatus = ({ return GpcStatus.OVERRIDDEN; }; - -export const getGpcStatusFromNotice = ({ - value, - notice, - consentContext, -}: { - value: boolean; - notice: PrivacyNoticeResponseWithUserPreferences; - consentContext: ConsentContext; -}) => { - // If GPC is not enabled, it won't be applied at all. - if (!consentContext.globalPrivacyControl || !notice.has_gpc_flag) { - return GpcStatus.NONE; - } - - if (!value) { - return GpcStatus.APPLIED; - } - - return GpcStatus.OVERRIDDEN; -}; diff --git a/clients/privacy-center/features/consent/types.ts b/clients/privacy-center/features/consent/types.ts index 37df806718a..0d78a746097 100644 --- a/clients/privacy-center/features/consent/types.ts +++ b/clients/privacy-center/features/consent/types.ts @@ -7,12 +7,3 @@ export type FidesKeyToConsent = { export type NoticeHistoryIdToPreference = { [historyId: string]: UserConsentPreference | undefined; }; - -export enum GpcStatus { - /** GPC is not relevant for the consent option. */ - NONE = "none", - /** GPC is enabled and consent matches the configured default. */ - APPLIED = "applied", - /** GPC is enabled but consent has been set to override the configured default. */ - OVERRIDDEN = "overridden", -}