-
Notifications
You must be signed in to change notification settings - Fork 527
Expand file tree
/
Copy pathtours.js
More file actions
49 lines (36 loc) · 1.08 KB
/
tours.js
File metadata and controls
49 lines (36 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import root from 'window-or-global'
const toursBundle = {
name: 'tours',
init: (store) => {
const tourTooltip = root.localStorage.getItem('tourTooltip')
if (tourTooltip) {
store.doDisableTooltip()
}
},
reducer: (state = { enabled: false, tooltip: true }, action) => {
if (action.type === 'TOURS_ENABLE') {
return { ...state, enabled: true }
}
if (action.type === 'TOURS_DISABLE') {
return { ...state, enabled: false }
}
if (action.type === 'TOURS_TOOLTIP_DISABLE') {
return { ...state, tooltip: false }
}
return state
},
doDisableTooltip: () => ({ dispatch }) => {
root.localStorage.setItem('tourTooltip', false)
dispatch({ type: 'TOURS_TOOLTIP_DISABLE' })
},
doEnableTours: () => ({ dispatch }) => {
dispatch({ type: 'TOURS_ENABLE' })
},
doDisableTours: () => ({ dispatch }) => {
dispatch({ type: 'TOURS_DISABLE' })
},
selectTours: state => state.tours,
selectToursEnabled: state => state.tours.enabled,
selectShowTooltip: state => state.tours.tooltip
}
export default toursBundle