updated CookieConsentBtn.vue

This commit is contained in:
2022-03-25 16:09:58 +01:00
parent 70fb352d7f
commit f6dd2ea1c4

View File

@@ -47,22 +47,23 @@
</div> </div>
</template> </template>
<script> <script setup lang="ts">
import { onMounted, ref } from "vue"; import { onMounted, ref } from "vue";
import { useCookies } from "vue3-cookies"; import { useCookies } from "vue3-cookies";
export default {
name: "CookieConsentBtn",
setup() {
const tracking = ref(true); const tracking = ref(true);
const { cookies } = useCookies(); const { cookies } = useCookies();
const consent = ref(false); const consent = ref(false);
const handleConsent = () => { const handleConsent = () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
window._paq.push(["rememberCookieConsentGiven"]); window._paq.push(["rememberCookieConsentGiven"]);
cookies.set("consent", "given", Infinity); cookies.set("consent", "given", Infinity);
if (tracking.value) { if (tracking.value) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
window._paq.push(["rememberConsentGiven"]); window._paq.push(["rememberConsentGiven"]);
} }
consent.value = true; consent.value = true;
@@ -72,15 +73,15 @@ export default {
}; };
onMounted(() => { onMounted(() => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
window._paq.push(["requireCookieConsent"]); window._paq.push(["requireCookieConsent"]);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
window._paq.push(["trackPageView"]); window._paq.push(["trackPageView"]);
if (cookies.get("consent") === "given") consent.value = true; if (cookies.get("consent") === "given") consent.value = true;
}); });
return { handleConsent, handleConsentForget, tracking, consent };
},
};
</script> </script>
<style scoped> <style scoped>