web: People: Added loading settings from api
This commit is contained in:
parent
cf8fba615e
commit
17805a596c
@ -56,7 +56,7 @@ const App = ({ settings }) => {
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
settings: state.settings
|
||||
settings: state.auth.settings
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ ArticleMainButtonContent.propTypes = {
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
isAdmin: isAdmin(state.auth),
|
||||
settings: state.settings
|
||||
settings: state.auth.settings
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,8 +66,8 @@ function mapStateToProps(state) {
|
||||
auth: state.auth,
|
||||
availableModules: getAvailableModules(state.auth.modules),
|
||||
currentUser: state.auth.user,
|
||||
currentModuleId: state.settings.currentProductId,
|
||||
settings: state.settings
|
||||
currentModuleId: state.auth.settings.currentProductId,
|
||||
settings: state.auth.settings
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ SectionHeaderContent.defaultProps = {
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
settings: state.settings
|
||||
settings: state.auth.settings
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -23,7 +23,7 @@ class GroupAction extends React.Component {
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
settings: state.settings
|
||||
settings: state.auth.settings
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ const mapStateToProps = state => {
|
||||
selected: state.people.selected,
|
||||
users: state.people.users,
|
||||
isAdmin: isAdmin(state.auth),
|
||||
settings: state.settings
|
||||
settings: state.auth.settings
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -141,7 +141,7 @@ const UserContent = ({user, history,settings }) => {
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
settings: state.settings
|
||||
settings: state.auth.settings
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ const SectionBodyContent = (props) => {
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
settings: state.settings
|
||||
settings: state.auth.settings
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ const SectionHeaderContent = (props) => {
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
settings: state.settings
|
||||
settings: state.auth.settings
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ SectionHeaderContent.defaultProps = {
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
settings: state.settings
|
||||
settings: state.auth.settings
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -6,6 +6,7 @@ import { fetchPeople } from '../people/actions';
|
||||
export const LOGIN_POST = 'LOGIN_POST';
|
||||
export const SET_CURRENT_USER = 'SET_CURRENT_USER';
|
||||
export const SET_MODULES = 'SET_MODULES';
|
||||
export const SET_SETTINGS = 'SET_SETTINGS';
|
||||
export const SET_IS_LOADED = 'SET_IS_LOADED';
|
||||
export const LOGOUT = 'LOGOUT';
|
||||
|
||||
@ -23,6 +24,13 @@ export function setModules(modules) {
|
||||
};
|
||||
};
|
||||
|
||||
export function setSettings(settings) {
|
||||
return {
|
||||
type: SET_SETTINGS,
|
||||
settings
|
||||
};
|
||||
};
|
||||
|
||||
export function setIsLoaded(isLoaded) {
|
||||
return {
|
||||
type: SET_IS_LOADED,
|
||||
@ -38,11 +46,13 @@ export function setLogout() {
|
||||
|
||||
export function getUserInfo(dispatch) {
|
||||
return api.getUser()
|
||||
.then((res) => dispatch(setCurrentUser(res.data.response)))
|
||||
.then(res => dispatch(setCurrentUser(res.data.response)))
|
||||
.then(() => api.getModulesList())
|
||||
.then((res) => dispatch(setModules(res.data.response)))
|
||||
.then(res => dispatch(setModules(res.data.response)))
|
||||
.then(() => api.getSettings())
|
||||
.then(res => dispatch(setSettings(res.data.response)))
|
||||
.then(() => api.getGroupList())
|
||||
.then((res) => dispatch(setGroups(res.data.response)))
|
||||
.then(res => dispatch(setGroups(res.data.response)))
|
||||
.then(() => dispatch(fetchPeople()))
|
||||
.then(() => dispatch(setIsLoaded(true)));
|
||||
};
|
||||
|
@ -1,11 +1,30 @@
|
||||
import { SET_CURRENT_USER, SET_MODULES, SET_IS_LOADED, LOGOUT } from './actions';
|
||||
import { SET_CURRENT_USER, SET_MODULES, SET_IS_LOADED, LOGOUT, SET_SETTINGS } from './actions';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import config from "../../../package.json";
|
||||
|
||||
const initialState = {
|
||||
isAuthenticated: false,
|
||||
isLoaded: false,
|
||||
user: {},
|
||||
modules: []
|
||||
modules: [],
|
||||
settings: {
|
||||
currentProductId: "f4d98afd-d336-4332-8778-3c6945c81ea0",
|
||||
culture: "en-US",
|
||||
trustedDomains: [],
|
||||
trustedDomainsType: 1,
|
||||
timezone: "UTC",
|
||||
utcOffset: "00:00:00",
|
||||
utcHoursOffset: 0,
|
||||
homepage: config.homepage,
|
||||
datePattern: "M/d/yyyy",
|
||||
datePatternJQ: "00/00/0000",
|
||||
dateTimePattern: "dddd, MMMM d, yyyy h:mm:ss tt",
|
||||
datepicker: {
|
||||
datePattern: "mm/dd/yy",
|
||||
dateTimePattern: "DD, mm dd, yy h:mm:ss tt",
|
||||
timePattern: "h:mm tt"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const authReducer = (state = initialState, action) => {
|
||||
@ -19,6 +38,10 @@ const authReducer = (state = initialState, action) => {
|
||||
return Object.assign({}, state, {
|
||||
modules: action.modules
|
||||
});
|
||||
case SET_SETTINGS:
|
||||
return Object.assign({}, state, {
|
||||
settings: { ...state.settings, ...action.settings }
|
||||
});
|
||||
case SET_IS_LOADED:
|
||||
return Object.assign({}, state, {
|
||||
isLoaded: action.isLoaded
|
||||
|
@ -2,15 +2,13 @@ import { combineReducers } from 'redux';
|
||||
import authReducer from './auth/reducers';
|
||||
import peopleReducer from './people/reducers';
|
||||
import profileReducer from './profile/reducers';
|
||||
import settingsReducer from './settings/reducer';
|
||||
import { reducer as formReducer } from 'redux-form';
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
auth: authReducer,
|
||||
people: peopleReducer,
|
||||
profile: profileReducer,
|
||||
form: formReducer,
|
||||
settings: settingsReducer
|
||||
form: formReducer
|
||||
});
|
||||
|
||||
export default rootReducer;
|
@ -26,6 +26,12 @@ export function getModulesList() {
|
||||
});
|
||||
};
|
||||
|
||||
export function getSettings() {
|
||||
return IS_FAKE
|
||||
? fakeApi.getSettings()
|
||||
: axios.get(`${API_URL}/settings.json`);
|
||||
};
|
||||
|
||||
export function getUser(userId) {
|
||||
return IS_FAKE ? fakeApi.getUser() : axios.get(`${API_URL}/people/${userId || "@self"}.json`);
|
||||
};
|
||||
|
@ -39,6 +39,20 @@ export function getModulesList() {
|
||||
return fakeResponse(data);
|
||||
};
|
||||
|
||||
export function getSettings() {
|
||||
const data = {
|
||||
"timezone": "Russian Standard Time;180;(UTC+03:00) Moscow, St. Petersburg;Russia TZ 2 Standard Time;Russia TZ 2 Daylight Time;[01:01:0001;12:31:2010;60;[0;02:00:00;3;5;0;];[0;03:00:00;10;5;0;];][01:01:2011;12:31:2011;60;[0;02:00:00;3;5;0;];[0;00:00:00;1;1;6;];][01:01:2012;12:31:2012;0;[1;00:00:00;1;1;];[1;00:00:00.001;1;1;];60;][01:01:2013;12:31:2013;0;[1;00:00:00;1;1;];[1;00:00:00.001;1;1;];60;][01:01:2014;12:31:2014;60;[0;00:00:00;1;1;3;];[0;02:00:00;10;5;0;];];",
|
||||
"trustedDomains": [],
|
||||
"trustedDomainsType": 1,
|
||||
"culture": "ru-RU",
|
||||
"utcOffset": "03:00:00",
|
||||
"utcHoursOffset": 3
|
||||
};
|
||||
|
||||
return fakeResponse(data);
|
||||
};
|
||||
|
||||
|
||||
export function getUser() {
|
||||
const data = {
|
||||
"index": "a",
|
||||
|
@ -1,25 +0,0 @@
|
||||
import config from "../../../package.json";
|
||||
|
||||
const initialState = {
|
||||
currentProductId: "f4d98afd-d336-4332-8778-3c6945c81ea0",
|
||||
currentCulture: "en-US",
|
||||
currentCultureName: "en-us",
|
||||
homepage: config.homepage,
|
||||
datePattern: "M/d/yyyy",
|
||||
datePatternJQ: "00/00/0000",
|
||||
dateTimePattern: "dddd, MMMM d, yyyy h:mm:ss tt",
|
||||
datepicker: {
|
||||
datePattern: "mm/dd/yy",
|
||||
dateTimePattern: "DD, mm dd, yy h:mm:ss tt",
|
||||
timePattern: "h:mm tt"
|
||||
}
|
||||
};
|
||||
|
||||
const settingsReducer = (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default settingsReducer;
|
Loading…
Reference in New Issue
Block a user