moved actions from web.common to web.client and people modules
This commit is contained in:
parent
4b9637c1ae
commit
781833d38d
@ -184,8 +184,8 @@ class PureInviteDialog extends React.Component {
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
settings: state.auth.settings.hasShortenService,
|
||||
userInvitationLink: state.auth.settings.inviteLinks.userLink,
|
||||
guestInvitationLink: state.auth.settings.inviteLinks.guestLink
|
||||
userInvitationLink: state.portal.inviteLinks.userLink,
|
||||
guestInvitationLink: state.portal.inviteLinks.guestLink
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -10,7 +10,8 @@ import App from "./App";
|
||||
import * as serviceWorker from "./serviceWorker";
|
||||
import { store as commonStore, constants } from "asc-web-common";
|
||||
import { getFilterByLocation } from "./helpers/converters";
|
||||
const { setIsLoaded, getUserInfo, setCurrentProductId, setCurrentProductHomePage, getPortalPasswordSettings, getPortalCultures, getPortalInviteLinks } = commonStore.auth.actions;
|
||||
import { getPortalInviteLinks } from './store/portal/actions';
|
||||
const { setIsLoaded, getUserInfo, setCurrentProductId, setCurrentProductHomePage, getPortalPasswordSettings, getPortalCultures } = commonStore.auth.actions;
|
||||
const { AUTH_KEY } = constants;
|
||||
|
||||
const token = localStorage.getItem(AUTH_KEY);
|
||||
|
24
products/ASC.People/Client/src/store/portal/actions.js
Normal file
24
products/ASC.People/Client/src/store/portal/actions.js
Normal file
@ -0,0 +1,24 @@
|
||||
import { api } from 'asc-web-common';
|
||||
|
||||
export const SET_INVITE_LINKS = "SET_INVITE_LINKS";
|
||||
|
||||
export function setInviteLinks(userLink, guestLink) {
|
||||
return {
|
||||
type: SET_INVITE_LINKS,
|
||||
payload: {
|
||||
userLink,
|
||||
guestLink
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function getPortalInviteLinks() {
|
||||
return (dispatch, getState) => {
|
||||
const { auth } = getState();
|
||||
if (!auth.user.isAdmin) return Promise.resolve();
|
||||
|
||||
return api.portal.getInvitationLinks().then(data => {
|
||||
dispatch(setInviteLinks(data.userLink, data.guestLink));
|
||||
});
|
||||
};
|
||||
};
|
18
products/ASC.People/Client/src/store/portal/reducers.js
Normal file
18
products/ASC.People/Client/src/store/portal/reducers.js
Normal file
@ -0,0 +1,18 @@
|
||||
import { SET_INVITE_LINKS } from "./actions";
|
||||
|
||||
const initialState = {
|
||||
inviteLinks: {}
|
||||
};
|
||||
|
||||
const profileReducer = (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case SET_INVITE_LINKS:
|
||||
return Object.assign({}, state, {
|
||||
inviteLinks: action.payload
|
||||
});
|
||||
default:
|
||||
return state;
|
||||
};
|
||||
}
|
||||
|
||||
export default profileReducer;
|
@ -2,6 +2,7 @@ import { combineReducers } from 'redux';
|
||||
import peopleReducer from './people/reducers';
|
||||
import profileReducer from './profile/reducers';
|
||||
import groupReducer from './group/reducers';
|
||||
import portalReducer from './portal/reducers';
|
||||
import { store } from 'asc-web-common';
|
||||
const { reducer: authReducer } = store.auth;
|
||||
|
||||
@ -9,7 +10,8 @@ const rootReducer = combineReducers({
|
||||
auth: authReducer,
|
||||
people: peopleReducer,
|
||||
profile: profileReducer,
|
||||
group: groupReducer
|
||||
group: groupReducer,
|
||||
portal: portalReducer
|
||||
});
|
||||
|
||||
export default rootReducer;
|
@ -5,7 +5,8 @@ import { PageLayout, Loader } from 'asc-web-components';
|
||||
import { connect } from 'react-redux';
|
||||
import PropTypes from 'prop-types';
|
||||
import { store } from 'asc-web-common';
|
||||
const { logout, changeEmail } = store.auth.actions;
|
||||
import { changeEmail } from '../../../../store/confirm/actions';
|
||||
const { logout } = store.auth.actions;
|
||||
|
||||
class ActivateEmail extends React.PureComponent {
|
||||
|
||||
@ -18,13 +19,13 @@ class ActivateEmail extends React.PureComponent {
|
||||
history.push(`/login/confirmed-email=${email}`);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log('activate email error', e);
|
||||
// console.log('activate email error', e);
|
||||
history.push(`/login/error=${e}`);
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
console.log('Activate email render');
|
||||
// console.log('Activate email render');
|
||||
return (
|
||||
<Loader className="pageLoader" type="rombs" size={40} />
|
||||
);
|
||||
|
@ -4,8 +4,7 @@ import { withTranslation } from 'react-i18next';
|
||||
import { PageLayout, Loader } from 'asc-web-components';
|
||||
import { connect } from 'react-redux';
|
||||
import PropTypes from 'prop-types';
|
||||
import { store } from 'asc-web-common';
|
||||
const { changeEmail } = store.auth.actions;
|
||||
import { changeEmail } from '../../../../store/confirm/actions';
|
||||
|
||||
class ChangeEmail extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
|
@ -14,8 +14,8 @@ import {
|
||||
Heading
|
||||
} from "asc-web-components";
|
||||
import { store } from "asc-web-common";
|
||||
import { getConfirmationInfo} from '../../../../store/confirm/actions';
|
||||
const { changePassword, logout } = store.auth.actions;
|
||||
import { getConfirmationInfo, changePassword } from '../../../../store/confirm/actions';
|
||||
const { logout } = store.auth.actions;
|
||||
|
||||
const BodyStyle = styled.form`
|
||||
margin: 70px auto 0 auto;
|
||||
|
@ -5,7 +5,8 @@ import { FieldContainer, Text, ComboBox, Loader, Button, toastr, Link, TextInput
|
||||
import styled from 'styled-components';
|
||||
import { Trans } from 'react-i18next';
|
||||
import { store } from 'asc-web-common';
|
||||
const { getPortalCultures, setLanguageAndTime, getPortalTimezones, setGreetingTitle, restoreGreetingTitle } = store.auth.actions;
|
||||
import { setLanguageAndTime, getPortalTimezones, setGreetingTitle, restoreGreetingTitle } from '../../../../../store/settings/actions';
|
||||
const { getPortalCultures } = store.auth.actions;
|
||||
|
||||
const mapCulturesToArray = (cultures, t) => {
|
||||
return cultures.map((culture) => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { api, store } from "asc-web-common";
|
||||
const { setCurrentUser, loadInitInfo, login, getPortalPasswordSettings } = store.auth.actions;
|
||||
const { setCurrentUser, loadInitInfo, login, getPortalPasswordSettings, setNewEmail, logout } = store.auth.actions;
|
||||
|
||||
export const SET_IS_CONFIRM_LOADED = "SET_IS_CONFIRM_LOADED";
|
||||
|
||||
@ -56,3 +56,19 @@ export function activateConfirmUser(
|
||||
.then(user => dispatch(setCurrentUser(user)));
|
||||
};
|
||||
}
|
||||
|
||||
export function changeEmail(userId, email, key) {
|
||||
return dispatch => {
|
||||
return api.people
|
||||
.changeEmail(userId, email, key)
|
||||
.then(user => dispatch(setNewEmail(user.email)));
|
||||
};
|
||||
};
|
||||
|
||||
export function changePassword(userId, password, key) {
|
||||
return dispatch => {
|
||||
return api.people
|
||||
.changePassword(userId, password, key)
|
||||
.then(() => logout(dispatch));
|
||||
};
|
||||
};
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { api } from "asc-web-common";
|
||||
import { api, store } from "asc-web-common";
|
||||
import axios from "axios";
|
||||
import { getSelectorOptions, getUserOptions } from "./selectors";
|
||||
const { Filter } = api;
|
||||
const { setPortalLanguageAndTime, setTimezones, setGreetingSettings } = store.auth.actions;
|
||||
|
||||
export const SET_USERS = "SET_USERS";
|
||||
export const SET_ADMINS = "SET_ADMINS";
|
||||
@ -178,3 +179,35 @@ export function getWhiteLabelLogoUrls() {
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function setLanguageAndTime(lng, timeZoneID) {
|
||||
return dispatch => {
|
||||
return api.settings
|
||||
.setLanguageAndTime(lng, timeZoneID)
|
||||
.then(() => dispatch(setPortalLanguageAndTime({ lng, timeZoneID })));
|
||||
};
|
||||
};
|
||||
|
||||
export function getPortalTimezones() {
|
||||
return dispatch => {
|
||||
return api.settings.getPortalTimezones().then(timezones => {
|
||||
dispatch(setTimezones(timezones));
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export function setGreetingTitle(greetingTitle) {
|
||||
return dispatch => {
|
||||
return api.settings.setGreetingSettings(greetingTitle).then(() => {
|
||||
dispatch(setGreetingSettings(greetingTitle));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function restoreGreetingTitle() {
|
||||
return dispatch => {
|
||||
return api.settings.restoreGreetingSettings().then(res => {
|
||||
dispatch(setGreetingSettings(res.companyName));
|
||||
});
|
||||
};
|
||||
}
|
@ -14,7 +14,6 @@ export const GET_TIMEZONES = "GET_TIMEZONES";
|
||||
export const SET_CURRENT_PRODUCT_ID = "SET_CURRENT_PRODUCT_ID";
|
||||
export const SET_CURRENT_PRODUCT_HOME_PAGE = "SET_CURRENT_PRODUCT_HOME_PAGE";
|
||||
export const SET_GREETING_SETTINGS = "SET_GREETING_SETTINGS";
|
||||
export const SET_INVITE_LINKS = "SET_INVITE_LINKS";
|
||||
|
||||
export function setCurrentUser(user) {
|
||||
return {
|
||||
@ -58,16 +57,6 @@ export function setPasswordSettings(passwordSettings) {
|
||||
};
|
||||
}
|
||||
|
||||
export function setInviteLinks(userLink, guestLink) {
|
||||
return {
|
||||
type: SET_INVITE_LINKS,
|
||||
payload: {
|
||||
userLink,
|
||||
guestLink
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function setNewEmail(email) {
|
||||
return {
|
||||
type: SET_NEW_EMAIL,
|
||||
@ -153,22 +142,6 @@ export function logout() {
|
||||
};
|
||||
}
|
||||
|
||||
export function changePassword(userId, password, key) {
|
||||
return dispatch => {
|
||||
return api.people
|
||||
.changePassword(userId, password, key)
|
||||
.then(() => logout(dispatch));
|
||||
};
|
||||
}
|
||||
|
||||
export function changeEmail(userId, email, key) {
|
||||
return dispatch => {
|
||||
return api.people
|
||||
.changeEmail(userId, email, key)
|
||||
.then(user => dispatch(setNewEmail(user.email)));
|
||||
};
|
||||
}
|
||||
|
||||
export function getPortalCultures(dispatch = null) {
|
||||
return dispatch
|
||||
? api.settings.getPortalCultures().then(cultures => {
|
||||
@ -181,51 +154,8 @@ export function getPortalCultures(dispatch = null) {
|
||||
};
|
||||
}
|
||||
|
||||
export function setLanguageAndTime(lng, timeZoneID) {
|
||||
return dispatch => {
|
||||
return api.settings
|
||||
.setLanguageAndTime(lng, timeZoneID)
|
||||
.then(() => dispatch(setPortalLanguageAndTime({ lng, timeZoneID })));
|
||||
};
|
||||
}
|
||||
|
||||
export function getPortalTimezones() {
|
||||
return dispatch => {
|
||||
return api.settings.getPortalTimezones().then(timezones => {
|
||||
dispatch(setTimezones(timezones));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function setGreetingTitle(greetingTitle) {
|
||||
return dispatch => {
|
||||
return api.settings.setGreetingSettings(greetingTitle).then(() => {
|
||||
dispatch(setGreetingSettings(greetingTitle));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function restoreGreetingTitle() {
|
||||
return dispatch => {
|
||||
return api.settings.restoreGreetingSettings().then(res => {
|
||||
dispatch(setGreetingSettings(res.companyName));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function getPortalPasswordSettings(dispatch, confirmKey = null) {
|
||||
return api.settings.getPortalPasswordSettings(confirmKey).then(settings => {
|
||||
dispatch(setPasswordSettings(settings));
|
||||
});
|
||||
}
|
||||
|
||||
export function getPortalInviteLinks() {
|
||||
return (dispatch, getState) => {
|
||||
const { auth } = getState();
|
||||
if (!auth.user.isAdmin) return Promise.resolve();
|
||||
|
||||
return api.portal.getInvitationLinks().then(data => {
|
||||
dispatch(setInviteLinks(data.userLink, data.guestLink));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import {
|
||||
SET_CURRENT_USER, SET_MODULES, SET_SETTINGS, SET_IS_LOADED, LOGOUT, SET_PASSWORD_SETTINGS, SET_NEW_EMAIL,
|
||||
GET_PORTAL_CULTURES, SET_PORTAL_LANGUAGE_AND_TIME, GET_TIMEZONES, SET_CURRENT_PRODUCT_ID, SET_CURRENT_PRODUCT_HOME_PAGE, SET_GREETING_SETTINGS,
|
||||
SET_INVITE_LINKS
|
||||
} from './actions';
|
||||
import isEmpty from "lodash/isEmpty";
|
||||
|
||||
@ -56,10 +55,6 @@ const authReducer = (state = initialState, action) => {
|
||||
return Object.assign({}, state, {
|
||||
settings: { ...state.settings, passwordSettings: action.passwordSettings }
|
||||
});
|
||||
case SET_INVITE_LINKS:
|
||||
return Object.assign({}, state, {
|
||||
settings: { ...state.settings, inviteLinks: action.payload }
|
||||
});
|
||||
case SET_IS_LOADED:
|
||||
return Object.assign({}, state, {
|
||||
isLoaded: action.isLoaded
|
||||
|
Loading…
Reference in New Issue
Block a user