From ed7d3d662292cbbf58fa2e0da4a93450da4cbd6b Mon Sep 17 00:00:00 2001 From: Nikolai R Kristiansen Date: Wed, 9 Aug 2017 00:46:25 +0200 Subject: [PATCH] chore: 4 spaces and reformat --- src/modules/login/Login.js | 245 +++++++++++++++++++------------------ 1 file changed, 125 insertions(+), 120 deletions(-) diff --git a/src/modules/login/Login.js b/src/modules/login/Login.js index 6f7d615..51f226b 100644 --- a/src/modules/login/Login.js +++ b/src/modules/login/Login.js @@ -1,139 +1,144 @@ -import React, { Component } from 'react'; +import React, {Component} from 'react'; import {StyleSheet, View} from 'react-native'; -import { Container, Header, Content, Form, Item, Input, Label, Spinner, Button, Text as NBText, Icon} from 'native-base'; +import {Container, Header, Content, Form, Item, Input, Label, Spinner, Button, Text as NBText, Icon} from 'native-base'; export default class Login extends Component { - constructor(props) { - super(props); - this.state = { - email: '', - password: '' - } - } - - emailInput() { - if(this.props.loginError && this.props.loginError.username) { - return - - { - this.passwordInputEl._root.focus(); - }} - /> - ; + constructor(props) { + super(props); + this.state = { + email: '', + password: '' + } } - return - - { - this.passwordInputEl._root.focus(); - }} - /> - ; - } + emailInput() { + if (this.props.loginError && this.props.loginError.username) { + return + + { + this.passwordInputEl._root.focus(); + }} + /> + ; + } - passwordInput() { - if(this.props.loginError && this.props.loginError.password) { - return - - { this.passwordInputEl = input; }} - onChangeText={this.handlePassword} - onSubmitEditing={this.onLoginPress} - /> - + return + + { + this.passwordInputEl._root.focus(); + }} + /> + ; } - return - - { this.passwordInputEl = input; }} - onChangeText={this.handlePassword} - onSubmitEditing={this.onLoginPress} - /> - - } - render() { - return ( - - -
- {this.emailInput()} - {this.passwordInput()} - {this.showError()} - - {this.showSpinner()} -
-
-
- ); - } - - showError= () => { - if (this.props.loginError) { - const err = this.props.loginError.non_field_errors; - let errorFormatted = err ? err[0] : 'Feil brukernavn eller passord, prøv igjen...'; - // TODO: Format these and highlight error fields - return {errorFormatted} + passwordInput() { + if (this.props.loginError && this.props.loginError.password) { + return + + { + this.passwordInputEl = input; + }} + onChangeText={this.handlePassword} + onSubmitEditing={this.onLoginPress} + /> + + } + return + + { + this.passwordInputEl = input; + }} + onChangeText={this.handlePassword} + onSubmitEditing={this.onLoginPress} + /> + } - else { - return + + render() { + return ( + + +
+ {this.emailInput()} + {this.passwordInput()} + {this.showError()} + + {this.showSpinner()} +
+
+
+ ); } - }; - showSpinner = () => { - if (this.props.isLoggingIn) { - return - } - }; + showError = () => { + if (this.props.loginError) { + const err = this.props.loginError.non_field_errors; + let errorFormatted = err ? err[0] : 'Feil brukernavn eller passord, prøv igjen...'; + // TODO: Format these and highlight error fields + return {errorFormatted} + } + else { + return + } + }; - handleEmail = (text) => { - this.setState({ email: text }) - }; + showSpinner = () => { + if (this.props.isLoggingIn) { + return + } + }; - handlePassword = (text) => { - this.setState({ password: text }) - }; + handleEmail = (text) => { + this.setState({email: text}) + }; - onLoginPress = () => { - this.props.requestLogin(this.state.email, this.state.password) - }; + handlePassword = (text) => { + this.setState({password: text}) + }; + + onLoginPress = () => { + this.props.requestLogin(this.state.email, this.state.password) + }; } const styles = StyleSheet.create({ - container: { - flex: 1, - justifyContent: 'center', - backgroundColor: 'white' - }, - input: { - width: 320, - fontSize: 20, - height: 52, - }, - loginButton: { - marginVertical: 16, - marginHorizontal: 16 - }, - errorBox: { - marginVertical: 16, - }, - errorMessage: { - textAlign: 'center', - color: 'red', - } + container: { + flex: 1, + justifyContent: 'center', + backgroundColor: 'white' + }, + input: { + width: 320, + fontSize: 20, + height: 52, + }, + loginButton: { + marginVertical: 16, + marginHorizontal: 16 + }, + errorBox: { + marginVertical: 16, + }, + errorMessage: { + textAlign: 'center', + color: 'red', + } }); \ No newline at end of file