@bytebrand/fe-ui-core 4.1.66 → 4.1.68
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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import useModal from '../../../framework/hooks/useModal';
|
|
3
|
+
import { updateCookieList } from '../../../framework/utils/CommonUtils';
|
|
4
|
+
import Modal from './Modal';
|
|
5
|
+
|
|
6
|
+
const CookieModal = () => {
|
|
7
|
+
const { isVisible, toggleModal } = useModal();
|
|
8
|
+
const [modal, setModal] = useState('');
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const cookieConfig = localStorage.getItem('cookieConfig');
|
|
12
|
+
if (!cookieConfig) {
|
|
13
|
+
setModal('PREVIEW_COOKIE_MODAL');
|
|
14
|
+
toggleModal();
|
|
15
|
+
} else setTimeout(() => { updateCookieList(); }, 3000);
|
|
16
|
+
}, []);
|
|
17
|
+
|
|
18
|
+
const onClearModalState = () => {
|
|
19
|
+
setModal('');
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const modalProps = {
|
|
23
|
+
onClearModalState,
|
|
24
|
+
setModal
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return isVisible
|
|
28
|
+
? <Modal
|
|
29
|
+
isVisible={isVisible}
|
|
30
|
+
toggleModal={toggleModal}
|
|
31
|
+
name={modal}
|
|
32
|
+
modalProps={modalProps}
|
|
33
|
+
/>
|
|
34
|
+
: <></>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default CookieModal;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import _merge from 'lodash/merge';
|
|
3
|
-
import
|
|
3
|
+
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import IconSVG from '../../../IconSVG/IconSVG';
|
|
6
6
|
import Button from '../../../Button/Button';
|
|
7
7
|
import MaterialAccordionGroup from '../../../MaterialAccordionGroup/MaterialAccordionGroup';
|
|
8
|
-
import classNames from 'classnames';
|
|
9
8
|
import MaterialSwitch from '../../../MaterialSwitch/MaterialSwitch';
|
|
10
9
|
import { COOKIE_SCHEMA } from '../../../../../framework/constants/common';
|
|
11
|
-
import
|
|
12
|
-
|
|
10
|
+
import { updateCookieList } from '../../../../../framework/utils/CommonUtils';
|
|
11
|
+
|
|
12
|
+
import styles from './ManageCookieModal.styl';
|
|
13
13
|
|
|
14
14
|
const ManageCookieModal = ({ onClearModalState }) => {
|
|
15
15
|
const [analytcisMasterSwitch, setAnalyticsMasterSwitch] = useState(true);
|
|
@@ -43,6 +43,7 @@ const ManageCookieModal = ({ onClearModalState }) => {
|
|
|
43
43
|
value: marketingMasterSwitch,
|
|
44
44
|
onChange: onHandleMarketingSwitchValue
|
|
45
45
|
};
|
|
46
|
+
|
|
46
47
|
const analyticsSwitchProps = {
|
|
47
48
|
value: analytcisMasterSwitch,
|
|
48
49
|
onChange: onHandleAnalyticsSwitchValue
|
|
@@ -54,18 +55,13 @@ const ManageCookieModal = ({ onClearModalState }) => {
|
|
|
54
55
|
onChange: () => {}
|
|
55
56
|
};
|
|
56
57
|
|
|
57
|
-
const onAccept = (value?: object) => {
|
|
58
|
+
const onAccept = (value?: object) => {
|
|
58
59
|
const cookieConfig = value || {
|
|
59
60
|
marketing: Object.keys(marketingSwitches).filter(i => !marketingSwitches[i]) || [],
|
|
60
61
|
analytics: Object.keys(analyticsSwitches).filter(i => !analyticsSwitches[i]) || []
|
|
61
62
|
};
|
|
62
63
|
localStorage.setItem('cookieConfig', JSON.stringify(cookieConfig));
|
|
63
|
-
|
|
64
|
-
Object.keys(cookieConfig).forEach((group) => {
|
|
65
|
-
cookieConfig[group].forEach((cookie: string) => {
|
|
66
|
-
Cookies.remove(cookie, { path: '/' });
|
|
67
|
-
});
|
|
68
|
-
});
|
|
64
|
+
updateCookieList();
|
|
69
65
|
onClearModalState();
|
|
70
66
|
};
|
|
71
67
|
|
|
@@ -139,8 +135,8 @@ const ManageCookieModal = ({ onClearModalState }) => {
|
|
|
139
135
|
</MaterialAccordionGroup>
|
|
140
136
|
</div>
|
|
141
137
|
<div className={styles.buttonsContainer}>
|
|
142
|
-
<Button onClick={() => onAccept()}className={classNames(styles.modalBtn, styles.outlinedBtn)} variant='outlined'>
|
|
143
|
-
<Button onClick={() => onAccept({})} className={styles.modalBtn}>
|
|
138
|
+
<Button onClick={() => onAccept()}className={classNames(styles.modalBtn, styles.outlinedBtn)} variant='outlined'>Auswahl speichern</Button>
|
|
139
|
+
<Button onClick={() => onAccept({})} className={styles.modalBtn}>Alles akzeptieren</Button>
|
|
144
140
|
</div>
|
|
145
141
|
</div>
|
|
146
142
|
);
|
|
@@ -529,4 +529,13 @@ export function setUtmParameters() {
|
|
|
529
529
|
expiresDate.setDate(expiresDate.getDate() + 1);
|
|
530
530
|
|
|
531
531
|
document.cookie = `marketing=${JSON.stringify(marketing)};expires=${expiresDate};domain=.${config.DOMAIN};path=/`;
|
|
532
|
-
}
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
export const updateCookieList = () => {
|
|
535
|
+
const cookieConfig = JSON.parse(localStorage.getItem('cookieConfig')) || {};
|
|
536
|
+
Object.keys(cookieConfig).forEach((group: string) => {
|
|
537
|
+
cookieConfig[group].forEach((cookie: string) => {
|
|
538
|
+
Cookies.remove(cookie, { path: '/', domain: config[process.env.NODE_ENV].DOMAIN });
|
|
539
|
+
})
|
|
540
|
+
});
|
|
541
|
+
};
|