fix(Settings): Actually change state when nav to update email
This commit is contained in:
@ -12,8 +12,9 @@ import SocialSettings from './Social-Settings.jsx';
|
|||||||
import EmailSettings from './Email-Setting.jsx';
|
import EmailSettings from './Email-Setting.jsx';
|
||||||
import LanguageSettings from './Language-Settings.jsx';
|
import LanguageSettings from './Language-Settings.jsx';
|
||||||
import SettingsSkeleton from './Settings-Skeleton.jsx';
|
import SettingsSkeleton from './Settings-Skeleton.jsx';
|
||||||
|
import UpdateEmail from './routes/update-email';
|
||||||
|
|
||||||
import { toggleUserFlag } from './redux';
|
import { toggleUserFlag, showUpdateEmailViewSelector } from './redux';
|
||||||
import {
|
import {
|
||||||
toggleNightMode,
|
toggleNightMode,
|
||||||
updateTitle,
|
updateTitle,
|
||||||
@ -23,20 +24,10 @@ import {
|
|||||||
} from '../../redux';
|
} from '../../redux';
|
||||||
import ChildContainer from '../../Child-Container.jsx';
|
import ChildContainer from '../../Child-Container.jsx';
|
||||||
|
|
||||||
|
|
||||||
const mapDispatchToProps = {
|
|
||||||
updateTitle,
|
|
||||||
toggleNightMode,
|
|
||||||
toggleIsAvailableForHire: () => toggleUserFlag('isAvailableForHire'),
|
|
||||||
toggleIsLocked: () => toggleUserFlag('isLocked'),
|
|
||||||
toggleQuincyEmail: () => toggleUserFlag('sendQuincyEmail'),
|
|
||||||
toggleNotificationEmail: () => toggleUserFlag('sendNotificationEmail'),
|
|
||||||
toggleMonthlyEmail: () => toggleUserFlag('sendMonthlyEmail')
|
|
||||||
};
|
|
||||||
|
|
||||||
const mapStateToProps = createSelector(
|
const mapStateToProps = createSelector(
|
||||||
userSelector,
|
userSelector,
|
||||||
signInLoadingSelector,
|
signInLoadingSelector,
|
||||||
|
showUpdateEmailViewSelector,
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
username,
|
username,
|
||||||
@ -51,21 +42,33 @@ const mapStateToProps = createSelector(
|
|||||||
sendQuincyEmail
|
sendQuincyEmail
|
||||||
},
|
},
|
||||||
showLoading,
|
showLoading,
|
||||||
|
showUpdateEmailView
|
||||||
) => ({
|
) => ({
|
||||||
showLoading,
|
|
||||||
username,
|
|
||||||
email,
|
email,
|
||||||
isAvailableForHire,
|
isAvailableForHire,
|
||||||
isLocked,
|
|
||||||
isGithubCool,
|
isGithubCool,
|
||||||
isTwitter,
|
|
||||||
isLinkedIn,
|
isLinkedIn,
|
||||||
|
isLocked,
|
||||||
|
isTwitter,
|
||||||
sendMonthlyEmail,
|
sendMonthlyEmail,
|
||||||
sendNotificationEmail,
|
sendNotificationEmail,
|
||||||
sendQuincyEmail
|
sendQuincyEmail,
|
||||||
|
showLoading,
|
||||||
|
showUpdateEmailView,
|
||||||
|
username
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const mapDispatchToProps = {
|
||||||
|
toggleIsAvailableForHire: () => toggleUserFlag('isAvailableForHire'),
|
||||||
|
toggleIsLocked: () => toggleUserFlag('isLocked'),
|
||||||
|
toggleMonthlyEmail: () => toggleUserFlag('sendMonthlyEmail'),
|
||||||
|
toggleNightMode,
|
||||||
|
toggleNotificationEmail: () => toggleUserFlag('sendNotificationEmail'),
|
||||||
|
toggleQuincyEmail: () => toggleUserFlag('sendQuincyEmail'),
|
||||||
|
updateTitle
|
||||||
|
};
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
children: PropTypes.element,
|
children: PropTypes.element,
|
||||||
email: PropTypes.string,
|
email: PropTypes.string,
|
||||||
@ -80,6 +83,7 @@ const propTypes = {
|
|||||||
sendNotificationEmail: PropTypes.bool,
|
sendNotificationEmail: PropTypes.bool,
|
||||||
sendQuincyEmail: PropTypes.bool,
|
sendQuincyEmail: PropTypes.bool,
|
||||||
showLoading: PropTypes.bool,
|
showLoading: PropTypes.bool,
|
||||||
|
showUpdateEmailView: PropTypes.bool,
|
||||||
toggleIsAvailableForHire: PropTypes.func.isRequired,
|
toggleIsAvailableForHire: PropTypes.func.isRequired,
|
||||||
toggleIsLocked: PropTypes.func.isRequired,
|
toggleIsLocked: PropTypes.func.isRequired,
|
||||||
toggleMonthlyEmail: PropTypes.func.isRequired,
|
toggleMonthlyEmail: PropTypes.func.isRequired,
|
||||||
@ -109,34 +113,30 @@ export class Settings extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
children,
|
|
||||||
username,
|
|
||||||
isAvailableForHire,
|
|
||||||
isLocked,
|
|
||||||
isGithubCool,
|
|
||||||
isTwitter,
|
|
||||||
isLinkedIn,
|
|
||||||
showLoading,
|
|
||||||
email,
|
email,
|
||||||
|
isAvailableForHire,
|
||||||
|
isGithubCool,
|
||||||
|
isLinkedIn,
|
||||||
|
isLocked,
|
||||||
|
isTwitter,
|
||||||
sendMonthlyEmail,
|
sendMonthlyEmail,
|
||||||
sendNotificationEmail,
|
sendNotificationEmail,
|
||||||
sendQuincyEmail,
|
sendQuincyEmail,
|
||||||
|
showLoading,
|
||||||
|
showUpdateEmailView,
|
||||||
toggleIsAvailableForHire,
|
toggleIsAvailableForHire,
|
||||||
toggleNightMode,
|
|
||||||
toggleIsLocked,
|
toggleIsLocked,
|
||||||
toggleQuincyEmail,
|
|
||||||
toggleMonthlyEmail,
|
toggleMonthlyEmail,
|
||||||
toggleNotificationEmail
|
toggleNightMode,
|
||||||
|
toggleNotificationEmail,
|
||||||
|
toggleQuincyEmail,
|
||||||
|
username
|
||||||
} = this.props;
|
} = this.props;
|
||||||
if (!username && !showLoading) {
|
if (!username && !showLoading) {
|
||||||
return <SettingsSkeleton />;
|
return <SettingsSkeleton />;
|
||||||
}
|
}
|
||||||
if (children) {
|
if (showUpdateEmailView) {
|
||||||
return (
|
return <UpdateEmail />;
|
||||||
<ChildContainer>
|
|
||||||
{ children }
|
|
||||||
</ChildContainer>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<ChildContainer>
|
<ChildContainer>
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
import { isLocationAction } from 'redux-first-router';
|
||||||
import {
|
import {
|
||||||
|
addNS,
|
||||||
createAction,
|
createAction,
|
||||||
createTypes,
|
createTypes
|
||||||
handleActions
|
|
||||||
} from 'berkeleys-redux-utils';
|
} from 'berkeleys-redux-utils';
|
||||||
|
|
||||||
import userUpdateEpic from './update-user-epic.js';
|
import userUpdateEpic from './update-user-epic.js';
|
||||||
@ -19,6 +20,7 @@ export const types = createTypes([
|
|||||||
'onRouteUpdateEmail'
|
'onRouteUpdateEmail'
|
||||||
], 'settings');
|
], 'settings');
|
||||||
|
|
||||||
|
|
||||||
export const onRouteSettings = createAction(types.onRouteSettings);
|
export const onRouteSettings = createAction(types.onRouteSettings);
|
||||||
export const onRouteUpdateEmail = createAction(types.onRouteUpdateEmail);
|
export const onRouteUpdateEmail = createAction(types.onRouteUpdateEmail);
|
||||||
export const toggleUserFlag = createAction(types.toggleUserFlag);
|
export const toggleUserFlag = createAction(types.toggleUserFlag);
|
||||||
@ -33,10 +35,28 @@ const defaultState = {
|
|||||||
showUpdateEmailView: false
|
showUpdateEmailView: false
|
||||||
};
|
};
|
||||||
|
|
||||||
export default handleActions(
|
const getNS = state => state[ns];
|
||||||
() => ({
|
export const showUpdateEmailViewSelector =
|
||||||
[types.onRouteSettings]: state => ({ ...state, showUpdateEmailView: true })
|
state => getNS(state).showUpdateEmailView;
|
||||||
}),
|
|
||||||
defaultState,
|
export default addNS(
|
||||||
ns
|
ns,
|
||||||
|
function settingsRouteReducer(state = defaultState, action) {
|
||||||
|
if (isLocationAction(action)) {
|
||||||
|
const { type } = action;
|
||||||
|
if (type === types.onRouteUpdateEmail) {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
showUpdateEmailView: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (state.showUpdateEmailView) {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
showUpdateEmailView: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
@ -1,8 +1 @@
|
|||||||
import UpdateEmail from './Update-Email.jsx';
|
export { default } from './Update-Email.jsx';
|
||||||
|
|
||||||
export default function updateEmailRoute() {
|
|
||||||
return [{
|
|
||||||
path: 'update-email',
|
|
||||||
component: UpdateEmail
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user