forked from wednesday-solutions/react-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reducer.js
29 lines (25 loc) · 750 Bytes
/
reducer.js
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
/*
*
* LanguageProvider reducer
*
*/
import { createActions } from 'reduxsauce';
import { produce } from 'immer';
import { DEFAULT_LOCALE } from '@app/i18n';
export const { Types: languageProviderTypes, Creators: languageProviderActions } = createActions({
changeLocale: ['locale']
});
export const initialState = {
locale: DEFAULT_LOCALE
};
export const languageProviderReducer = (state = initialState, action) =>
produce(state, (draft) => {
// the number of languages should and will increase.
// eslint-disable-next-line sonarjs/no-small-switch
switch (action.type) {
case languageProviderTypes.CHANGE_LOCALE:
draft.locale = action.locale;
break;
}
});
export default languageProviderReducer;