2020-09-07 10:22:16 +02:00
|
|
|
import { createSlice } from '@reduxjs/toolkit';
|
2020-09-17 09:17:11 +02:00
|
|
|
import { getItem } from 'lib/web';
|
2020-09-20 10:33:39 +02:00
|
|
|
import { LOCALE_CONFIG, THEME_CONFIG } from 'lib/constants';
|
2020-09-07 10:22:16 +02:00
|
|
|
|
|
|
|
const app = createSlice({
|
|
|
|
name: 'app',
|
2020-09-20 10:33:39 +02:00
|
|
|
initialState: {
|
|
|
|
locale: getItem(LOCALE_CONFIG) || 'en-US',
|
|
|
|
theme: getItem(THEME_CONFIG) || 'light',
|
|
|
|
},
|
2020-09-07 10:22:16 +02:00
|
|
|
reducers: {
|
2020-09-20 10:33:39 +02:00
|
|
|
setLocale(state, action) {
|
|
|
|
state.locale = action.payload;
|
|
|
|
return state;
|
|
|
|
},
|
|
|
|
setTheme(state, action) {
|
|
|
|
state.theme = action.payload;
|
2020-09-07 10:22:16 +02:00
|
|
|
return state;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2020-09-20 10:33:39 +02:00
|
|
|
export const { setLocale, setTheme } = app.actions;
|
2020-09-07 10:22:16 +02:00
|
|
|
|
|
|
|
export default app.reducer;
|