1- import React , { Component } from 'react' ;
2- import Router from 'next/router' ;
3- import withRedux from 'next-redux-wrapper' ;
1+ import React , { Component } from "react" ;
2+ import Router from "next/router" ;
43
5- import initStore from '../src/store' ;
6- import { SignUpLink } from './signup' ;
7- import { PasswordForgetLink } from './pw-forget' ;
8- import { AppWithAuthentication } from '../src/components/App' ;
9- import { auth } from '../src/firebase' ;
10- import * as routes from '../src/constants/routes' ;
4+ import { SignUpLink } from "./signup" ;
5+ import { PasswordForgetLink } from "./pw-forget" ;
6+ import { AppWithAuthentication } from "../src/components/App" ;
7+ import { auth } from "../src/firebase" ;
8+ import * as routes from "../src/constants/routes" ;
119
12- const SignInPage = ( ) =>
10+ const SignInPage = ( ) => (
1311 < AppWithAuthentication >
1412 < h1 > SignIn</ h1 >
1513 < SignInForm />
1614 < PasswordForgetLink />
1715 < SignUpLink />
1816 </ AppWithAuthentication >
17+ ) ;
1918
2019const updateByPropertyName = ( propertyName , value ) => ( ) => ( {
21- [ propertyName ] : value ,
20+ [ propertyName ] : value
2221} ) ;
2322
2423const INITIAL_STATE = {
25- email : '' ,
26- password : '' ,
27- error : null ,
24+ email : "" ,
25+ password : "" ,
26+ error : null
2827} ;
2928
3029class SignInForm extends Component {
@@ -34,61 +33,55 @@ class SignInForm extends Component {
3433 this . state = { ...INITIAL_STATE } ;
3534 }
3635
37- onSubmit = ( event ) => {
38- const {
39- email,
40- password,
41- } = this . state ;
36+ onSubmit = event => {
37+ const { email, password } = this . state ;
4238
43- auth . doSignInWithEmailAndPassword ( email , password )
39+ auth
40+ . doSignInWithEmailAndPassword ( email , password )
4441 . then ( ( ) => {
4542 this . setState ( ( ) => ( { ...INITIAL_STATE } ) ) ;
4643 Router . push ( routes . HOME ) ;
4744 } )
4845 . catch ( error => {
49- this . setState ( updateByPropertyName ( ' error' , error ) ) ;
46+ this . setState ( updateByPropertyName ( " error" , error ) ) ;
5047 } ) ;
5148
5249 event . preventDefault ( ) ;
53- }
50+ } ;
5451
5552 render ( ) {
56- const {
57- email,
58- password,
59- error,
60- } = this . state ;
53+ const { email, password, error } = this . state ;
6154
62- const isInvalid =
63- password === '' ||
64- email === '' ;
55+ const isInvalid = password === "" || email === "" ;
6556
6657 return (
6758 < form onSubmit = { this . onSubmit } >
6859 < input
6960 value = { email }
70- onChange = { event => this . setState ( updateByPropertyName ( 'email' , event . target . value ) ) }
61+ onChange = { event =>
62+ this . setState ( updateByPropertyName ( "email" , event . target . value ) )
63+ }
7164 type = "text"
7265 placeholder = "Email Address"
7366 />
7467 < input
7568 value = { password }
76- onChange = { event => this . setState ( updateByPropertyName ( 'password' , event . target . value ) ) }
69+ onChange = { event =>
70+ this . setState ( updateByPropertyName ( "password" , event . target . value ) )
71+ }
7772 type = "password"
7873 placeholder = "Password"
7974 />
8075 < button disabled = { isInvalid } type = "submit" >
8176 Sign In
8277 </ button >
8378
84- { error && < p > { error . message } </ p > }
79+ { error && < p > { error . message } </ p > }
8580 </ form >
8681 ) ;
8782 }
8883}
8984
90- export default withRedux ( initStore ) ( SignInPage ) ;
85+ export default SignInPage ;
9186
92- export {
93- SignInForm ,
94- } ;
87+ export { SignInForm } ;
0 commit comments