Skip to content

Commit

Permalink
Merge pull request #64 from gluebi/63-use-query-params-for-consent-if…
Browse files Browse the repository at this point in the history
…-available

63 use query params for consent if available
  • Loading branch information
gluebi authored Feb 22, 2023
2 parents c561c21 + 7908a1a commit eecdf6c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-cookie-comply-with-reject",
"description": "A Vue 3 component to handle cookie acceptance on your website",
"version": "0.2.4",
"version": "0.2.5",
"files": [
"dist"
],
Expand All @@ -26,7 +26,8 @@
"eslint-plugin-vue": "^9.9.0",
"prettier": "^2.8.4",
"vite": "^4.1.3",
"vue": "^3.2.47"
"vue": "^3.2.47",
"vue-router": "^4.1.6"
},
"peerDependencies": {
"vue": "3.2"
Expand Down
21 changes: 19 additions & 2 deletions src/components/CookieComply.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ import { getConsentValuesFromStorage } from '../shared/storageUtils';
import CookieComplyModal from './CookieComplyModal.vue';
import CookieComplyButton from './CookieComplyButton.vue';
import { scrollLock as vScrollLock } from '../directives/scroll-lock';
import { useRoute } from "vue-router";
interface Props {
headerTitle?: string
Expand Down Expand Up @@ -149,12 +150,28 @@ const emit = defineEmits<Emits>()
const showCookieComply = ref(true)
const isModalOpen = ref(false)
const route = useRoute()
onMounted((): void => {
if (localStorage.getItem('cookie-comply')) {
checkValues()
})
const checkValues = (): void => {
if ('consent' in route.query || localStorage.getItem('cookie-comply')) {
showCookieComply.value = false;
}
if ('consent' in route.query && typeof route.query.consent === 'string') {
let consentValues: Array<string>
try {
consentValues = JSON.parse(route.query.consent)
} catch (error) {
console.log('Error parsing consent values.');
}
onSave(consentValues)
}
emit('on-cookie-comply-mount', getConsentValuesFromStorage());
})
}
const handleAcceptAll = (): void => {
showCookieComply.value = false;
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
"@vue/compiler-dom" "3.2.47"
"@vue/shared" "3.2.47"

"@vue/devtools-api@^6.4.5":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.5.0.tgz#98b99425edee70b4c992692628fa1ea2c1e57d07"
integrity sha512-o9KfBeaBmCKl10usN4crU53fYtC1r7jJwdGKjPT24t348rHxgfpZ0xL3Xm/gLUYnc0oTp8LAmrxOeLyu6tbk2Q==

"@vue/[email protected]":
version "3.2.47"
resolved "https://registry.yarnpkg.com/@vue/reactivity-transform/-/reactivity-transform-3.2.47.tgz#e45df4d06370f8abf29081a16afd25cffba6d84e"
Expand Down Expand Up @@ -1071,6 +1076,13 @@ vue-eslint-parser@^9.0.1:
lodash "^4.17.21"
semver "^7.3.6"

vue-router@^4.1.6:
version "4.1.6"
resolved "https://registry.yarnpkg.com/vue-router/-/vue-router-4.1.6.tgz#b70303737e12b4814578d21d68d21618469375a1"
integrity sha512-DYWYwsG6xNPmLq/FmZn8Ip+qrhFEzA14EI12MsMgVxvHFDYvlr4NXpVF5hrRH1wVcDP8fGi5F4rxuJSl8/r+EQ==
dependencies:
"@vue/devtools-api" "^6.4.5"

vue@^3.2.47:
version "3.2.47"
resolved "https://registry.yarnpkg.com/vue/-/vue-3.2.47.tgz#3eb736cbc606fc87038dbba6a154707c8a34cff0"
Expand Down

0 comments on commit eecdf6c

Please sign in to comment.