updated CookieConsentBtn.vue

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

View File

@@ -47,40 +47,41 @@
</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 { const tracking = ref(true);
name: "CookieConsentBtn", const { cookies } = useCookies();
setup() { const consent = ref(false);
const tracking = ref(true);
const { cookies } = useCookies();
const consent = ref(false);
const handleConsent = () => { const handleConsent = () => {
window._paq.push(["rememberCookieConsentGiven"]); // eslint-disable-next-line @typescript-eslint/ban-ts-comment
cookies.set("consent", "given", Infinity); // @ts-ignore
window._paq.push(["rememberCookieConsentGiven"]);
cookies.set("consent", "given", Infinity);
if (tracking.value) { if (tracking.value) {
window._paq.push(["rememberConsentGiven"]); // eslint-disable-next-line @typescript-eslint/ban-ts-comment
} // @ts-ignore
consent.value = true; window._paq.push(["rememberConsentGiven"]);
}; }
const handleConsentForget = () => { consent.value = true;
consent.value = true;
};
onMounted(() => {
window._paq.push(["requireCookieConsent"]);
window._paq.push(["trackPageView"]);
if (cookies.get("consent") === "given") consent.value = true;
});
return { handleConsent, handleConsentForget, tracking, consent };
},
}; };
const handleConsentForget = () => {
consent.value = true;
};
onMounted(() => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
window._paq.push(["requireCookieConsent"]);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
window._paq.push(["trackPageView"]);
if (cookies.get("consent") === "given") consent.value = true;
});
</script> </script>
<style scoped> <style scoped>