Commit a89e2d9c authored by Valeriy Panov's avatar Valeriy Panov Committed by Matija Obreza
Browse files

Removed react-bootstrap

parent b2526ec6
import * as React from 'react';
import {Form, FormGroup, Col, FormControl, ControlLabel, Button} from 'react-bootstrap';
import * as _ from 'lodash';
import TextField from 'material-ui/TextField';
import Button from 'material-ui/Button';
import {saveCookies} from 'utilities';
const googleClientId: string = process.env.GOOGLE_CLIENT_ID;
......@@ -33,23 +36,13 @@ class Login extends React.Component<ILoginProps, any> {
saveCookies(data);
this.props.router.push('/dashboard');
}).catch((e) => {
if (e.error) {
this.setState({error: e.error, errorDescription: e.error_description});
}
const data = _.get(e, 'response.data');
if (data && data.error) {
this.setState({error: data.error, errorDescription: data.error_description});
}
});
}
protected showError = () => {
return this.state.error ? (
<FormGroup validationState="error">
<Col sm={ 2 } />
<Col componentClass={ ControlLabel } sm={ 10 }>
{ this.state.errorDescription }
</Col>
</FormGroup>
) : null;
}
private onSuccessGoogle = (response) => {
this.props.verifyGoogleTokenRequest(response.tokenId, googleClientId)
.then(({access_token}) => this.props.checkTokenRequest(access_token))
......@@ -71,35 +64,31 @@ class Login extends React.Component<ILoginProps, any> {
public render() {
return (
<Form horizontal onSubmit={ this.authorize }>
<FormGroup controlId="loginFormUsername">
<Col componentClass={ ControlLabel } sm={ 2 }>
Username
</Col>
<Col sm={ 10 }>
<FormControl type="text" placeholder="Username" value={ this.state.username } onChange={ this.handleUsername } />
</Col>
</FormGroup>
<FormGroup controlId="loginFormPassword">
<Col componentClass={ ControlLabel } sm={ 2 }>
Password
</Col>
<Col sm={ 10 }>
<FormControl type="password" placeholder="Password" value={ this.state.password } onChange={ this.handlePassword } />
</Col>
</FormGroup>
{ this.showError() }
<FormGroup>
<Col smOffset={ 2 } sm={ 10 }>
<Button type="submit" onClick={ this.authorize }>
Login
</Button>
</Col>
</FormGroup>
</Form>
<form onSubmit={ this.authorize }>
<TextField
label="Username"
value={ this.state.username }
onChange={ this.handleUsername }
fullWidth
/>
<TextField
label="Password"
type="password"
value={ this.state.password }
onChange={ this.handlePassword }
fullWidth
/>
{ this.state.error && <div style={ { color: 'red' } }>{ this.state.errorDescription }</div> }
<Button
raised
type="submit"
style={ { margin: '1rem 0 1rem 0' } }
>
Login
</Button>
</form>
);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment