[ ADD ] react configuration
This commit is contained in:
10
react/src/store/Lang/LangAction.js
Normal file
10
react/src/store/Lang/LangAction.js
Normal file
@ -0,0 +1,10 @@
|
||||
import * as types from './LangTypes';
|
||||
|
||||
export const setCurrentLang = payload => {
|
||||
localStorage.setItem('lang', payload);
|
||||
return { type: types.SET_LANG, payload };
|
||||
}
|
||||
|
||||
export const getCurrentLang = () => {
|
||||
return { type: types.GET_LANG };
|
||||
};
|
14
react/src/store/Lang/LangReducer.js
Normal file
14
react/src/store/Lang/LangReducer.js
Normal file
@ -0,0 +1,14 @@
|
||||
import * as types from "./LangTypes";
|
||||
|
||||
const INITIAL_STATE = localStorage.getItem("lang") || "en";
|
||||
|
||||
export default function locale(state = INITIAL_STATE, action) {
|
||||
switch (action.type) {
|
||||
case types.SET_LANG:
|
||||
return action.payload;
|
||||
case types.GET_LANG:
|
||||
return action.payload;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
2
react/src/store/Lang/LangTypes.js
Normal file
2
react/src/store/Lang/LangTypes.js
Normal file
@ -0,0 +1,2 @@
|
||||
export const SET_LANG = 'SET_LANG';
|
||||
export const GET_LANG = 'GET_LANG';
|
Reference in New Issue
Block a user