1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-06-23 01:36:47 +02:00
market/src/@context/CookieConsent.tsx

142 lines
3.7 KiB
TypeScript
Raw Normal View History

GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
import React, {
useContext,
useState,
createContext,
useEffect,
ReactNode,
ReactElement
} from 'react'
2021-10-13 18:48:59 +02:00
import { deleteCookie, getCookieValue, setCookie } from '@utils/cookies'
import { UseGdprMetadata, useGdprMetadata } from '@hooks/useGdprMetadata'
Various fixes in the pool component (#1327) * remove legacy check to prevent rug pull Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * add expected output to remove Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove console.logs Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix max calculations Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactors Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * temp fixes for build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * local calc for pice and liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove var Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix profile liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * global context, opc fee Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * comment Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactor global context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove nesting from market context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix undefined appConfig Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * direct import of appConfig & siteContent * this never changes on run time, so we should never have to wait for it and have it in js bundle at all times * in utility methods, import directly * for components, import directly in MarketMetadata context and pass through * remove screen CSS fixes * put back auto-fetching indicator, move manual refresh action behind debug Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-04-22 02:38:35 +02:00
import { useMarketMetadata } from './MarketMetadata'
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
export enum CookieConsentStatus {
NOT_AVAILABLE = -1,
APPROVED = 0,
REJECTED = 1
}
export interface ConsentStatus {
[name: string]: CookieConsentStatus
}
interface ConsentProviderValue {
cookies: UseGdprMetadata['optionalCookies']
cookieConsentStatus: ConsentStatus
setConsentStatus: (cookieName: string, status: CookieConsentStatus) => void
resetConsentStatus: (status?: CookieConsentStatus) => void
}
const ConsentContext = createContext({} as ConsentProviderValue)
function ConsentProvider({ children }: { children: ReactNode }): ReactElement {
const cookies = useGdprMetadata()
Various fixes in the pool component (#1327) * remove legacy check to prevent rug pull Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * add expected output to remove Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove console.logs Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix max calculations Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactors Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * temp fixes for build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * local calc for pice and liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove var Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix profile liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * global context, opc fee Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * comment Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactor global context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove nesting from market context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix undefined appConfig Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * direct import of appConfig & siteContent * this never changes on run time, so we should never have to wait for it and have it in js bundle at all times * in utility methods, import directly * for components, import directly in MarketMetadata context and pass through * remove screen CSS fixes * put back auto-fetching indicator, move manual refresh action behind debug Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-04-22 02:38:35 +02:00
const { appConfig } = useMarketMetadata()
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
const [consentStatus, setConsentStatus] = useState({} as ConsentStatus)
function resetConsentStatus(status = CookieConsentStatus.NOT_AVAILABLE) {
const resetCookieConsent = {} as ConsentStatus
cookies.optionalCookies?.map((cookie) => {
deleteCookie(cookie.cookieName)
resetCookieConsent[cookie.cookieName] = status
return status
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
})
setConsentStatus(resetCookieConsent)
}
function setCookieConsentStatus(
cookieName: string,
status: CookieConsentStatus
) {
setConsentStatus({ ...consentStatus, [cookieName]: status })
}
function handleAccept(cookieName: string) {
setCookie(cookieName, true)
switch (cookieName) {
case 'AnalyticsCookieConsent':
break
default:
break
// Add your specific logic here
// e.g.
/* function handleAnalytics() {
ReactGA.initialize(analyticsId)
ReactGA.pageview(window.location.pathname + window.location.search)
} */
}
}
function handleReject(cookieName: string) {
setCookie(cookieName, false)
switch (cookieName) {
case 'AnalyticsCookieConsent':
break
default:
break
// Add your specific logic here
}
}
useEffect(() => {
Various fixes in the pool component (#1327) * remove legacy check to prevent rug pull Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * add expected output to remove Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove console.logs Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix max calculations Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactors Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * temp fixes for build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * local calc for pice and liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove var Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix profile liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * global context, opc fee Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * comment Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactor global context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove nesting from market context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix undefined appConfig Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * direct import of appConfig & siteContent * this never changes on run time, so we should never have to wait for it and have it in js bundle at all times * in utility methods, import directly * for components, import directly in MarketMetadata context and pass through * remove screen CSS fixes * put back auto-fetching indicator, move manual refresh action behind debug Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-04-22 02:38:35 +02:00
if (appConfig?.privacyPreferenceCenter !== 'true') return
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
const initialValues = {} as ConsentStatus
cookies.optionalCookies?.map((cookie) => {
const cookieValue = getCookieValue(cookie.cookieName)
switch (cookieValue) {
case 'true':
initialValues[cookie.cookieName] = CookieConsentStatus.APPROVED
break
case 'false':
initialValues[cookie.cookieName] = CookieConsentStatus.REJECTED
break
default:
initialValues[cookie.cookieName] = CookieConsentStatus.NOT_AVAILABLE
break
}
return initialValues
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
})
setConsentStatus(initialValues)
Various fixes in the pool component (#1327) * remove legacy check to prevent rug pull Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove old prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * add expected output to remove Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove console.logs Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix max calculations Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactors Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * temp fixes for build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * local calc for pice and liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove var Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix profile liquidity Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * global context, opc fee Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * comment Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * various fixes Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactor global context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove nesting from market context Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix undefined appConfig Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * direct import of appConfig & siteContent * this never changes on run time, so we should never have to wait for it and have it in js bundle at all times * in utility methods, import directly * for components, import directly in MarketMetadata context and pass through * remove screen CSS fixes * put back auto-fetching indicator, move manual refresh action behind debug Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2022-04-22 02:38:35 +02:00
}, [cookies.optionalCookies, appConfig])
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
useEffect(() => {
// eslint-disable-next-line array-callback-return
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
Object.keys(consentStatus).map((cookieName) => {
switch (consentStatus[cookieName]) {
case CookieConsentStatus.APPROVED:
handleAccept(cookieName)
break
case CookieConsentStatus.REJECTED:
handleReject(cookieName)
break
}
})
}, [consentStatus])
return (
<ConsentContext.Provider
value={
{
cookies: cookies.optionalCookies || [],
cookieConsentStatus: consentStatus,
setConsentStatus: setCookieConsentStatus,
resetConsentStatus
} as ConsentProviderValue
}
>
{children}
</ConsentContext.Provider>
)
}
const useConsent = (): ConsentProviderValue => useContext(ConsentContext)
export { ConsentProvider, useConsent, ConsentContext }
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
export default ConsentProvider