-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
61 lines (52 loc) · 1.4 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { Field, reduxForm } from 'redux-form'
import { Button } from 'react-toolbox/lib/button'
import ImageUploader from 'components/ImageUploader'
import Input from 'components/Input'
class EditProfile extends Component {
constructor (props) {
super(props)
this.handleSubmit = this.handleSubmit.bind(this)
}
handleSubmit (values) {
console.log(values)
}
render () {
const { handleSubmit } = this.props
return (
<section>
<h1>Edit Profile</h1>
<form onSubmit={handleSubmit(this.handleSubmit)}>
<Field
name='photo'
component={ImageUploader}
/>
<Field
name='username'
label='Username'
component={Input}
/>
<Field
name='email'
label='Email'
component={Input}
/>
<Button raised type='submit' className='button' primary label='Save' />
</form>
</section>
)
}
}
EditProfile.propTypes = {
dispatch: PropTypes.func.isRequired,
handleSubmit: PropTypes.func.isRequired
}
const l1 = reduxForm({ form: 'EditProfile' })(EditProfile)
const l2 = connect(() => ({
initialValues: {
photo: 'https://avatars3.githubusercontent.com/u/32059990?s=200&v=4'
}
}))(l1)
export default l2