@bytebrand/fe-ui-core 4.2.130 → 4.2.132

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/fe-ui-core",
3
- "version": "4.2.130",
3
+ "version": "4.2.132",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -7,10 +7,11 @@ interface IMaterialSwitch {
7
7
  disabled?: boolean;
8
8
  onChange: (value: boolean) => void;
9
9
  label?: any;
10
+ sx?: any;
10
11
  labelPlacement?: 'bottom' | 'end' | 'start' | 'top';
11
12
  }
12
13
 
13
- const MaterialSwitch = ({ disabled, label, onChange, value = false, labelPlacement }: IMaterialSwitch) => {
14
+ const MaterialSwitch = ({ disabled, label, onChange, value = false, sx, labelPlacement }: IMaterialSwitch) => {
14
15
  const [checked, setChecked] = useState(value);
15
16
  const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
16
17
  setChecked(event.target.checked);
@@ -19,6 +20,7 @@ const MaterialSwitch = ({ disabled, label, onChange, value = false, labelPlaceme
19
20
  return (
20
21
  <FormControlLabel
21
22
  label={label}
23
+ sx={sx}
22
24
  labelPlacement={labelPlacement}
23
25
  control={
24
26
  <Switch
@@ -67,10 +67,17 @@
67
67
 
68
68
  .switchBlock
69
69
  display: flex
70
- justify-content: space-between
71
70
  align-items: center
72
71
  font-size: 12px
73
72
  line-height: 15px
74
73
  letter-spacing: 1px
75
74
  color: rgba(76, 78, 100, 0.87)
76
- text-align: left
75
+ text-align: left
76
+
77
+ .switchBlockTitle
78
+ width: 140px;
79
+
80
+ .switchBlockLink
81
+ color: rgba(76, 78, 100, 0.87);
82
+ text-decoration-line: underline;
83
+ font-size: 8px;
@@ -1,12 +1,12 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import _merge from 'lodash/merge';
3
3
  import classNames from 'classnames';
4
-
4
+ import _get from 'lodash/get';
5
5
  import IconSVG from '../../../IconSVG/IconSVG';
6
6
  import Button from '../../../Button/Button';
7
7
  import MaterialAccordionGroup from '../../../MaterialAccordionGroup/MaterialAccordionGroup';
8
8
  import MaterialSwitch from '../../../MaterialSwitch/MaterialSwitch';
9
- import { COOKIE_SCHEMA } from '../../../../../framework/constants/common';
9
+ import { COOKIE_SCHEMA, COOKIE_SCHEMA_LINKS } from '../../../../../framework/constants/common';
10
10
  import { updateCookieList } from '../../../../../framework/utils/CommonUtils';
11
11
 
12
12
  import styles from './ManageCookieModal.styl';
@@ -28,8 +28,14 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
28
28
 
29
29
  useEffect(
30
30
  () => {
31
- const newAnalyticsSwitches = Object.keys(COOKIE_SCHEMA.analytics).reduce((acc, item) => ({ ...acc, [item]: true }), {});
32
- const newMarketingSwitches = Object.keys(COOKIE_SCHEMA.marketing).reduce((acc, item) => ({ ...acc, [item]: true }), {});
31
+ const newAnalyticsSwitches = Object.values(COOKIE_SCHEMA.analytics)
32
+ .reduce((acc, val) => acc.concat(val), [])
33
+ .reduce((acc, item) => ({ ...acc, [item]: true }), {});
34
+
35
+ const newMarketingSwitches = Object.values(COOKIE_SCHEMA.marketing)
36
+ .reduce((acc, val) => acc.concat(val), [])
37
+ .reduce((acc, item) => ({ ...acc, [item]: true }), {});
38
+
33
39
  setAnalyticsSwitches(newAnalyticsSwitches);
34
40
  setMarketingSwitches(newMarketingSwitches);
35
41
  },
@@ -37,13 +43,17 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
37
43
  );
38
44
 
39
45
  const onHandleAnalyticsSwitchValue = (value: boolean) => {
40
- const newAnalyticsSwitches = Object.keys(analyticsSwitches).reduce((acc, item) => ({ ...acc, [item]: value }), {});
46
+ const newAnalyticsSwitches = Object.values(COOKIE_SCHEMA.analytics)
47
+ .reduce((acc, val) => acc.concat(val), [])
48
+ .reduce((acc, item) => ({ ...acc, [item]: value }), {});
41
49
  setAnalyticsSwitches(newAnalyticsSwitches);
42
50
  setAnalyticsMasterSwitch(value);
43
51
  };
44
52
 
45
53
  const onHandleMarketingSwitchValue = (value: boolean) => {
46
- const newMarketingSwitches = Object.keys(marketingSwitches).reduce((acc, item) => ({ ...acc, [item]: value }), {});
54
+ const newMarketingSwitches = Object.values(COOKIE_SCHEMA.marketing)
55
+ .reduce((acc, val) => acc.concat(val), [])
56
+ .reduce((acc, item) => ({ ...acc, [item]: value }), {});
47
57
  setMarketingSwitches(newMarketingSwitches);
48
58
  setMarketingMasterSwitch(value);
49
59
  };
@@ -73,6 +83,22 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
73
83
  updateCookieList(handleSentryInit);
74
84
  toggleModal();
75
85
  };
86
+
87
+ const onHandleChangeInnerSwitchAnalytics = (cookiesFromCategory: [key: string], isChecked: boolean) => {
88
+ const updatedSwitches = { ...analyticsSwitches };
89
+ for (const item of cookiesFromCategory) {
90
+ updatedSwitches[item] = !isChecked
91
+ }
92
+ setAnalyticsSwitches(updatedSwitches);
93
+ };
94
+
95
+ const onHandleChangeInnerSwitchMarketing = (cookiesFromCategory: [key: string], isChecked: boolean) => {
96
+ const updatedSwitches = { ...marketingSwitches };
97
+ for (const item of cookiesFromCategory) {
98
+ updatedSwitches[item] = !isChecked
99
+ }
100
+ setMarketingSwitches(updatedSwitches);
101
+ };
76
102
 
77
103
  return (
78
104
  <div className={styles.modalWrapper}>
@@ -87,12 +113,16 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
87
113
  switchProps={necessarySwitchProps}
88
114
  >
89
115
  <span>Wir verwenden Browser-Cookies, die notwendig sind, damit die Website wie vorgesehen funktioniert. Beispiel: Wir speichern Ihre Präferenzen bei der Datenerfassung auf der Website, damit wir sie berücksichtigen können, wenn Sie auf unsere Website zurückkehren. Sie können diese Cookies in den Einstellungen Ihres Browsers deaktivieren, aber wenn Sie dies tun, funktioniert die Website möglicherweise nicht wie vorgesehen.</span>
90
- {Object.keys(COOKIE_SCHEMA.necessary).map(cookie =>
91
- <div className={styles.switchBlock} key={cookie} >
92
- <span>{`${COOKIE_SCHEMA.necessary[cookie].name} (${cookie})`}</span>
93
- <MaterialSwitch disabled={true} value={true} onChange={() => {}} />
94
- </div>
95
- )}
116
+ {Object.keys(COOKIE_SCHEMA.necessary).map(cookie => {
117
+ const getLinkFromCategory = _get(COOKIE_SCHEMA_LINKS, [cookie], '');
118
+ return (
119
+ <div className={styles.switchBlock} key={cookie} >
120
+ <span className={styles.switchBlockTitle}>{cookie}</span>
121
+ <a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>Datenschutzbestimmungen</a>
122
+ <MaterialSwitch sx={{ marginLeft: 'auto' }} disabled={true} value={true} onChange={() => {}} />
123
+ </div>
124
+ );
125
+ })}
96
126
  </MaterialAccordionGroup>
97
127
  <MaterialAccordionGroup
98
128
  title='Analytisch'
@@ -101,15 +131,22 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
101
131
  switchProps={analyticsSwitchProps}
102
132
  >
103
133
  <span>Um das Nutzerverhalten zu verstehen und Ihnen ein relevanteres Surferlebnis zu bieten oder den Inhalt unserer Website zu personalisieren. Beispiel: Wir sammeln Informationen darüber, welche Seiten Sie besuchen, damit wir Ihnen relevantere Informationen präsentieren können.</span>
104
- {Object.keys(COOKIE_SCHEMA.analytics).map(cookie =>
105
- <div className={styles.switchBlock} key={cookie} >
106
- <span>{`${COOKIE_SCHEMA.analytics[cookie].name} (${cookie})`}</span>
107
- <MaterialSwitch
108
- value={analyticsSwitches[cookie]}
109
- onChange={() => { setAnalyticsSwitches(s => ({ ...s, [cookie]: !s[cookie] })); }}
110
- />
111
- </div>
112
- )}
134
+ {Object.keys(COOKIE_SCHEMA.analytics).map(cookie => {
135
+ const getItemsFromCategory = _get(COOKIE_SCHEMA, `analytics['${cookie}']`, null);
136
+ const getLinkFromCategory = _get(COOKIE_SCHEMA_LINKS, [cookie], '');
137
+ const isChecked = getItemsFromCategory.every((item: string) => analyticsSwitches[item] === true);
138
+ return (
139
+ <div className={styles.switchBlock} key={cookie} >
140
+ <span className={styles.switchBlockTitle}>{cookie}</span>
141
+ <a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>Datenschutzbestimmungen</a>
142
+ <MaterialSwitch
143
+ sx={{ marginLeft: 'auto' }}
144
+ value={isChecked}
145
+ onChange={() => onHandleChangeInnerSwitchAnalytics(getItemsFromCategory, isChecked)}
146
+ />
147
+ </div>
148
+ );
149
+ })}
113
150
  </MaterialAccordionGroup>
114
151
  <MaterialAccordionGroup
115
152
  title='Marketing'
@@ -118,15 +155,22 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
118
155
  switchProps={marketingSwitchProps}
119
156
  >
120
157
  <span>Zur Personalisierung und Messung der Effektivität von Werbung auf unserer Website und anderen Websites. Beispiel: Wir können Ihnen eine personalisierte Werbung auf der Grundlage der von Ihnen besuchten Seiten auf unserer Website anzeigen.</span>
121
- {Object.keys(COOKIE_SCHEMA.marketing).map(cookie =>
122
- <div className={styles.switchBlock} key={cookie} >
123
- <span>{`${COOKIE_SCHEMA.marketing[cookie].name} (${cookie})`}</span>
124
- <MaterialSwitch
125
- value={marketingSwitches[cookie]}
126
- onChange={() => setMarketingSwitches(s => ({ ...s, [cookie]: !s[cookie] }))}
127
- />
128
- </div>
129
- )}
158
+ {Object.keys(COOKIE_SCHEMA.marketing).map(cookie => {
159
+ const getItemsFromCategory = _get(COOKIE_SCHEMA, `marketing['${cookie}']`, null);
160
+ const getLinkFromCategory = _get(COOKIE_SCHEMA_LINKS, [cookie], '');
161
+ const isChecked = getItemsFromCategory.every((item: string) => marketingSwitches[item] === true);
162
+ return (
163
+ <div className={styles.switchBlock} key={cookie} >
164
+ <span className={styles.switchBlockTitle}>{cookie}</span>
165
+ <a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>Datenschutzbestimmungen</a>
166
+ <MaterialSwitch
167
+ sx={{ marginLeft: 'auto' }}
168
+ value={isChecked}
169
+ onChange={() => onHandleChangeInnerSwitchMarketing(getItemsFromCategory, isChecked)}
170
+ />
171
+ </div>
172
+ )
173
+ })}
130
174
  </MaterialAccordionGroup>
131
175
  </div>
132
176
  <div className={styles.buttonsContainer}>
@@ -79,7 +79,7 @@ const withStats = (WrappedComponent: any) => ({
79
79
  };
80
80
 
81
81
  const renderRotateSvg = (): JSX.Element => {
82
- const hasExteriorPhotos = hasInteriorExteriorPhoto && Array.isArray(images) && images.length > 0;
82
+ const hasExteriorPhotos = hasInteriorExteriorPhoto && imagesCount > 0;
83
83
  if (!hasExteriorPhotos) return null;
84
84
  return (
85
85
  <div className={styles.section}>
@@ -8,76 +8,91 @@ export const QUOTES_SLIDES_TO_SHOW_DEFAULT = 3;
8
8
 
9
9
  export const HUNDRED = 100;
10
10
 
11
- export const GOOGLE_BUNDLE_COOKIES = {
12
- analytics_storage: { name: 'Google-Analytics' },
13
- ad_storage: { name: 'Google-Werbeausrichtung' },
14
- functionality_storage: { name: 'Google-Funktionalität' },
15
- personalization_storage: { name: 'Google-Personalisierung' },
16
- security_storage: { name: 'Google-Sicherheit' }
17
- };
11
+ export const GOOGLE_BUNDLE_COOKIES = [
12
+ 'analytics_storage',
13
+ 'ad_storage',
14
+ 'functionality_storage',
15
+ 'personalization_storage',
16
+ 'security_storage'
17
+ ];
18
18
 
19
19
  /* tslint:disable */
20
- export interface INecessaryCookieSchema {
21
- [key: string]: {
22
- [key: string]: {
23
- name: string;
24
- }
25
- };
20
+
21
+ export const COOKIE_SCHEMA_LINKS = {
22
+ ['auto.de']: 'https://www.auto.de/datenschutz/',
23
+ Cloudflare: 'https://www.cloudflare.com/de-de/gdpr/introduction/',
24
+ Firebase: 'https://firebase.google.com/support/privacy?hl=de',
25
+ Google: 'https://policies.google.com/privacy?hl=de',
26
+ Criteo: 'https://www.criteo.com/de/privacy/',
27
+ Facebook: 'https://www.facebook.com/privacy/policies/cookies/?entry_point=cookie_policy_redirect&entry=0',
28
+ ['Google Analytics']: 'http://datenschutzbestimmungen/',
29
+ Hotjar: 'https://www.hotjar.com/legal/policies/privacy/de/',
30
+ Microsoft: 'https://privacy.microsoft.com/de-de/privacystatement'
26
31
  }
27
32
 
28
- export const COOKIE_SCHEMA: INecessaryCookieSchema = {
33
+ export const COOKIE_SCHEMA = {
29
34
  necessary: {
30
- cf_chl_2: { name: 'Cloudflare für Webverkehr zu identifizieren' },
31
- cf_chl_rc_ni: { name: 'Cloudflare für den internen Gebrauch' },
32
- ['next-i18next']: { name: 'Spracheinstellungen' },
33
- cf_chl_prog: { name: 'Cloudflare für JS' }
35
+ ['auto.de']: ['next-i18next'],
36
+ Cloudflare: [
37
+ 'cf_chl_2',
38
+ 'cf_chl_rc_ni',
39
+ 'cf_chl_prog'
40
+ ]
34
41
  },
35
42
  analytics: {
36
- PugT: {name: 'PubMatic' },
37
- locale: {name: 'Personio' },
38
- uid: { name: 'criteo' },
39
- callback: { name: 'callback' },
40
- demdex: { name: 'demdex' },
41
- _fbp: { name: 'Facebook' },
42
- hotjar: { name: 'Hotjar-Analytics'},
43
- _clck: { name: 'Clarity' },
44
- _clsk: { name: 'Clarity' },
45
- _uetsid: { name: 'Microsoft-Werbeausrichtung' },
46
- _uetvid: { name: 'Microsoft-Werbeausrichtung' },
47
- sentry: { name: 'Sentry' },
48
- ...GOOGLE_BUNDLE_COOKIES
43
+ ['auto.de']: [
44
+ 'sentry',
45
+ 'callback',
46
+ 'locale'
47
+ ],
48
+ ['Google Analytics']: [
49
+ '_clck',
50
+ '_clsk',
51
+ '_uetsid',
52
+ '_uetvid',
53
+ ...GOOGLE_BUNDLE_COOKIES
54
+ ],
55
+ Criteo: [
56
+ 'uid',
57
+ 'PugT',
58
+ 'demdex',
59
+ 'cto_bundle',
60
+ 'tuuid',
61
+ 'tuuid_lu',
62
+ 'c',
63
+ 'CMID',
64
+ 'CMPS',
65
+ 'CMPRO',
66
+ 'uuid2',
67
+ 'um',
68
+ 'umeh',
69
+ 'KRTBCOOKIE_97',
70
+ 'IDSYNC',
71
+ 'dpm',
72
+ '_kuid_',
73
+ 'visitor-id',
74
+ 'data-c-ts',
75
+ 'data-c',
76
+ 'CMTS',
77
+ 'mv_tokens',
78
+ 'A3',
79
+ 'mv_tokens_eu-v1',
80
+ 'am_tokens',
81
+ 'am_tokens_eu-v1',
82
+ 'iteo'
83
+ ],
84
+ Hotjar: ['hotjar'],
85
+ Facebook: ['_fbp']
49
86
  },
50
87
  marketing: {
51
- test_cookie: { name: 'doubleclick.net' },
52
- tuuid: { name: '360yield.com' },
53
- tuuid_lu: { name: '360yield.com' },
54
- c: { name: 'bidswitch.net' },
55
- CMID: { name: 'casalemedia.com' },
56
- CMPS: { name: 'casalemedia.com' },
57
- CMPRO: { name: 'casalemedia.com' },
58
- uuid2: { name: 'adnxs.com' },
59
- IDE: { name: 'Google DoubleClick' },
60
- um: { name: '360yield.com' },
61
- umeh: { name: '360yield.com' },
62
- cf: { name: 'id5-sync.com' },
63
- cip: { name: 'id5-sync.com' },
64
- cnac: { name: 'id5-sync.com' },
65
- car: { name: 'id5-sync.com' },
66
- KRTBCOOKIE_97: { name: 'PubMatic' },
67
- IDSYNC: { name: 'analytics.yahoo.com' },
68
- dpm: { name: 'Demdex' },
69
- _kuid_: { name: 'Krux' },
70
- cto_bundle: { name: 'Criteo' },
71
- ['visitor-id']: { name: 'media.net' },
72
- ['data-c-ts']: { name: 'media.net' },
73
- ['data-c']: { name: 'media.net' },
74
- CMTS: { name: 'casalemedia.com' },
75
- ['mv_tokens']: { name: 'mediavine' },
76
- A3: { name: 'yahoo.com' },
77
- ['mv_tokens_eu-v1']: { name: 'mediavine' },
78
- am_tokens: { name: 'mediavine' },
79
- ['am_tokens_eu-v1']: { name: 'mediavine' },
80
- iteo: { name: 'mediavine' }
88
+ Google: [
89
+ 'test_cookie',
90
+ 'IDE',
91
+ 'cf',
92
+ 'cip',
93
+ 'cnac',
94
+ 'car'
95
+ ]
81
96
  }
82
97
  };
83
98
 
@@ -17,13 +17,8 @@ const PRICE_DEFAULT = DROP_DOWN_GROUP[PRICE].defaultValue;
17
17
  declare global {
18
18
  // tslint:disable-next-line:interface-name
19
19
  interface Window {
20
- grantHotjarCookieConsent?: () => void;
21
- grantCookieConsentClarity?: () => void;
22
- grantCookieConsentMicrosoft?: () => void;
23
- grantCookieConsentFacebook?: () => void;
24
20
  grantCookieConsentSentry?: () => void;
25
- grantCookieConsent?: (list: string[]) => void;
26
- allowGoogle?: () => void;
21
+ grantCookieConsent?: (disabledCookies: string[]) => void;
27
22
  }
28
23
  }
29
24
 
@@ -548,69 +543,25 @@ export function setUtmParameters() {
548
543
  }
549
544
 
550
545
  export const updateCookieList = (handleSentryInit: () => void) => {
551
- let cookieConsentList = Object.keys(GOOGLE_BUNDLE_COOKIES);
552
- let isHomeGoogleGranted = true; // home page google cookie
553
- let isMicrosoftGranted = true; // Microsoft _uetvid _uetsid
554
- let isMicrosoftClarity = true; // Microsoft Clarity _clck _clsk
555
- let isFacebookGranted = true; // Facebook Clarity _fbp _f
556
- let isSentryGranted = true; // Sentry
557
- let isHotjarGranted = true;
558
- let isCriteoGranted = true;
559
546
  const cookieConfig = JSON.parse(localStorage.getItem('cookieConfig')) || {};
560
-
547
+ let isSentryGranted = true; // Sentry
548
+ let disabledCookies: any[] = [];
561
549
  const parsedUrl = new URL(window.location.href);
562
550
  const domain = parsedUrl.hostname.split('.').slice(-2).join('.');
551
+
563
552
  Object.keys(cookieConfig).forEach((group: string) => {
564
553
  cookieConfig[group].forEach((cookie: string) => {
565
554
  Cookies.remove(cookie, { domain, path: '/' }); // manually remove selected cookies
566
- // google
567
- if (cookieConsentList.includes(cookie)) {
568
- cookieConsentList = cookieConsentList.filter(i => i !== cookie); // deny google cookie consent for _gcl_au, _ga, _gid, _gat_UA-31842-13, etc
569
-
570
- isHomeGoogleGranted = false;
571
- } else if (cookie === 'hotjar') {
572
- isHotjarGranted = false;
573
- } else if (cookie === '_uetvid' || cookie === '_uetsid') {
574
- isMicrosoftGranted = false;
575
- } else if (cookie === '_clck' || cookie === '_clsk') {
576
- isMicrosoftClarity = false;
577
- } else if (cookie === '_fbp') {
578
- isFacebookGranted = false;
579
- } else if (cookie === 'sentry') {
555
+ if (cookie === 'sentry') {
580
556
  isSentryGranted = false;
581
- } else if (cookie === 'uid' && 'cto_bundle') {
582
- isCriteoGranted = false;
583
557
  }
558
+ disabledCookies.push(cookie);
584
559
  });
585
560
  });
586
561
 
587
562
  // grant google cookies
588
- if (isCriteoGranted && typeof window.grantCookieConsent === 'function') {
589
- window.grantCookieConsent(cookieConsentList);
590
- }
591
-
592
- // grant Microsoft cookies
593
- if (isMicrosoftGranted && typeof window.grantCookieConsentMicrosoft === 'function') {
594
- window.grantCookieConsentMicrosoft();
595
- }
596
-
597
- // grant Microsoft Clarity cookies
598
- if (isMicrosoftClarity && typeof window.grantCookieConsentClarity === 'function') {
599
- window.grantCookieConsentClarity();
600
- }
601
-
602
- // grant Facebook cookies
603
- if (!isFacebookGranted && typeof window.grantCookieConsentFacebook === 'function') {
604
- window.grantCookieConsentFacebook();
605
- }
606
-
607
- if (isHomeGoogleGranted && typeof window.allowGoogle === 'function') {
608
- window.allowGoogle();
609
- }
610
-
611
- // grant Hotjar cookies
612
- if (isHotjarGranted && typeof window.grantHotjarCookieConsent === 'function') {
613
- window.grantHotjarCookieConsent();
563
+ if (typeof window.grantCookieConsent === 'function') {
564
+ window.grantCookieConsent(disabledCookies);
614
565
  }
615
566
 
616
567
  // grant Sentry cookies