@seamly/web-ui 20.7.0 → 20.8.0-beta.1
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/build/dist/lib/hooks.js +1 -1
- package/build/dist/lib/hooks.min.js +1 -1
- package/build/dist/lib/index.debug.js +945 -790
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +187 -131
- package/build/dist/lib/index.js +24800 -19606
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/index.min.js.LICENSE.txt +38 -4
- package/build/dist/lib/standalone.js +32920 -26742
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/standalone.min.js.LICENSE.txt +39 -0
- package/build/dist/lib/storage.js +2 -2
- package/build/dist/lib/storage.min.js +1 -1
- package/build/dist/lib/style-guide.js +8780 -7907
- package/build/dist/lib/style-guide.min.js +2 -1
- package/build/dist/lib/style-guide.min.js.LICENSE.txt +38 -0
- package/build/dist/lib/styles.css +1 -1
- package/build/dist/lib/utils.js +1 -2
- package/build/dist/lib/utils.min.js +1 -1
- package/package.json +19 -9
- package/src/icons/avatar_agent-32.svg +7 -0
- package/src/icons/avatar_bot-32.svg +6 -1
- package/src/javascripts/api/index.js +1 -1
- package/src/javascripts/{config.js → config.ts} +3 -1
- package/src/javascripts/config.types.ts +96 -0
- package/src/javascripts/domains/app/actions.ts +83 -0
- package/src/javascripts/domains/app/app.types.ts +3 -0
- package/src/javascripts/domains/app/hooks.js +3 -5
- package/src/javascripts/domains/app/selectors.ts +6 -0
- package/src/javascripts/domains/app/slice.ts +30 -0
- package/src/javascripts/domains/config/actions.ts +45 -0
- package/src/javascripts/domains/config/hooks.ts +19 -0
- package/src/javascripts/domains/config/selectors.ts +24 -0
- package/src/javascripts/domains/config/slice.ts +113 -0
- package/src/javascripts/domains/errors/index.js +13 -9
- package/src/javascripts/domains/forms/context.ts +14 -0
- package/src/javascripts/domains/forms/forms.types.ts +24 -0
- package/src/javascripts/domains/forms/{hooks.js → hooks.ts} +23 -26
- package/src/javascripts/domains/forms/{provider.js → provider.tsx} +20 -14
- package/src/javascripts/domains/forms/{selectors.js → selectors.ts} +7 -8
- package/src/javascripts/domains/forms/slice.ts +84 -0
- package/src/javascripts/domains/forms/utils.ts +15 -0
- package/src/javascripts/domains/i18n/actions.ts +24 -0
- package/src/javascripts/domains/i18n/{hooks.js → hooks.ts} +2 -2
- package/src/javascripts/domains/i18n/i18n.types.ts +6 -0
- package/src/javascripts/domains/i18n/selectors.ts +16 -0
- package/src/javascripts/domains/i18n/{reducer.js → slice.ts} +40 -37
- package/src/javascripts/domains/interrupt/{hooks.js → hooks.ts} +2 -2
- package/src/javascripts/domains/interrupt/{middleware.js → middleware.ts} +11 -8
- package/src/javascripts/domains/interrupt/selectors.ts +6 -0
- package/src/javascripts/domains/interrupt/slice.ts +40 -0
- package/src/javascripts/domains/options/middleware.js +9 -6
- package/src/javascripts/domains/redux/redux.types.ts +11 -0
- package/src/javascripts/domains/store/index.ts +53 -0
- package/src/javascripts/domains/store/slice.ts +642 -0
- package/src/javascripts/domains/store/store.types.ts +146 -0
- package/src/javascripts/domains/translations/components/chat-status.js +2 -2
- package/src/javascripts/domains/translations/components/options-button.js +1 -1
- package/src/javascripts/domains/translations/components/options-dialog/form.js +5 -5
- package/src/javascripts/domains/translations/components/options-dialog/index.js +2 -2
- package/src/javascripts/domains/translations/hooks.ts +114 -0
- package/src/javascripts/domains/translations/middleware.js +29 -27
- package/src/javascripts/domains/translations/selectors.ts +12 -0
- package/src/javascripts/domains/translations/slice.ts +120 -0
- package/src/javascripts/domains/translations/translations.types.ts +19 -0
- package/src/javascripts/domains/visibility/{actions.js → actions.ts} +25 -19
- package/src/javascripts/domains/visibility/{hooks.js → hooks.ts} +13 -10
- package/src/javascripts/domains/visibility/{selectors.js → selectors.ts} +3 -6
- package/src/javascripts/domains/visibility/slice.ts +38 -0
- package/src/javascripts/domains/visibility/utils.js +0 -9
- package/src/javascripts/domains/visibility/visibility.types.ts +6 -0
- package/src/javascripts/index.ts +92 -0
- package/src/javascripts/lib/engine/index.js +15 -11
- package/src/javascripts/lib/external-api/initialize-api.js +1 -1
- package/src/javascripts/lib/id.js +5 -8
- package/src/javascripts/lib/mutex.js +3 -1
- package/src/javascripts/lib/store/providers/cookie-storage.js +1 -1
- package/src/javascripts/lib/store/providers/session-storage.js +1 -1
- package/src/javascripts/package/hooks.js +2 -2
- package/src/javascripts/package/utils.js +0 -1
- package/src/javascripts/schema.ts +1448 -0
- package/src/javascripts/style-guide/components/app.js +6 -6
- package/src/javascripts/style-guide/components/static-core.js +87 -65
- package/src/javascripts/style-guide/components/view.js +4 -4
- package/src/javascripts/style-guide/state-helpers/index.js +5 -5
- package/src/javascripts/style-guide/states.js +67 -7
- package/src/javascripts/style-guide.ts +5 -0
- package/src/javascripts/ui/components/app-options/index.js +2 -4
- package/src/javascripts/ui/components/conversation/component-filter.js +1 -1
- package/src/javascripts/ui/components/conversation/conversation.js +11 -7
- package/src/javascripts/ui/components/conversation/event/card-message.js +2 -2
- package/src/javascripts/ui/components/conversation/event/carousel-component/components/controls.js +1 -1
- package/src/javascripts/ui/components/conversation/event/carousel-message/components/slide.js +1 -1
- package/src/javascripts/ui/components/conversation/event/carousel-message/index.js +2 -2
- package/src/javascripts/ui/components/conversation/event/choice-prompt.js +3 -3
- package/src/javascripts/ui/components/conversation/event/conversation-suggestions.js +19 -15
- package/src/javascripts/ui/components/conversation/event/cta.js +2 -2
- package/src/javascripts/ui/components/conversation/event/divider/variants/default.js +1 -1
- package/src/javascripts/ui/components/conversation/event/divider/variants/new-translation.js +44 -5
- package/src/javascripts/ui/components/conversation/event/event-participant.js +2 -2
- package/src/javascripts/ui/components/conversation/event/hooks/use-formatted-date.js +2 -2
- package/src/javascripts/ui/components/conversation/event/image-lightbox.js +1 -1
- package/src/javascripts/ui/components/conversation/event/image.js +6 -8
- package/src/javascripts/ui/components/conversation/event/participant.js +2 -2
- package/src/javascripts/ui/components/conversation/event/splash.js +4 -4
- package/src/javascripts/ui/components/conversation/event/text.js +2 -2
- package/src/javascripts/ui/components/conversation/event/translation.js +3 -3
- package/src/javascripts/ui/components/conversation/event/upload.js +3 -3
- package/src/javascripts/ui/components/conversation/event/video.js +2 -2
- package/src/javascripts/ui/components/conversation/message-container.js +4 -26
- package/src/javascripts/ui/components/core/seamly-api-context.js +1 -1
- package/src/javascripts/ui/components/core/seamly-core.js +15 -14
- package/src/javascripts/ui/components/core/seamly-event-subscriber.js +98 -92
- package/src/javascripts/ui/components/core/seamly-file-upload.js +20 -24
- package/src/javascripts/ui/components/core/seamly-initializer.js +1 -1
- package/src/javascripts/ui/components/core/seamly-instance-functions-loader.js +5 -4
- package/src/javascripts/ui/components/core/seamly-new-notifications.js +2 -2
- package/src/javascripts/ui/components/core/seamly-read-state.js +10 -17
- package/src/javascripts/ui/components/entry/deprecated-toggle-button.js +3 -3
- package/src/javascripts/ui/components/entry/entry-container.js +4 -6
- package/src/javascripts/ui/components/entry/text-entry/hooks.js +3 -3
- package/src/javascripts/ui/components/entry/text-entry/index.js +3 -2
- package/src/javascripts/ui/components/entry/text-entry/text-entry-form.js +6 -10
- package/src/javascripts/ui/components/entry/upload/file-upload-form.js +2 -2
- package/src/javascripts/ui/components/entry/upload/index.js +10 -9
- package/src/javascripts/ui/components/entry/upload-toggle.js +2 -2
- package/src/javascripts/ui/components/faq/faq.js +9 -7
- package/src/javascripts/ui/components/form-controls/file-input.js +1 -1
- package/src/javascripts/ui/components/form-controls/form.js +1 -1
- package/src/javascripts/ui/components/form-controls/input.js +1 -1
- package/src/javascripts/ui/components/form-controls/select.js +1 -1
- package/src/javascripts/ui/components/layout/agent-info.js +4 -4
- package/src/javascripts/ui/components/layout/chat-frame.js +3 -3
- package/src/javascripts/ui/components/layout/chat.js +11 -12
- package/src/javascripts/ui/components/layout/deprecated-app-frame.js +10 -9
- package/src/javascripts/ui/components/layout/header.js +1 -1
- package/src/javascripts/ui/components/layout/interrupt.js +23 -24
- package/src/javascripts/ui/components/layout/pre-chat-messages.js +11 -11
- package/src/javascripts/ui/components/layout/privacy-disclaimer.js +2 -2
- package/src/javascripts/ui/components/options/options-button.js +14 -10
- package/src/javascripts/ui/components/options/transcript/index.js +2 -2
- package/src/javascripts/ui/components/options/transcript/transcript-form.js +1 -1
- package/src/javascripts/ui/components/suggestions/index.js +14 -10
- package/src/javascripts/ui/components/view/deprecated-view.js +19 -16
- package/src/javascripts/ui/components/view/index.js +12 -12
- package/src/javascripts/ui/components/view/inline-view.js +2 -2
- package/src/javascripts/ui/components/view/window-view/collapse-button.js +3 -3
- package/src/javascripts/ui/components/view/window-view/index.js +13 -13
- package/src/javascripts/ui/components/view/window-view/window-open-button.js +13 -13
- package/src/javascripts/ui/components/warnings/idle-detach-warning.js +1 -1
- package/src/javascripts/ui/components/warnings/resume-conversation-prompt.js +1 -1
- package/src/javascripts/ui/components/widgets/lightbox.js +2 -2
- package/src/javascripts/ui/components/widgets/upload-progress.js +1 -1
- package/src/javascripts/ui/hooks/component-helper-hooks.js +1 -1
- package/src/javascripts/ui/hooks/file-upload-hooks.js +4 -6
- package/src/javascripts/ui/hooks/focus-helper-hooks.js +14 -12
- package/src/javascripts/ui/hooks/live-region-hooks.js +2 -0
- package/src/javascripts/ui/hooks/seamly-api-hooks.js +8 -3
- package/src/javascripts/ui/hooks/seamly-entry-hooks.js +28 -25
- package/src/javascripts/ui/hooks/seamly-hooks.js +25 -25
- package/src/javascripts/ui/hooks/seamly-option-hooks.js +17 -19
- package/src/javascripts/ui/hooks/seamly-state-hooks.js +20 -13
- package/src/javascripts/ui/hooks/use-seamly-chat.js +15 -25
- package/src/javascripts/ui/hooks/use-seamly-commands.js +46 -46
- package/src/javascripts/ui/hooks/use-seamly-idle-detach-countdown.js +22 -24
- package/src/javascripts/ui/hooks/use-seamly-resume-conversation-prompt.js +8 -9
- package/src/javascripts/ui/hooks/use-single-file-upload.js +4 -6
- package/src/javascripts/ui/hooks/utility-hooks.js +4 -4
- package/src/javascripts/ui/utils/form-utils.js +0 -145
- package/src/javascripts/ui/utils/general-utils.js +3 -4
- package/src/javascripts/ui/utils/seamly-utils.ts +73 -0
- package/src/stylesheets/5-components/_message-carousel.scss +10 -8
- package/webpack/config.common.js +16 -0
- package/webpack/config.dev.js +1 -0
- package/webpack/config.package.js +26 -5
- package/webpack/defaults.js +7 -2
- package/webpack/parts/babel-loader-browser-plugins.js +1 -0
- package/webpack/parts/dev-server.js +4 -3
- package/CHANGELOG.md +0 -791
- package/src/javascripts/domains/app/actions.js +0 -112
- package/src/javascripts/domains/app/index.js +0 -7
- package/src/javascripts/domains/app/reducer.js +0 -16
- package/src/javascripts/domains/app/selectors.js +0 -8
- package/src/javascripts/domains/app/utils.js +0 -4
- package/src/javascripts/domains/config/actions.js +0 -7
- package/src/javascripts/domains/config/hooks.js +0 -23
- package/src/javascripts/domains/config/index.js +0 -7
- package/src/javascripts/domains/config/reducer.js +0 -79
- package/src/javascripts/domains/config/selectors.js +0 -23
- package/src/javascripts/domains/config/utils.js +0 -4
- package/src/javascripts/domains/forms/actions.js +0 -21
- package/src/javascripts/domains/forms/context.js +0 -6
- package/src/javascripts/domains/forms/index.js +0 -8
- package/src/javascripts/domains/forms/reducer.js +0 -84
- package/src/javascripts/domains/forms/utils.js +0 -20
- package/src/javascripts/domains/i18n/actions.js +0 -20
- package/src/javascripts/domains/i18n/index.js +0 -7
- package/src/javascripts/domains/i18n/selectors.js +0 -15
- package/src/javascripts/domains/i18n/utils.js +0 -4
- package/src/javascripts/domains/interrupt/actions.js +0 -4
- package/src/javascripts/domains/interrupt/index.js +0 -9
- package/src/javascripts/domains/interrupt/reducer.js +0 -22
- package/src/javascripts/domains/interrupt/selectors.js +0 -6
- package/src/javascripts/domains/interrupt/utils.js +0 -4
- package/src/javascripts/domains/options/index.js +0 -1
- package/src/javascripts/domains/redux/context.js +0 -6
- package/src/javascripts/domains/redux/create-redux-store.js +0 -21
- package/src/javascripts/domains/redux/hooks.js +0 -80
- package/src/javascripts/domains/redux/index.js +0 -19
- package/src/javascripts/domains/redux/provider.js +0 -5
- package/src/javascripts/domains/redux/utils.js +0 -12
- package/src/javascripts/domains/store/index.js +0 -46
- package/src/javascripts/domains/store/state-reducer.js +0 -56
- package/src/javascripts/domains/translations/actions.js +0 -11
- package/src/javascripts/domains/translations/hooks.js +0 -103
- package/src/javascripts/domains/translations/index.js +0 -10
- package/src/javascripts/domains/translations/reducer.js +0 -69
- package/src/javascripts/domains/translations/selectors.js +0 -16
- package/src/javascripts/domains/translations/utils.js +0 -4
- package/src/javascripts/domains/visibility/index.js +0 -8
- package/src/javascripts/domains/visibility/reducer.js +0 -24
- package/src/javascripts/index.js +0 -153
- package/src/javascripts/lib/redux-helpers/index.js +0 -99
- package/src/javascripts/style-guide.js +0 -5
- package/src/javascripts/ui/hooks/use-seamly-dispatch.js +0 -3
- package/src/javascripts/ui/utils/seamly-utils.js +0 -832
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { createSlice } from '@reduxjs/toolkit'
|
|
2
|
+
import { initializeApp } from 'domains/app/actions'
|
|
3
|
+
import { initializeConfig } from 'domains/config/actions'
|
|
4
|
+
import { setLocale } from 'domains/i18n/actions'
|
|
5
|
+
import { I18nState } from 'domains/i18n/i18n.types'
|
|
4
6
|
|
|
5
|
-
const
|
|
7
|
+
const initialState: I18nState = {
|
|
6
8
|
translations: {
|
|
7
9
|
'errors.configError.message':
|
|
8
10
|
'We are sorry this happened, please retry at a later time.',
|
|
@@ -28,45 +30,46 @@ const defaultState = {
|
|
|
28
30
|
},
|
|
29
31
|
isLoading: false,
|
|
30
32
|
initialLocale: undefined,
|
|
33
|
+
locale: undefined,
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
36
|
+
export const i18nSlice = createSlice({
|
|
37
|
+
name: 'app',
|
|
38
|
+
initialState,
|
|
39
|
+
reducers: {
|
|
40
|
+
setInitialLocale: (state, action) => {
|
|
41
|
+
state.initialLocale = action.payload
|
|
42
|
+
},
|
|
43
|
+
setTranslations: (state, { payload }) => {
|
|
44
|
+
state.translations = payload
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
extraReducers: (builder) => {
|
|
48
|
+
// Add reducers for additional action types here, and handle loading state as needed
|
|
49
|
+
builder
|
|
50
|
+
.addCase(initializeConfig.fulfilled, (state, { payload }) => {
|
|
51
|
+
state.initialLocale = payload.locale
|
|
52
|
+
})
|
|
53
|
+
.addCase(setLocale.fulfilled, (state, { payload }) => {
|
|
54
|
+
if (!payload?.translations) {
|
|
55
|
+
state.isLoading = false
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
state.locale = payload.locale
|
|
60
|
+
state.translations = Object.keys(payload.translations)
|
|
55
61
|
.sort()
|
|
56
62
|
.reduce(
|
|
57
63
|
(accum, key) => ({
|
|
58
64
|
...accum,
|
|
59
|
-
[key]: translations[key],
|
|
65
|
+
[key]: payload.translations[key],
|
|
60
66
|
}),
|
|
61
67
|
{},
|
|
62
|
-
)
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
[Actions.setLocale.rejected]: (state) => ({
|
|
66
|
-
...state,
|
|
67
|
-
isLoading: false,
|
|
68
|
-
}),
|
|
69
|
-
[AppActions.initialize.pending]: () => defaultState,
|
|
68
|
+
)
|
|
69
|
+
})
|
|
70
70
|
},
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
export const { setInitialLocale, setTranslations } = i18nSlice.actions
|
|
74
|
+
|
|
75
|
+
export default i18nSlice.reducer
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { useI18n } from 'domains/i18n/hooks'
|
|
1
2
|
import { useMemo } from 'preact/hooks'
|
|
2
|
-
import {
|
|
3
|
-
import { useSelector } from 'domains/redux'
|
|
3
|
+
import { useSelector } from 'react-redux'
|
|
4
4
|
import * as Selectors from './selectors'
|
|
5
5
|
|
|
6
6
|
export function useInterrupt() {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import SeamlyGeneralError from 'api/errors/seamly-general-error'
|
|
2
1
|
import SeamlyConfigurationError from 'api/errors/seamly-configuration-error'
|
|
3
|
-
import
|
|
2
|
+
import SeamlyGeneralError from 'api/errors/seamly-general-error'
|
|
4
3
|
import SeamlyOfflineError from 'api/errors/seamly-offline-error'
|
|
4
|
+
import SeamlySessionExpiredError from 'api/errors/seamly-session-expired-error'
|
|
5
5
|
import SeamlyUnauthorizedError from 'api/errors/seamly-unauthorized-error'
|
|
6
6
|
import SeamlyUnavailableError from 'api/errors/seamly-unavailable-error'
|
|
7
|
+
import { setInterrupt } from 'domains/interrupt/slice'
|
|
7
8
|
|
|
8
9
|
const handledErrorTypes = [
|
|
9
10
|
SeamlyGeneralError,
|
|
@@ -14,13 +15,15 @@ const handledErrorTypes = [
|
|
|
14
15
|
SeamlyUnavailableError,
|
|
15
16
|
]
|
|
16
17
|
|
|
17
|
-
export default function
|
|
18
|
+
export default function createInterruptMiddleware({ api }) {
|
|
18
19
|
return () => (next) => (action) => {
|
|
19
|
-
const {
|
|
20
|
-
if (
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const { payload, type } = action
|
|
21
|
+
if (type === setInterrupt.type) {
|
|
22
|
+
if (
|
|
23
|
+
!handledErrorTypes.some((ErrorType) => payload.name === ErrorType.name)
|
|
24
|
+
) {
|
|
25
|
+
throw new Error(payload)
|
|
26
|
+
} else if (payload.action === 'reset') {
|
|
24
27
|
// [SMLY-942] We clear the store before a reset to force a new conversation if the page is refreshed before the conversation is reset
|
|
25
28
|
api.disconnect().then(() => {
|
|
26
29
|
api.clearStore()
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createSlice, isAnyOf } from '@reduxjs/toolkit'
|
|
2
|
+
import { initializeApp, resetApp } from 'domains/app/actions'
|
|
3
|
+
import { initializeConfig } from 'domains/config/actions'
|
|
4
|
+
import { setLocale } from 'domains/i18n/actions'
|
|
5
|
+
import { initializeVisibility, setVisibility } from 'domains/visibility/actions'
|
|
6
|
+
|
|
7
|
+
const initialState = {
|
|
8
|
+
error: undefined,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const interruptSlice = createSlice({
|
|
12
|
+
name: 'interrupt',
|
|
13
|
+
initialState,
|
|
14
|
+
reducers: {
|
|
15
|
+
setInterrupt: (state, action) => {
|
|
16
|
+
state.error = action.payload
|
|
17
|
+
},
|
|
18
|
+
clearInterrupt: () => initialState,
|
|
19
|
+
},
|
|
20
|
+
extraReducers: (builder) => {
|
|
21
|
+
builder
|
|
22
|
+
.addCase(resetApp.fulfilled, () => initialState)
|
|
23
|
+
.addMatcher(
|
|
24
|
+
isAnyOf(
|
|
25
|
+
initializeApp.rejected,
|
|
26
|
+
initializeConfig.rejected,
|
|
27
|
+
setLocale.rejected,
|
|
28
|
+
setVisibility.rejected,
|
|
29
|
+
initializeVisibility.rejected,
|
|
30
|
+
),
|
|
31
|
+
(state, { payload }) => {
|
|
32
|
+
state.error = payload
|
|
33
|
+
},
|
|
34
|
+
)
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
export const { setInterrupt, clearInterrupt } = interruptSlice.actions
|
|
39
|
+
|
|
40
|
+
export default interruptSlice.reducer
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
setUserSelectedOption,
|
|
3
|
+
setUserSelectedOptions,
|
|
4
|
+
} from 'domains/store/slice'
|
|
2
5
|
|
|
3
|
-
export default function
|
|
6
|
+
export default function createOptionsMiddleware({ api }) {
|
|
4
7
|
return () => (next) => (action) => {
|
|
5
8
|
const result = next(action)
|
|
6
9
|
switch (action.type) {
|
|
7
|
-
case
|
|
8
|
-
api.store.set('options', action.
|
|
10
|
+
case setUserSelectedOptions.toString():
|
|
11
|
+
api.store.set('options', action.payload)
|
|
9
12
|
break
|
|
10
|
-
case
|
|
13
|
+
case setUserSelectedOption.toString():
|
|
11
14
|
api.store.set('options', {
|
|
12
15
|
...(api.store.get('options') || {}),
|
|
13
|
-
[action.option]: action.value,
|
|
16
|
+
[action.payload.option]: action.payload.value,
|
|
14
17
|
})
|
|
15
18
|
break
|
|
16
19
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { configureStore } from '@reduxjs/toolkit'
|
|
2
|
+
import appReducer from 'domains/app/slice'
|
|
3
|
+
import configReducer from 'domains/config/slice'
|
|
4
|
+
import { createErrorsMiddleware } from 'domains/errors'
|
|
5
|
+
import formsReducer from 'domains/forms/slice'
|
|
6
|
+
import i18nReducer from 'domains/i18n/slice'
|
|
7
|
+
import createInterruptMiddleware from 'domains/interrupt/middleware'
|
|
8
|
+
import interruptReducer from 'domains/interrupt/slice'
|
|
9
|
+
import createOptionsMiddleware from 'domains/options/middleware'
|
|
10
|
+
import stateReducer from 'domains/store/slice'
|
|
11
|
+
import createI18nMiddleware from 'domains/translations/middleware'
|
|
12
|
+
import translationReducer from 'domains/translations/slice'
|
|
13
|
+
import visibilityReducer from 'domains/visibility/slice'
|
|
14
|
+
import { useDispatch } from 'react-redux'
|
|
15
|
+
|
|
16
|
+
export function createStore({ initialState, api, eventBus, config }) {
|
|
17
|
+
const store = configureStore({
|
|
18
|
+
reducer: {
|
|
19
|
+
state: stateReducer,
|
|
20
|
+
app: appReducer,
|
|
21
|
+
config: configReducer,
|
|
22
|
+
i18n: i18nReducer,
|
|
23
|
+
translations: translationReducer,
|
|
24
|
+
visibility: visibilityReducer,
|
|
25
|
+
forms: formsReducer,
|
|
26
|
+
interrupt: interruptReducer,
|
|
27
|
+
},
|
|
28
|
+
preloadedState: initialState,
|
|
29
|
+
middleware: (getDefaultMiddleWare) =>
|
|
30
|
+
getDefaultMiddleWare({
|
|
31
|
+
thunk: {
|
|
32
|
+
extraArgument: {
|
|
33
|
+
api,
|
|
34
|
+
eventBus,
|
|
35
|
+
config,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
serializableCheck: false,
|
|
39
|
+
}).concat([
|
|
40
|
+
createErrorsMiddleware({ api }),
|
|
41
|
+
createInterruptMiddleware({ api }),
|
|
42
|
+
createOptionsMiddleware({ api }),
|
|
43
|
+
createI18nMiddleware,
|
|
44
|
+
]),
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
return store
|
|
48
|
+
}
|
|
49
|
+
export type Store = ReturnType<typeof createStore>
|
|
50
|
+
export type RootState = ReturnType<Store['getState']>
|
|
51
|
+
export type AppDispatch = Store['dispatch']
|
|
52
|
+
|
|
53
|
+
export const useAppDispatch: () => AppDispatch = useDispatch
|