@@ -6,8 +6,8 @@ import { Button, Form, FormFeedback, Col, Row } from 'reactstrap';
66
77import { InputField , TextArea , SelectField , required } from '../../forms' ;
88
9- export const PostFormPart = ( { values, part} ) => {
10- switch ( values . type ) {
9+ export const PostFormPart = ( { values, part } ) => {
10+ switch ( values . type ) {
1111 case 'image' :
1212 return (
1313 < div >
@@ -17,11 +17,12 @@ export const PostFormPart = ({values, part}) => {
1717 name = { `${ part } .imageUrl` }
1818 placeholder = { 'Image url...' }
1919 component = { InputField }
20- /> < Field
21- name = { `${ part } .description` }
22- placeholder = { 'Image description...' }
23- component = { InputField }
24- />
20+ />
21+ < Field
22+ name = { `${ part } .description` }
23+ placeholder = { 'Image description...' }
24+ component = { InputField }
25+ />
2526 </ div >
2627 ) ;
2728 case 'text' :
@@ -33,23 +34,25 @@ export const PostFormPart = ({values, part}) => {
3334 component = { TextArea }
3435 />
3536 ) ;
36- } ;
37+ default :
38+ return null ;
39+ }
3740} ;
3841
3942export const PostFormParts = ( { parts, fields, meta : { error } } ) => (
4043 < div className = "my-3" >
4144 { fields . map ( ( part , index ) =>
42- < div >
45+ < div key = { index } >
4346 < hr />
44- < Row key = { index } >
47+ < Row >
4548 < Col xs = "10" >
4649 < PostFormPart values = { parts [ index ] } part = { part } />
4750 </ Col >
4851 < Col xs = "2" >
4952 < Button color = "danger" onClick = { ( ) => fields . remove ( index ) } > X</ Button >
5053 </ Col >
5154 </ Row >
52- </ div >
55+ </ div > ,
5356 ) }
5457 { error && < FormFeedback > { error } </ FormFeedback > }
5558 < Button onClick = { ( ) => fields . push ( { type : 'text' } ) } className = "mr-2" > Add Text</ Button >
@@ -104,7 +107,7 @@ const validate = (values) => {
104107
105108const selector = formValueSelector ( 'post' ) ;
106109
107- export const mapStateToProps = ( state ) => ( {
110+ export const mapStateToProps = state => ( {
108111 parts : selector ( state , 'parts' ) ,
109112} ) ;
110113
@@ -113,5 +116,5 @@ export default reduxForm({
113116 form : 'post' ,
114117 validate,
115118} ) (
116- connect ( mapStateToProps ) ( PostForm )
119+ connect ( mapStateToProps ) ( PostForm ) ,
117120) ;
0 commit comments