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" ;
4
3
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" ;
11
9
12
- const SignInPage = ( ) =>
10
+ const SignInPage = ( ) => (
13
11
< AppWithAuthentication >
14
12
< h1 > SignIn</ h1 >
15
13
< SignInForm />
16
14
< PasswordForgetLink />
17
15
< SignUpLink />
18
16
</ AppWithAuthentication >
17
+ ) ;
19
18
20
19
const updateByPropertyName = ( propertyName , value ) => ( ) => ( {
21
- [ propertyName ] : value ,
20
+ [ propertyName ] : value
22
21
} ) ;
23
22
24
23
const INITIAL_STATE = {
25
- email : '' ,
26
- password : '' ,
27
- error : null ,
24
+ email : "" ,
25
+ password : "" ,
26
+ error : null
28
27
} ;
29
28
30
29
class SignInForm extends Component {
@@ -34,61 +33,55 @@ class SignInForm extends Component {
34
33
this . state = { ...INITIAL_STATE } ;
35
34
}
36
35
37
- onSubmit = ( event ) => {
38
- const {
39
- email,
40
- password,
41
- } = this . state ;
36
+ onSubmit = event => {
37
+ const { email, password } = this . state ;
42
38
43
- auth . doSignInWithEmailAndPassword ( email , password )
39
+ auth
40
+ . doSignInWithEmailAndPassword ( email , password )
44
41
. then ( ( ) => {
45
42
this . setState ( ( ) => ( { ...INITIAL_STATE } ) ) ;
46
43
Router . push ( routes . HOME ) ;
47
44
} )
48
45
. catch ( error => {
49
- this . setState ( updateByPropertyName ( ' error' , error ) ) ;
46
+ this . setState ( updateByPropertyName ( " error" , error ) ) ;
50
47
} ) ;
51
48
52
49
event . preventDefault ( ) ;
53
- }
50
+ } ;
54
51
55
52
render ( ) {
56
- const {
57
- email,
58
- password,
59
- error,
60
- } = this . state ;
53
+ const { email, password, error } = this . state ;
61
54
62
- const isInvalid =
63
- password === '' ||
64
- email === '' ;
55
+ const isInvalid = password === "" || email === "" ;
65
56
66
57
return (
67
58
< form onSubmit = { this . onSubmit } >
68
59
< input
69
60
value = { email }
70
- onChange = { event => this . setState ( updateByPropertyName ( 'email' , event . target . value ) ) }
61
+ onChange = { event =>
62
+ this . setState ( updateByPropertyName ( "email" , event . target . value ) )
63
+ }
71
64
type = "text"
72
65
placeholder = "Email Address"
73
66
/>
74
67
< input
75
68
value = { password }
76
- onChange = { event => this . setState ( updateByPropertyName ( 'password' , event . target . value ) ) }
69
+ onChange = { event =>
70
+ this . setState ( updateByPropertyName ( "password" , event . target . value ) )
71
+ }
77
72
type = "password"
78
73
placeholder = "Password"
79
74
/>
80
75
< button disabled = { isInvalid } type = "submit" >
81
76
Sign In
82
77
</ button >
83
78
84
- { error && < p > { error . message } </ p > }
79
+ { error && < p > { error . message } </ p > }
85
80
</ form >
86
81
) ;
87
82
}
88
83
}
89
84
90
- export default withRedux ( initStore ) ( SignInPage ) ;
85
+ export default SignInPage ;
91
86
92
- export {
93
- SignInForm ,
94
- } ;
87
+ export { SignInForm } ;
0 commit comments