2017-07-18 15:53:56 +02:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* EditForm
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
import { map } from 'lodash';
|
2017-07-19 10:49:23 +02:00
|
|
|
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}>
|
2017-07-18 18:32:32 +02:00
|
|
|
<EditFormSection section={section} values={this.props.values} handleChange={this.props.handleChange} />
|
2017-07-18 15:53:56 +02:00
|
|
|
{line}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
2017-07-19 10:49:23 +02:00
|
|
|
<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 = {
|
2017-07-19 10:49:23 +02:00
|
|
|
handleCancel: React.PropTypes.func,
|
2017-07-18 18:06:15 +02:00
|
|
|
handleChange: React.PropTypes.func.isRequired,
|
2017-07-19 10:49:23 +02:00
|
|
|
handleSubmit: React.PropTypes.func,
|
2017-07-18 18:06:15 +02:00
|
|
|
sections: React.PropTypes.array,
|
2017-07-18 18:32:32 +02:00
|
|
|
values: React.PropTypes.object,
|
2017-07-18 18:06:15 +02:00
|
|
|
};
|
2017-07-18 15:53:56 +02:00
|
|
|
|
|
|
|
|
export default EditForm;
|