@bytebrand/fe-ui-core 4.1.51 → 4.1.53

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.1.51",
3
+ "version": "4.1.53",
4
4
  "description": "UI components for the auto.de project",
5
5
  "main": "index.ts",
6
6
  "module": "dist/common.js",
@@ -1,4 +1,5 @@
1
- import React, { useState } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
+ import _merge from 'lodash/merge';
2
3
  import styles from './ManageCookieModal.styl';
3
4
 
4
5
  import IconSVG from '../../../IconSVG/IconSVG';
@@ -6,18 +7,46 @@ import Button from '../../../Button/Button';
6
7
  import MaterialAccordionGroup from '../../../MaterialAccordionGroup/MaterialAccordionGroup';
7
8
  import classNames from 'classnames';
8
9
  import MaterialSwitch from '../../../MaterialSwitch/MaterialSwitch';
10
+ import { COOKIE_SCHEMA } from '@bytebrand/fe-ui-core/source/framework/constants/common';
9
11
 
10
12
  const ManageCookieModal = () => {
11
- const [accordionSwitchValue, setAccordionSwitchValue] = useState(false);
12
- const [switchValue, setSwitchValue] = useState(false);
13
+ const [analytcisMasterSwitch, setAnalyticsMasterSwitch] = useState(true);
14
+ const [marketingMasterSwitch, setMarketingMasterSwitch] = useState(true);
15
+ const [analyticsSwitches, setAnalyticsSwitches] = useState({});
16
+ const [marketingSwitches, setMarketingSwitches] = useState({});
13
17
 
14
- const onHandleAccordionSwitchValue = (value: boolean) => {
15
- setAccordionSwitchValue(value);
18
+
19
+ useEffect(() => {
20
+ const newAnalyticsSwitches = COOKIE_SCHEMA.analytics.reduce((acc, item) => ({...acc, [item]: true}), {});
21
+ const newMarketingSwitches = COOKIE_SCHEMA.marketing.reduce((acc, item) => ({...acc, [item]: true}), {});
22
+ setAnalyticsSwitches(newAnalyticsSwitches);
23
+ setMarketingSwitches(newMarketingSwitches);
24
+ }, []);
25
+
26
+ const onHandleAnalyticsSwitchValue = (value: boolean) => {
27
+ const newAnalyticsSwitches = Object.keys(analyticsSwitches).reduce((acc, item) => ({ ...acc, [item]: value }), {})
28
+ setAnalyticsSwitches(newAnalyticsSwitches);
29
+ setAnalyticsMasterSwitch(value);
30
+ };
31
+
32
+ const onHandleMarketingSwitchValue = (value: boolean) => {
33
+ const newAnalyticsSwitches = Object.keys(analyticsSwitches).reduce((acc, item) => ({ ...acc, [item]: value }), {})
34
+ setMarketingSwitches(newAnalyticsSwitches);
35
+ setMarketingMasterSwitch(value);
36
+ };
37
+
38
+ const marketingSwitchProps = {
39
+ value: marketingMasterSwitch,
40
+ onChange: onHandleMarketingSwitchValue
41
+ };
42
+ const analyticsSwitchProps = {
43
+ value: analytcisMasterSwitch,
44
+ onChange: onHandleAnalyticsSwitchValue
16
45
  };
17
46
 
18
- const accordionSwitchProps = {
19
- value: accordionSwitchValue,
20
- onChange: onHandleAccordionSwitchValue
47
+ const necessarySwitchProps = {
48
+ value: true,
49
+ onChange: () => {}
21
50
  };
22
51
 
23
52
  return (
@@ -30,37 +59,63 @@ const ManageCookieModal = () => {
30
59
  title='Notwendig'
31
60
  tooltipText='tooltip text'
32
61
  withSwitch
33
- switchProps={accordionSwitchProps}
62
+ switchProps={necessarySwitchProps}
34
63
  >
64
+ <span>
35
65
  Wir verwenden Browser-Cookies, die notwendig sind, damit die Website wie vorgesehen funktioniert.
36
66
  Beispiel: Wir speichern Ihre Präferenzen bei der Datenerfassung auf der Website, damit wir sie berücksichtigen
37
67
  können, wenn Sie auf unsere Website zurückkehren.
38
68
  For example, we store your website data collection preferences so we can honor them if you return to our site.
39
69
  You can disable these cookies in your browser settings but if you do the site may not work as intended.
70
+ </span>
71
+ {COOKIE_SCHEMA.necessary.map(cookie =>
72
+ <div className={styles.switchBlock}>
73
+ <span>{cookie}</span>
74
+ <MaterialSwitch value={true} onChange={(value: boolean) => {}} />
75
+ </div>
76
+ )}
40
77
  </MaterialAccordionGroup>
41
78
  <MaterialAccordionGroup
42
79
  title='Analytisch'
43
80
  withSwitch
44
- switchProps={accordionSwitchProps}
81
+ switchProps={analyticsSwitchProps}
45
82
  >
46
- Um das Nutzerverhalten zu verstehen und Ihnen ein relevanteres Surferlebnis zu bieten oder den Inhalt
47
- unserer Website zu personalisieren. Beispiel: Wir sammeln Informationen darüber, welche Seiten Sie besuchen,
48
- damit wir Ihnen relevantere Informationen präsentieren können.
49
- For example, we collect information about which pages you visit to help us present more relevant information.
83
+ <span>
84
+ Um das Nutzerverhalten zu verstehen und Ihnen ein relevanteres Surferlebnis zu bieten oder den Inhalt
85
+ unserer Website zu personalisieren. Beispiel: Wir sammeln Informationen darüber, welche Seiten Sie besuchen,
86
+ damit wir Ihnen relevantere Informationen präsentieren können.
87
+ For example, we collect information about which pages you visit to help us present more relevant information.
88
+ </span>
89
+ {COOKIE_SCHEMA.analytics.map(cookie =>
90
+ <div className={styles.switchBlock}>
91
+ <span>{cookie}</span>
92
+ <MaterialSwitch
93
+ value={analyticsSwitches[cookie]}
94
+ onChange={() => { setAnalyticsSwitches(s => ({ ...s, [cookie]: !s[cookie]})) }}
95
+ />
96
+ </div>
97
+ )}
50
98
  </MaterialAccordionGroup>
51
99
  <MaterialAccordionGroup
52
100
  title='Marketing'
53
101
  withSwitch
54
- switchProps={accordionSwitchProps}
102
+ switchProps={marketingSwitchProps}
55
103
  >
56
- Zur Personalisierung und Messung der Effektivität von Werbung auf unserer Website und anderen Websites.
57
- Beispiel: Wir können Ihnen eine personalisierte Werbung auf der Grundlage der Seiten, die Sie auf unserer
58
- Website besuchen, anzeigen.
59
- For example, we may serve you a personalized ad based on the pages you visit on our site.
60
- <div className={styles.switchBlock}>
61
- <span>Cookie</span>
62
- <MaterialSwitch value={switchValue} onChange={(value: boolean) => setSwitchValue(value)} />
63
- </div>
104
+ <span>
105
+ Zur Personalisierung und Messung der Effektivität von Werbung auf unserer Website und anderen Websites.
106
+ Beispiel: Wir können Ihnen eine personalisierte Werbung auf der Grundlage der Seiten, die Sie auf unserer
107
+ Website besuchen, anzeigen.
108
+ For example, we may serve you a personalized ad based on the pages you visit on our site.
109
+ </span>
110
+ {COOKIE_SCHEMA.marketing.map(cookie =>
111
+ <div className={styles.switchBlock}>
112
+ <span>Cookie</span>
113
+ <MaterialSwitch
114
+ value={marketingSwitches[cookie]}
115
+ onChange={() => setMarketingSwitches(s => ({ ...s, [cookie]: !s[cookie]}))}
116
+ />
117
+ </div>
118
+ )}
64
119
  </MaterialAccordionGroup>
65
120
  </div>
66
121
  <div className={styles.buttonsContainer}>
@@ -14,6 +14,7 @@ const PreviewCookieModal = ({ toggleModal, setModal }: IPreviewCookieModal) => {
14
14
  localStorage.setItem('cookieConfig', JSON.stringify([]));
15
15
  toggleModal();
16
16
  };
17
+
17
18
  return (
18
19
  <div className={styles.modalWrapper}>
19
20
  <IconSVG name='autodeLogo' customDimensions />
@@ -3,7 +3,9 @@ import MaterialSelect from '../MaterialSelect/MaterialSelect';
3
3
  import styles from './TimePicker.styl';
4
4
 
5
5
  interface ITimePickerProps {
6
- onHandleTimestampChange: (value: string) => void;
6
+ onHandleTimestampChange: (value: number) => void;
7
+ onDayChange: (value: number) => void;
8
+ onTimeChange: (value: number) => void;
7
9
  className: string;
8
10
  lang: string;
9
11
  time: number;
@@ -14,22 +16,24 @@ interface ITimePickerProps {
14
16
 
15
17
  const TimePicker = ({
16
18
  onHandleTimestampChange,
19
+ onDayChange,
20
+ onTimeChange,
21
+ day,
22
+ time,
17
23
  className,
18
24
  lang,
19
25
  t,
20
26
  size = 'custom'
21
27
  }: ITimePickerProps) => {
22
- const date = new Date();
28
+ const date: any = new Date();
23
29
  const [currentDay, setCurrentDay] = useState(date.getDay());
24
- const [day, setDay] = useState(0);
25
- const [time, setTime] = useState(0);
26
30
  const onHandleDayChange = (value: number) => {
27
- setDay(value);
31
+ onDayChange(value);
28
32
  };
29
33
  const onHandleTimeChange = (value: number) => {
30
- setTime(value);
34
+ onTimeChange(value);
31
35
  };
32
- const format = {
36
+ const format: { hour: 'numeric' | '2-digit', minute: 'numeric' | '2-digit' } = {
33
37
  hour: 'numeric',
34
38
  minute: 'numeric'
35
39
  };
@@ -70,7 +74,7 @@ const TimePicker = ({
70
74
  const time = date.toLocaleTimeString('de', format);
71
75
  const rangeTime = new Date(getHours(time).getTime() + 30 * 60000).toLocaleString('de', format);
72
76
  currentDayRanges.push({ time, value: currentDayRanges.length, label: `${time} - ${rangeTime}` });
73
- }
77
+ } // time ranges for current day and from current time
74
78
 
75
79
  for (let minutes = 0; minutes < ranges * 60; minutes = minutes + 30) {
76
80
  date.setHours(startTime);
@@ -78,19 +82,20 @@ const TimePicker = ({
78
82
  const time = date.toLocaleTimeString('de', format);
79
83
  const rangeTime = new Date(getHours(time).getTime() + 30 * 60000).toLocaleString('de', format);
80
84
  dayRanges.push({ time, value: dayRanges.length, label: `${time} - ${rangeTime}` });
81
- }
85
+ } // time ranges for full day
82
86
 
83
87
  return currentDay === new Date().getDay() && isWorkingHours() ? currentDayRanges : dayRanges;
84
88
  };
85
89
 
86
90
  useEffect(
87
91
  () => {
88
- onHandleTimestampChange(`${new Date(nextWeekDaysFull[day]).toDateString()} ${getTimeRanges()[time].time}`);
92
+ setCurrentDay(new Date(nextWeekDaysFull[day]).getDay())
89
93
  if (isAfterWorkingHours() && date.getDay() === 0) {
90
94
  setCurrentDay(1);
91
95
  }
96
+ onHandleTimestampChange(+new Date(`${new Date(nextWeekDaysFull[day]).toDateString()} ${getTimeRanges()[time].time}`) / 1000);
92
97
  },
93
- [day, time]
98
+ [day, time, currentDay]
94
99
  );
95
100
 
96
101
  const getHours = (time: string) => {
@@ -100,7 +105,6 @@ const TimePicker = ({
100
105
 
101
106
  const dayOnchange = (value: number) => {
102
107
  onHandleDayChange(value);
103
- setCurrentDay(new Date(nextWeekDaysFull[value]).getDay());
104
108
  onHandleTimeChange(0);
105
109
  };
106
110
 
@@ -7,3 +7,10 @@ export const PLACEHOLDER_IMAGE_LARGE_URL: string = `https://images.auto.de/noima
7
7
  export const QUOTES_SLIDES_TO_SHOW_DEFAULT = 3;
8
8
 
9
9
  export const HUNDRED = 100;
10
+
11
+ export const COOKIE_SCHEMA = {
12
+ necessary: ['gdpr', '__cfruid', 'cf_chl_2', 'cf_chl_rc_ni', 'next-i18next', '_cfuvid', 'cf_chl_prog', '__cf_bm'],
13
+ analytics: ['PugT', 'locale', '_gcl_au', '_ga', '_gid', '_gat_UA-31842-13', 'uid', 'callback', 'demdex', '_hjFirstSeen', '_hjIncludedInSessionSample', '_hjIncludedInPageviewSample', '_hjAbsoluteSessionInProgress', 'vuid'],
14
+ marketing: ['_fbp', 'test_cookie', 'tuuid', 'tuuid_lu', 'c', 'CMID', 'CMPS', 'CMPRO', 'uuid2', 'IDE', 'um', 'umeh', 'cf', 'cip', 'cnac', 'car', 'KRTBCOOKIE_97', 'IDSYNC', 'dpm', '_kuid_', 'fr', 'cto_bundle',
15
+ 'visitor-id', 'data-c-ts', 'data-c', 'CMTS', 'mv_tokens', 'A3', 'mv_tokens_eu-v1', 'am_tokens', 'am_tokens_eu-v1', '_hjSessionUser_2590373', 'iteo', '_hjSession_2590373', 'MyVerivoxAuth', 'VxCheckAuth']
16
+ }