50 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-07-18 15:53:56 +02:00
/**
*
* EditForm
*
*/
import React from 'react';
import { map } from 'lodash';
import Button from 'components/Button';
2017-07-18 15:53:56 +02:00
import EditFormSection from 'components/EditFormSection';
import styles from './styles.scss';
class EditForm extends React.Component { // eslint-disable-line react/prefer-stateless-function
render() {
return (
<div className={styles.editForm}>
<div className={styles.formContainer}>
{map(this.props.sections, (section, key) => {
let line;
// display hr only if next section
if (key + 1 < this.props.sections.length) {
line = <hr />;
}
return (
<div key={key}>
<EditFormSection section={section} values={this.props.values} handleChange={this.props.handleChange} />
2017-07-18 15:53:56 +02:00
{line}
</div>
)
})}
</div>
<div className={styles.buttonContainer}>
<Button label={"cancel"} buttonSize={"buttonMd"} buttonBackground={"secondary"} onClick={this.props.handleCancel} />
<Button label={"save"} buttonSize={"buttonLg"} buttonBackground={"primary"} onClick={this.props.handleSubmit} />
</div>
2017-07-18 15:53:56 +02:00
</div>
);
}
}
EditForm.propTypes = {
handleCancel: React.PropTypes.func,
2017-07-18 18:06:15 +02:00
handleChange: React.PropTypes.func.isRequired,
handleSubmit: React.PropTypes.func,
2017-07-18 18:06:15 +02:00
sections: React.PropTypes.array,
values: React.PropTypes.object,
2017-07-18 18:06:15 +02:00
};
2017-07-18 15:53:56 +02:00
export default EditForm;