fix: replace navigate with hardgoto in showUser (#37363)
* fix: use hardGoTo in ShowUser * refactor: clean up hardGoTo Rather than using both navigate and hardGoTo this imports hardGoTo as navigate and uses navigate everywhere Co-authored-by: mrugesh <1884376+raisedadead@users.noreply.github.com>
This commit is contained in:
committed by
mrugesh
parent
78b6fd1adf
commit
0e143c2caf
@ -1,6 +1,5 @@
|
|||||||
import React, { Fragment } from 'react';
|
import React, { Fragment } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { bindActionCreators } from 'redux';
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import { Grid, Button } from '@freecodecamp/react-bootstrap';
|
import { Grid, Button } from '@freecodecamp/react-bootstrap';
|
||||||
@ -11,7 +10,7 @@ import {
|
|||||||
signInLoadingSelector,
|
signInLoadingSelector,
|
||||||
userSelector,
|
userSelector,
|
||||||
isSignedInSelector,
|
isSignedInSelector,
|
||||||
hardGoTo
|
hardGoTo as navigate
|
||||||
} from '../redux';
|
} from '../redux';
|
||||||
import { submitNewAbout, updateUserFlag, verifyCert } from '../redux/settings';
|
import { submitNewAbout, updateUserFlag, verifyCert } from '../redux/settings';
|
||||||
import { createFlashMessage } from '../components/Flash/redux';
|
import { createFlashMessage } from '../components/Flash/redux';
|
||||||
@ -28,7 +27,6 @@ import DangerZone from '../components/settings/DangerZone';
|
|||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
createFlashMessage: PropTypes.func.isRequired,
|
createFlashMessage: PropTypes.func.isRequired,
|
||||||
hardGoTo: PropTypes.func.isRequired,
|
|
||||||
isSignedIn: PropTypes.bool.isRequired,
|
isSignedIn: PropTypes.bool.isRequired,
|
||||||
navigate: PropTypes.func.isRequired,
|
navigate: PropTypes.func.isRequired,
|
||||||
showLoading: PropTypes.bool.isRequired,
|
showLoading: PropTypes.bool.isRequired,
|
||||||
@ -98,32 +96,26 @@ const mapStateToProps = createSelector(
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch =>
|
const mapDispatchToProps = {
|
||||||
bindActionCreators(
|
createFlashMessage,
|
||||||
{
|
navigate,
|
||||||
createFlashMessage,
|
submitNewAbout,
|
||||||
hardGoTo,
|
toggleNightMode: theme => updateUserFlag({ theme }),
|
||||||
navigate: location => dispatch(hardGoTo(location)),
|
updateInternetSettings: updateUserFlag,
|
||||||
submitNewAbout,
|
updateIsHonest: updateUserFlag,
|
||||||
toggleNightMode: theme => updateUserFlag({ theme }),
|
updatePortfolio: updateUserFlag,
|
||||||
updateInternetSettings: updateUserFlag,
|
updateQuincyEmail: sendQuincyEmail => updateUserFlag({ sendQuincyEmail }),
|
||||||
updateIsHonest: updateUserFlag,
|
verifyCert
|
||||||
updatePortfolio: updateUserFlag,
|
};
|
||||||
updateQuincyEmail: sendQuincyEmail => updateUserFlag({ sendQuincyEmail }),
|
|
||||||
verifyCert
|
|
||||||
},
|
|
||||||
dispatch
|
|
||||||
);
|
|
||||||
|
|
||||||
const createHandleSignoutClick = hardGoTo => e => {
|
const createHandleSignoutClick = navigate => e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return hardGoTo(`${apiLocation}/signout`);
|
return navigate(`${apiLocation}/signout`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export function ShowSettings(props) {
|
export function ShowSettings(props) {
|
||||||
const {
|
const {
|
||||||
createFlashMessage,
|
createFlashMessage,
|
||||||
hardGoTo,
|
|
||||||
isSignedIn,
|
isSignedIn,
|
||||||
submitNewAbout,
|
submitNewAbout,
|
||||||
toggleNightMode,
|
toggleNightMode,
|
||||||
@ -194,7 +186,7 @@ export function ShowSettings(props) {
|
|||||||
bsStyle='primary'
|
bsStyle='primary'
|
||||||
className='btn-invert'
|
className='btn-invert'
|
||||||
href={'/signout'}
|
href={'/signout'}
|
||||||
onClick={createHandleSignoutClick(hardGoTo)}
|
onClick={createHandleSignoutClick(navigate)}
|
||||||
>
|
>
|
||||||
Sign me out of freeCodeCamp
|
Sign me out of freeCodeCamp
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import React, { Component, Fragment } from 'react';
|
import React, { Component, Fragment } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { bindActionCreators } from 'redux';
|
|
||||||
import { navigate } from '@reach/router';
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import {
|
import {
|
||||||
@ -18,6 +16,7 @@ import Helmet from 'react-helmet';
|
|||||||
import { apiLocation } from '../../config/env.json';
|
import { apiLocation } from '../../config/env.json';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
hardGoTo as navigate,
|
||||||
isSignedInSelector,
|
isSignedInSelector,
|
||||||
userFetchStateSelector,
|
userFetchStateSelector,
|
||||||
userSelector,
|
userSelector,
|
||||||
@ -49,14 +48,10 @@ const mapStateToProps = createSelector(
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch =>
|
const mapDispatchToProps = {
|
||||||
bindActionCreators(
|
navigate,
|
||||||
{
|
reportUser
|
||||||
navigate,
|
};
|
||||||
reportUser
|
|
||||||
},
|
|
||||||
dispatch
|
|
||||||
);
|
|
||||||
|
|
||||||
class ShowUser extends Component {
|
class ShowUser extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -5,7 +5,7 @@ import { createSelector } from 'reselect';
|
|||||||
import { navigate as gatsbyNavigate } from 'gatsby';
|
import { navigate as gatsbyNavigate } from 'gatsby';
|
||||||
import { Button } from '@freecodecamp/react-bootstrap';
|
import { Button } from '@freecodecamp/react-bootstrap';
|
||||||
|
|
||||||
import { hardGoTo, isSignedInSelector } from '../../../redux';
|
import { hardGoTo as navigate, isSignedInSelector } from '../../../redux';
|
||||||
import { apiLocation } from '../../../../config/env.json';
|
import { apiLocation } from '../../../../config/env.json';
|
||||||
|
|
||||||
import { gtagReportConversion } from '../../../analytics/gtag';
|
import { gtagReportConversion } from '../../../analytics/gtag';
|
||||||
@ -18,9 +18,9 @@ const mapStateToProps = createSelector(
|
|||||||
isSignedIn
|
isSignedIn
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = {
|
||||||
navigate: location => dispatch(hardGoTo(location))
|
navigate
|
||||||
});
|
};
|
||||||
|
|
||||||
const createOnClick = (navigate, isSignedIn) => e => {
|
const createOnClick = (navigate, isSignedIn) => e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -12,7 +12,11 @@ import DonateOther from '../components/Donation/components/DonateOther';
|
|||||||
import DonateForm from '../components/Donation/components/DonateForm';
|
import DonateForm from '../components/Donation/components/DonateForm';
|
||||||
import DonateText from '../components/Donation/components/DonateText';
|
import DonateText from '../components/Donation/components/DonateText';
|
||||||
import PoweredByStripe from '../components/Donation/components/poweredByStripe';
|
import PoweredByStripe from '../components/Donation/components/poweredByStripe';
|
||||||
import { signInLoadingSelector, isSignedInSelector, hardGoTo } from '../redux';
|
import {
|
||||||
|
signInLoadingSelector,
|
||||||
|
isSignedInSelector,
|
||||||
|
hardGoTo as navigate
|
||||||
|
} from '../redux';
|
||||||
import { stripeScriptLoader } from '../utils/scriptLoaders';
|
import { stripeScriptLoader } from '../utils/scriptLoaders';
|
||||||
|
|
||||||
const mapStateToProps = createSelector(
|
const mapStateToProps = createSelector(
|
||||||
@ -24,9 +28,9 @@ const mapStateToProps = createSelector(
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = {
|
||||||
navigate: location => dispatch(hardGoTo(location))
|
navigate
|
||||||
});
|
};
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
isSignedIn: PropTypes.bool.isRequired,
|
isSignedIn: PropTypes.bool.isRequired,
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { bindActionCreators } from 'redux';
|
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
@ -11,7 +10,7 @@ import {
|
|||||||
signInLoadingSelector,
|
signInLoadingSelector,
|
||||||
userSelector,
|
userSelector,
|
||||||
isSignedInSelector,
|
isSignedInSelector,
|
||||||
hardGoTo
|
hardGoTo as navigate
|
||||||
} from '../redux';
|
} from '../redux';
|
||||||
|
|
||||||
import Loader from '../components/helpers/Loader';
|
import Loader from '../components/helpers/Loader';
|
||||||
@ -27,17 +26,11 @@ const mapStateToProps = createSelector(
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch =>
|
const mapDispatchToProps = {
|
||||||
bindActionCreators(
|
navigate
|
||||||
{
|
};
|
||||||
hardGoTo,
|
|
||||||
navigate: location => dispatch(hardGoTo(location))
|
|
||||||
},
|
|
||||||
dispatch
|
|
||||||
);
|
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
hardGoTo: PropTypes.func.isRequired,
|
|
||||||
isSignedIn: PropTypes.bool.isRequired,
|
isSignedIn: PropTypes.bool.isRequired,
|
||||||
navigate: PropTypes.func.isRequired,
|
navigate: PropTypes.func.isRequired,
|
||||||
showLoading: PropTypes.bool.isRequired,
|
showLoading: PropTypes.bool.isRequired,
|
||||||
|
Reference in New Issue
Block a user