Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Fix/yarn lint #192

Merged
merged 6 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
},
{
"path": "standalone/consent-manager.js",
"limit": "46 KB"
"limit": "50 KB"
}
],
"husky": {
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/consent-manager-builder/analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ describe('analytics', () => {
window = {} as WindowWithAJS
wd = window
wd.analytics = {
/*eslint-disable */
track: (_event, _properties, _optionsWithConsent, _callback) => {},
addSourceMiddleware: (_middleware: Middleware) => {}
/*eslint-enable */
}
})

Expand Down
75 changes: 37 additions & 38 deletions src/consent-manager/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,43 @@ const Container: React.FC<ContainerProps> = props => {
functionalDestinations
} = normalizeDestinations(props.destinations)

const onAcceptAll = () => {
props.setPreferences(props.preferences)
props.saveConsent()
}

const onDenyAll = () => {
const falsePreferences = Object.keys(props.preferences).reduce((acc, category) => {
acc[category] = false
return acc
}, {})

props.setPreferences(falsePreferences)
return props.saveConsent()
}

const onClose = () => {
if (props.closeBehavior === undefined || props.closeBehavior === CloseBehavior.DISMISS) {
return toggleBanner(false)
}

if (props.closeBehavior === CloseBehavior.ACCEPT) {
return onAcceptAll()
}

if (props.closeBehavior === CloseBehavior.DENY) {
return onDenyAll()
}

// closeBehavior is a custom function
const customClosePreferences = props.closeBehavior(props.preferences)
props.setPreferences(customClosePreferences)
props.saveConsent()
return toggleBanner(false)
}

const showDialog = () => toggleDialog(true)

const handleBodyClick = e => {
// Do nothing if no new implicit consent needs to be saved
if (
Expand All @@ -117,8 +154,6 @@ const Container: React.FC<ContainerProps> = props => {
}
}

const showDialog = () => toggleDialog(true)

React.useEffect(() => {
emitter.on('openDialog', showDialog)
if (props.isConsentRequired && props.implyConsentOnInteraction) {
Expand All @@ -137,41 +172,6 @@ const Container: React.FC<ContainerProps> = props => {
}
}, [isDialogOpen])

const onAcceptAll = () => {
props.setPreferences(props.preferences)
props.saveConsent()
}

const onDenyAll = () => {
const falsePreferences = Object.keys(props.preferences).reduce((acc, category) => {
acc[category] = false
return acc
}, {})

props.setPreferences(falsePreferences)
return props.saveConsent()
}

const onClose = () => {
if (props.closeBehavior === undefined || props.closeBehavior === CloseBehavior.DISMISS) {
return toggleBanner(false)
}

if (props.closeBehavior === CloseBehavior.ACCEPT) {
return onAcceptAll()
}

if (props.closeBehavior === CloseBehavior.DENY) {
return onDenyAll()
}

// closeBehavior is a custom function
const customClosePreferences = props.closeBehavior(props.preferences)
props.setPreferences(customClosePreferences)
props.saveConsent()
return toggleBanner(false)
}

const handleCategoryChange = (category: string, value: boolean) => {
props.setPreferences({
[category]: value
Expand All @@ -180,7 +180,6 @@ const Container: React.FC<ContainerProps> = props => {

const handleSave = () => {
toggleDialog(false)

props.saveConsent()
}

Expand Down
24 changes: 17 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3566,11 +3566,16 @@ builtin-status-codes@^3.0.0:
resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8"
integrity sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=

bytes@3.1.0, bytes@^3.0.0:
bytes@3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6"
integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==

bytes@^3.0.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.1.tgz#3f018291cb4cbad9accb6e6970bca9c8889e879a"
integrity sha512-dWe4nWO/ruEOY7HkUJ5gFt1DCFV9zPRoJr8pV0/ASQermOZjtq8jMjOprC0Kd10GLN+l7xaUPvxzJFWtxGu8Fg==

c8@^7.6.0:
version "7.9.0"
resolved "https://registry.yarnpkg.com/c8/-/c8-7.9.0.tgz#e63b9a22c8b4adbf6a8c8cb6194ee086b3e13c24"
Expand Down Expand Up @@ -3739,9 +3744,9 @@ caniuse-api@^1.5.2:
lodash.uniq "^4.5.0"

caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639:
version "1.0.30001258"
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30001258.tgz#a6de3ef3f89a5826bccdbf7674cbf5c081b86265"
integrity sha512-2Gc5901CmVN8HEswe3qJup7Mx34TrPsN+PKV9T7/5UUEEZxdsotLZDXYdWKvHBHsvVCGe9+39txJnfOkkW33qw==
version "1.0.30001282"
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30001282.tgz#a6085d27dcdc7a99b0d280c2dcb22e6fb8fd73aa"
integrity sha512-czsWYzaRcSfPVTWzxwl6xo6JdVPTTShJoWjAO7ZYArI3oKFe7COLk3G9k/WVysOCEs5Jiu66Ly+8nRLlj85vdw==

caniuse-lite@^1.0.30000989, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001254:
version "1.0.30001258"
Expand Down Expand Up @@ -4119,12 +4124,12 @@ color-convert@^2.0.1:
dependencies:
color-name "~1.1.4"

color-name@1.1.3, color-name@^1.0.0:
color-name@1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=

color-name@~1.1.4:
color-name@^1.0.0, color-name@~1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
Expand Down Expand Up @@ -5096,7 +5101,12 @@ ejs@^2.5.7, ejs@^2.7.4:
resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.7.4.tgz#48661287573dcc53e366c7a1ae52c3a120eec9ba"
integrity sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==

electron-to-chromium@^1.2.7, electron-to-chromium@^1.3.247, electron-to-chromium@^1.3.830:
electron-to-chromium@^1.2.7:
version "1.3.900"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.900.tgz#5be2c5818a2a012c511b4b43e87b6ab7a296d4f5"
integrity sha512-SuXbQD8D4EjsaBaJJxySHbC+zq8JrFfxtb4GIr4E9n1BcROyMcRrJCYQNpJ9N+Wjf5mFp7Wp0OHykd14JNEzzQ==

electron-to-chromium@^1.3.247, electron-to-chromium@^1.3.830:
version "1.3.843"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.843.tgz#671489bd2f59fd49b76adddc1aa02c88cd38a5c0"
integrity sha512-OWEwAbzaVd1Lk9MohVw8LxMXFlnYd9oYTYxfX8KS++kLLjDfbovLOcEEXwRhG612dqGQ6+44SZvim0GXuBRiKg==
Expand Down