CookiesConsent.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <template>
  2. <div v-if="layoutStore.isCookieConsentDialogVisible">
  3. <div v-if="!showCustomizationOptions" class="cookie-consent-banner">
  4. <div class="continue-wrapper">
  5. <a class="continue" href="#" @click.prevent="continueWithoutAccepting">
  6. Continuer sans accepter
  7. </a>
  8. <v-icon
  9. size="20"
  10. class="fa-solid fa-arrow-right ml-6"
  11. @click="closePopup()"
  12. />
  13. </div>
  14. <v-row justify="center">
  15. <v-col cols="12">
  16. <img
  17. src="/images/logos/cookies/A_cute_and_beautiful_illustration_of_a_cookie_list-removebg-preview.png"
  18. alt="Cookie"
  19. class="cookie-image"
  20. />
  21. </v-col>
  22. </v-row>
  23. <v-row no-gutters>
  24. <v-col cols="12">
  25. <div class="text">
  26. <p>GESTION DES COOKIES</p>
  27. </div>
  28. </v-col>
  29. </v-row>
  30. <p class="details-cookies" style="padding-left: 20px">
  31. Le site Opentalent.fr utilise des cookies fonctionnels nécessaires à la
  32. navigation du site et d'autres technologies similaire pour plusieurs
  33. objectifs : des cookies d'analyse de l'audience du site, des cookies de
  34. personnalisation de contenu et des cookies publicitaires. Pour plus de
  35. détail, veuillez consulter notre
  36. <NuxtLink to="/politique-de-confidentialite#cookie-policy">
  37. Politique de confidentialité</NuxtLink
  38. >. Vous pouvez ajuster vos préférences en matière de cookies à tout
  39. moment en cliquant sur le bouton "Gérer mes préférences"
  40. </p>
  41. <div class="horizontal-line"></div>
  42. <div class="actions">
  43. <button
  44. class="customize-button"
  45. @click="showCustomizationOptions = true"
  46. >
  47. Gérer mes préférences
  48. </button>
  49. <button class="accept-button" @click="acceptAllCookies">
  50. Tout accepter
  51. </button>
  52. <!-- <button class="decline-button" @click="declineCookies">Refuser</button> -->
  53. </div>
  54. </div>
  55. <v-dialog v-model="showCustomizationOptions" persistent max-width="600px">
  56. <v-card>
  57. <v-row class="headline">
  58. <v-btn
  59. class="close-dialog"
  60. :icon="true"
  61. @click="showCustomizationOptions = false"
  62. >
  63. <v-icon size="20" class="fas fa-times" />
  64. </v-btn>
  65. <v-card-title>Gérer mes préferences</v-card-title>
  66. </v-row>
  67. <p class="gestion-preferences">
  68. Vous pouvez définir vos préférences sur la manière dont vous souhaitez
  69. que vos données soient utilisées en fonction des finalités et des
  70. entreprises tierces ci-dessous. Certains tiers peuvent traiter des
  71. données sur la base d'un intérêt légitime et vous pouvez choisir de
  72. vous désinscrire.
  73. </p>
  74. <v-container class="preferences-actions text-end">
  75. <button class="decline-button" @click="declineCookies">
  76. Tout refuser
  77. </button>
  78. <button class="accept-button" @click="acceptAllCookies">
  79. Tout accepter
  80. </button>
  81. </v-container>
  82. <v-card-text>
  83. <h4>Des cookies tiers permettant de réaliser des statistiques</h4>
  84. <v-row align="center">
  85. <v-col cols="auto">
  86. <v-switch
  87. v-model="cookiesPreferences.analyticsConsent"
  88. label="Mesure d'audience"
  89. hide-details
  90. color="green"
  91. inset
  92. />
  93. </v-col>
  94. <v-col>{{
  95. cookiesPreferences.analyticsConsent ? 'Autorisé' : 'Non-autorisé'
  96. }}</v-col>
  97. </v-row>
  98. <p>
  99. Ces cookies nous permettent d'établir des statistiques, des volumes
  100. de fréquentation et d'utilisation des divers éléments de notre site,
  101. nous permettant d’optimiser son fonctionnement.
  102. </p>
  103. <h4 class="mt-6">Des cookies tiers à visée publicitaire</h4>
  104. <v-row align="center">
  105. <v-col cols="auto">
  106. <v-switch
  107. v-model="cookiesPreferences.advertisingConsent"
  108. label="Suivi publicitaire"
  109. hide-details
  110. color="green"
  111. inset
  112. />
  113. </v-col>
  114. <v-col>{{
  115. cookiesPreferences.advertisingConsent
  116. ? 'Autorisé'
  117. : 'Non-autorisé'
  118. }}</v-col>
  119. </v-row>
  120. <p>
  121. Autoriser le stockage et l'accès aux cookies pour diffuser des
  122. annonces publicitaires personnalisées. Cela permet de vous montrer
  123. des publicités plus pertinentes.
  124. </p>
  125. <v-row align="center">
  126. <v-col cols="auto">
  127. <v-switch
  128. v-model="cookiesPreferences.adUserDataConsent"
  129. label="Données Utilisateur pour la Publicité"
  130. hide-details
  131. color="green"
  132. inset
  133. />
  134. </v-col>
  135. <v-col>{{
  136. cookiesPreferences.advertisingConsent
  137. ? 'Autorisé'
  138. : 'Non-autorisé'
  139. }}</v-col>
  140. </v-row>
  141. <p>
  142. Autoriser la collecte et l'utilisation de vos données personnelles
  143. (comme votre adresse e-mail ou numéro de téléphone) pour créer des
  144. profils de publicité personnalisés et améliorer le ciblage des
  145. annonces.
  146. </p>
  147. <v-row align="center">
  148. <v-col cols="auto">
  149. <v-switch
  150. v-model="cookiesPreferences.adPersonalizationConsent"
  151. label="Personnalisation des annonces"
  152. hide-details
  153. color="green"
  154. inset
  155. />
  156. </v-col>
  157. <v-col>{{
  158. cookiesPreferences.advertisingConsent
  159. ? 'Autorisé'
  160. : 'Non-autorisé'
  161. }}</v-col>
  162. </v-row>
  163. <p>
  164. Autoriser la personnalisation des annonces en fonction de vos
  165. préférences et de votre comportement de navigation pour vous offrir
  166. des publicités plus pertinentes et ciblées.
  167. </p>
  168. </v-card-text>
  169. <v-card-actions>
  170. <v-btn color="secondary" @click="showCustomizationOptions = false">
  171. Fermer
  172. </v-btn>
  173. <v-spacer />
  174. <button class="accept-button" @click="saveCookiesPreferences">
  175. Sauvegarder
  176. </button>
  177. </v-card-actions>
  178. </v-card>
  179. </v-dialog>
  180. </div>
  181. <v-alert
  182. v-model="showNotification"
  183. title="Confirmation"
  184. type="warning"
  185. width="400"
  186. closable
  187. transition="fade-transition"
  188. density="compact"
  189. class="alert"
  190. >
  191. Vous avez refusé nos cookies. Si vous le souhaitez, vous pouvez encore
  192. modifier votre décision en
  193. <a href="#" @click="showPopup()">cliquant ici</a>.
  194. </v-alert>
  195. </template>
  196. <script setup lang="ts">
  197. import { onMounted, type Ref, ref } from 'vue'
  198. import { useCookies } from 'vue3-cookies'
  199. import { COOKIE_CONSENT_CHOICE } from '~/types/enum/enums'
  200. import type { CookiesPreferences } from '~/types/interface'
  201. const layoutStore = useLayoutStore()
  202. const { cookies } = useCookies()
  203. const showCustomizationOptions = ref(false)
  204. const showNotification = ref(false)
  205. const { gtag } = useGtag()
  206. /**
  207. * Cookies options
  208. */
  209. const cookiesPreferences: Ref<CookiesPreferences> = ref({
  210. analyticsConsent: true,
  211. advertisingConsent: true,
  212. adUserDataConsent: true,
  213. adPersonalizationConsent: true,
  214. })
  215. const showPopup = () => {
  216. layoutStore.setIsCookieConsentDialogVisible(true)
  217. }
  218. const closePopup = () => {
  219. layoutStore.setIsCookieConsentDialogVisible(false)
  220. showCustomizationOptions.value = false
  221. showNotification.value = false
  222. }
  223. const notify = () => {
  224. showNotification.value = true
  225. // Hide the notification after 1 minute
  226. setTimeout(() => {
  227. showNotification.value = false
  228. }, 60000)
  229. }
  230. const setupCookies = (
  231. choice: COOKIE_CONSENT_CHOICE,
  232. analyticsConsent: boolean,
  233. advertisingConsent: boolean,
  234. adUserDataConsent: boolean,
  235. adPersonalizationConsent: boolean,
  236. duration: number = 365
  237. ) => {
  238. cookies.set('cookie_consent', choice, duration + 'd')
  239. cookiesPreferences.value.analyticsConsent = analyticsConsent
  240. cookies.set('analytics_consent', analyticsConsent.toString(), duration + 'd')
  241. cookiesPreferences.value.advertisingConsent = advertisingConsent
  242. cookies.set(
  243. 'advertising_consent',
  244. advertisingConsent.toString(),
  245. duration + 'd'
  246. )
  247. cookiesPreferences.value.adUserDataConsent = adUserDataConsent
  248. cookies.set(
  249. 'ad_user_data_consent',
  250. adUserDataConsent.toString(),
  251. duration + 'd'
  252. )
  253. cookiesPreferences.value.adPersonalizationConsent = adPersonalizationConsent
  254. cookies.set(
  255. 'ad_personalization_consent',
  256. adPersonalizationConsent.toString(),
  257. duration + 'd'
  258. )
  259. gtag('consent', 'update', {
  260. analytics_storage: analyticsConsent ? 'granted' : 'denied',
  261. ad_storage: analyticsConsent ? 'granted' : 'denied',
  262. ad_user_data: adUserDataConsent ? 'granted' : 'denied',
  263. ad_personalization: adPersonalizationConsent ? 'granted' : 'denied',
  264. })
  265. // Store consent date and status
  266. localStorage.setItem(
  267. 'cookie_consent',
  268. JSON.stringify({
  269. date: new Date(),
  270. consent: {
  271. analyticsConsent,
  272. advertisingConsent,
  273. adUserDataConsent,
  274. adPersonalizationConsent,
  275. },
  276. })
  277. )
  278. }
  279. /**
  280. * Accept and setup all the cookies and close the popup
  281. */
  282. const acceptAllCookies = () => {
  283. setupCookies(COOKIE_CONSENT_CHOICE.ACCEPTED, true, true, true, true)
  284. closePopup()
  285. }
  286. /**
  287. * Refuse all the cookies, set up the cookie_consent cookie and close the popup
  288. */
  289. const declineCookies = () => {
  290. setupCookies(COOKIE_CONSENT_CHOICE.DECLINED, false, false, false, false, 7)
  291. notify()
  292. closePopup()
  293. }
  294. /**
  295. * Set up the cookies following user preferences and close the popup
  296. */
  297. const saveCookiesPreferences = () => {
  298. setupCookies(
  299. COOKIE_CONSENT_CHOICE.CUSTOMIZED,
  300. cookiesPreferences.value.analyticsConsent,
  301. cookiesPreferences.value.advertisingConsent,
  302. cookiesPreferences.value.adUserDataConsent,
  303. cookiesPreferences.value.adPersonalizationConsent
  304. )
  305. closePopup()
  306. }
  307. /**
  308. * Continue without accepting cookies
  309. */
  310. const continueWithoutAccepting = () => {
  311. closePopup()
  312. }
  313. const loadActivePreferences = () => {
  314. cookiesPreferences.value.analyticsConsent =
  315. cookies.get('analytics_consent') !== 'false'
  316. cookiesPreferences.value.advertisingConsent =
  317. cookies.get('advertising_consent') !== 'false'
  318. cookiesPreferences.value.adUserDataConsent =
  319. cookies.get('ad_user_data_consent') !== 'false'
  320. cookiesPreferences.value.adPersonalizationConsent =
  321. cookies.get('ad_personalization_consent') !== 'false'
  322. }
  323. /**
  324. * Check if the user has already accepted the cookies when page is mounted
  325. */
  326. onMounted(() => {
  327. const cookieConsent = cookies.get('cookie_consent')
  328. if (!cookieConsent) {
  329. showPopup()
  330. }
  331. loadActivePreferences()
  332. })
  333. </script>
  334. <style scoped lang="scss">
  335. .gestion-preferences {
  336. font-size: 1.2rem;
  337. font-weight: 500;
  338. margin-bottom: 10px;
  339. padding: 20px;
  340. text-align: justify;
  341. }
  342. .preferences-actions {
  343. overflow: visible;
  344. }
  345. .headline {
  346. font-size: 1.5rem;
  347. font-weight: 500;
  348. margin: 0 0 10px 0;
  349. background-color: var(--secondary-color);
  350. color: var(--on-secondary-color);
  351. text-transform: uppercase;
  352. padding: 15px;
  353. }
  354. .cookie-consent-banner {
  355. background: var(--neutral-color);
  356. position: fixed;
  357. bottom: 10px;
  358. left: 15px;
  359. max-width: 550px;
  360. z-index: 1000 !important;
  361. display: flex;
  362. flex-direction: column;
  363. align-items: center;
  364. box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  365. border-radius: 15px;
  366. padding: 20px;
  367. }
  368. .cookie-image {
  369. width: 150px;
  370. margin: 0;
  371. }
  372. .text {
  373. padding-top: 10px;
  374. padding-bottom: 0;
  375. font-weight: 600;
  376. font-size: 1.3rem;
  377. text-align: center;
  378. }
  379. .details-cookies {
  380. padding: 10px;
  381. text-align: justify;
  382. }
  383. .horizontal-line {
  384. width: 90%;
  385. height: 1px;
  386. background-color: var(--neutral-color-alt-strong);
  387. margin-top: 10px;
  388. margin-bottom: 10px;
  389. }
  390. .actions {
  391. margin-top: 10px;
  392. margin-bottom: 10px;
  393. display: flex;
  394. justify-content: center;
  395. }
  396. .accept-button,
  397. .customize-button {
  398. background-color: var(--on-primary-color-alt);
  399. border: none;
  400. padding: 10px 20px;
  401. margin: 5px;
  402. cursor: pointer;
  403. }
  404. .decline-button {
  405. border: 1px solid var(--on-neutral-color);
  406. padding: 10px 20px;
  407. margin: 5px;
  408. cursor: pointer;
  409. }
  410. .accept-button:hover,
  411. .customize-button:hover {
  412. background-color: var(--on-primary-color-alt);
  413. }
  414. .cookie-description {
  415. margin: 0;
  416. font-size: 0.875rem;
  417. color: var(--on-neutral-color-light);
  418. }
  419. .custom-switch .v-input--selection-controls__ripple .v-ripple__container {
  420. background-color: var(--v-primary-color);
  421. }
  422. .custom-switch,
  423. .v-input--selection-controls__ripple--active,
  424. .v-ripple__container {
  425. background-color: var(--v-primary-darken4);
  426. }
  427. .custom-switch .v-input--selection-controls__input {
  428. --v-theme-primary: var(--v-primary-base);
  429. --v-theme-primary-lighten4: var(--v-primary-lighten4);
  430. --v-theme-primary-darken4: var(--v-primary-darken4);
  431. }
  432. .custom-switch,
  433. .v-input--selection-controls__input,
  434. input:checked,
  435. .v-input--selection-controls__ripple,
  436. .v-ripple__container {
  437. background-color: var(--v-primary-darken4);
  438. }
  439. .custom-switch,
  440. .v-input--selection-controls__input,
  441. input:checked,
  442. .v-input--selection-controls__ripple,
  443. .v-ripple__container,
  444. .v-ripple__animation {
  445. background-color: var(--v-primary-darken4);
  446. }
  447. :deep(.v-switch__track) {
  448. background-color: var(--warning-color);
  449. }
  450. .close-dialog {
  451. background: none !important;
  452. box-shadow: none !important;
  453. }
  454. .continue {
  455. font-size: 0.9rem;
  456. font-weight: 500;
  457. cursor: pointer;
  458. text-decoration: none !important;
  459. color: var(--on-neutral-color);
  460. }
  461. .continue-wrapper {
  462. display: flex;
  463. justify-content: end;
  464. align-items: center;
  465. margin-left: auto;
  466. }
  467. :deep(.v-switch .v-label) {
  468. opacity: 0.8;
  469. }
  470. .alert {
  471. position: fixed;
  472. bottom: 20px;
  473. right: 20px;
  474. z-index: 1000;
  475. a {
  476. color: var(--on-primary-color);
  477. font-weight: 700;
  478. text-decoration: none;
  479. }
  480. a:hover {
  481. text-decoration: underline;
  482. }
  483. }
  484. </style>