fix(client): remove auto redirect on report user page (#38974)

This commit is contained in:
Tom
2020-06-01 12:33:53 -05:00
committed by GitHub
parent 959608e85e
commit 31614fa9a6
2 changed files with 14 additions and 42 deletions

View File

@ -13,7 +13,7 @@ import {
} from '@freecodecamp/react-bootstrap'; } from '@freecodecamp/react-bootstrap';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
import { apiLocation } from '../../config/env.json'; import Login from '../components/Header/components/Login';
import { import {
hardGoTo as navigate, hardGoTo as navigate,
@ -24,6 +24,8 @@ import {
} from '../redux'; } from '../redux';
import { Spacer, Loader, FullWidthRow } from '../components/helpers'; import { Spacer, Loader, FullWidthRow } from '../components/helpers';
import './showuser.css';
const propTypes = { const propTypes = {
email: PropTypes.string, email: PropTypes.string,
isSignedIn: PropTypes.bool, isSignedIn: PropTypes.bool,
@ -57,21 +59,13 @@ class ShowUser extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.timer = null;
this.state = { this.state = {
textarea: '', textarea: ''
time: 5
}; };
this.handleChange = this.handleChange.bind(this); this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
} }
componentWillUnmount() {
if (this.timer) {
clearInterval(this.timer);
}
}
handleChange(e) { handleChange(e) {
const textarea = e.target.value.slice(); const textarea = e.target.value.slice();
return this.setState({ return this.setState({
@ -86,17 +80,6 @@ class ShowUser extends Component {
return reportUser({ username, reportDescription }); return reportUser({ username, reportDescription });
} }
setNavigationTimer(navigate) {
if (!this.timer) {
this.timer = setInterval(() => {
if (this.state.time <= 0) {
navigate(`${apiLocation}/signin`);
}
this.setState({ time: this.state.time - 1 });
}, 1000);
}
}
render() { render() {
const { username, isSignedIn, userFetchState, email } = this.props; const { username, isSignedIn, userFetchState, email } = this.props;
const { pending, complete, errored } = userFetchState; const { pending, complete, errored } = userFetchState;
@ -105,37 +88,22 @@ class ShowUser extends Component {
} }
if ((complete || errored) && !isSignedIn) { if ((complete || errored) && !isSignedIn) {
const { navigate } = this.props;
this.setNavigationTimer(navigate);
return ( return (
<main> <main>
<FullWidthRow> <FullWidthRow>
<Spacer size={2} /> <Spacer size={2} />
<Panel bsStyle='info'> <Panel bsStyle='info' className='text-center'>
<Panel.Heading> <Panel.Heading>
<Panel.Title componentClass='h3'> <Panel.Title componentClass='h3'>
You need to be signed in to report a user You need to be signed in to report a user
</Panel.Title> </Panel.Title>
</Panel.Heading> </Panel.Heading>
<Panel.Body className='text-center'> <Panel.Body className='text-center'>
<Spacer /> <Spacer size={2} />
<p> <Col md={6} mdOffset={3} sm={8} smOffset={2} xs={12}>
You will be redirected to sign in to freeCodeCamp.org <Login block={true}>Click here to sign in</Login>
automatically in {this.state.time} seconds </Col>
</p> <Spacer size={3} />
<p>
<Button
bsStyle='default'
href='/signin'
onClick={e => {
e.preventDefault();
return navigate(`${apiLocation}/signin`);
}}
>
Or click here if you do not want to wait
</Button>
</p>
<Spacer />
</Panel.Body> </Panel.Body>
</Panel> </Panel>
</FullWidthRow> </FullWidthRow>

View File

@ -0,0 +1,4 @@
/* remove bootstrap margin*/
.row {
margin: 0;
}