2017-11-07 19:58:08 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* EditForm
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
2017-11-08 16:06:21 +01:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { get } from 'lodash';
|
2017-11-07 19:58:08 +01:00
|
|
|
|
2018-06-14 12:33:57 +02:00
|
|
|
import LoadingIndicator from 'components/LoadingIndicator';
|
2018-02-05 17:24:15 +01:00
|
|
|
import Input from 'components/InputsIndex';
|
2017-11-07 19:58:08 +01:00
|
|
|
|
|
|
|
import styles from './styles.scss';
|
|
|
|
|
|
|
|
class EditForm extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
2018-03-12 15:56:25 +01:00
|
|
|
generateSelectOptions = () => (
|
|
|
|
Object.keys(get(this.props.values, 'roles', [])).reduce((acc, current) => {
|
|
|
|
const option = {
|
|
|
|
id: get(this.props.values.roles, [current, 'name']),
|
|
|
|
value: get(this.props.values.roles, [current, 'type']),
|
|
|
|
};
|
|
|
|
acc.push(option);
|
|
|
|
return acc;
|
|
|
|
}, [])
|
|
|
|
)
|
|
|
|
|
2017-11-07 19:58:08 +01:00
|
|
|
render() {
|
2018-06-14 12:33:57 +02:00
|
|
|
if (this.props.showLoaders) {
|
|
|
|
return (
|
|
|
|
<div className={styles.editForm}>
|
|
|
|
<LoadingIndicator />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-11-07 19:58:08 +01:00
|
|
|
return (
|
|
|
|
<div className={styles.editForm}>
|
2018-03-12 15:56:25 +01:00
|
|
|
<div className="row">
|
|
|
|
<Input
|
|
|
|
inputDescription={{ id: 'users-permissions.EditForm.inputSelect.description.role' }}
|
|
|
|
inputClassName={styles.inputStyle}
|
|
|
|
label={{ id: 'users-permissions.EditForm.inputSelect.label.role' }}
|
|
|
|
name="settings.default_role"
|
|
|
|
onChange={this.props.onChange}
|
|
|
|
selectOptions={this.generateSelectOptions()}
|
|
|
|
type="select"
|
|
|
|
value={get(this.props.values.settings, 'default_role')}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className={styles.separator} />
|
2017-11-07 19:58:08 +01:00
|
|
|
<div className="row">
|
|
|
|
<Input
|
2018-02-05 17:24:15 +01:00
|
|
|
label={{ id: 'users-permissions.EditForm.inputToggle.label.email' }}
|
|
|
|
inputDescription={{ id: 'users-permissions.EditForm.inputToggle.description.email' }}
|
2018-03-12 15:56:25 +01:00
|
|
|
name="settings.unique_email"
|
2017-11-08 16:06:21 +01:00
|
|
|
onChange={this.props.onChange}
|
2017-11-07 19:58:08 +01:00
|
|
|
type="toggle"
|
2018-03-12 15:56:25 +01:00
|
|
|
value={get(this.props.values.settings, 'unique_email')}
|
2017-11-07 19:58:08 +01:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className={styles.separator} />
|
2018-01-18 15:26:33 +01:00
|
|
|
{/*}
|
2017-11-07 19:58:08 +01:00
|
|
|
<div className="row">
|
|
|
|
<Input
|
|
|
|
customBootstrapClass="col-md-3"
|
|
|
|
label="users-permissions.EditForm.inputSelect.subscriptions.label"
|
|
|
|
inputDescription="users-permissions.EditForm.inputSelect.subscriptions.description"
|
|
|
|
name="subscriptions"
|
2017-11-08 16:06:21 +01:00
|
|
|
onChange={this.props.onChange}
|
2017-11-14 10:59:57 +01:00
|
|
|
type="number"
|
2017-11-07 19:58:08 +01:00
|
|
|
validations={{}}
|
2017-11-08 16:06:21 +01:00
|
|
|
value={get(this.props.values, 'subscriptions')}
|
2017-11-07 19:58:08 +01:00
|
|
|
/>
|
2017-11-08 16:06:21 +01:00
|
|
|
<div className="col-md-3" />
|
2017-11-07 19:58:08 +01:00
|
|
|
<Input
|
|
|
|
customBootstrapClass="col-md-3"
|
|
|
|
label="users-permissions.EditForm.inputSelect.durations.label"
|
|
|
|
inputDescription="users-permissions.EditForm.inputSelect.durations.description"
|
|
|
|
name="durations"
|
2017-11-08 16:06:21 +01:00
|
|
|
onChange={this.props.onChange}
|
2017-11-14 10:59:57 +01:00
|
|
|
type="number"
|
2017-11-07 19:58:08 +01:00
|
|
|
validations={{}}
|
2017-11-08 16:06:21 +01:00
|
|
|
value={get(this.props.values, 'durations')}
|
2017-11-07 19:58:08 +01:00
|
|
|
/>
|
|
|
|
</div>
|
2018-01-18 15:26:33 +01:00
|
|
|
<div className={styles.separator} />
|
|
|
|
*/}
|
|
|
|
<div className="row">
|
|
|
|
<Input
|
2018-02-05 17:24:15 +01:00
|
|
|
label={{ id: 'users-permissions.EditForm.inputToggle.label.sign-up' }}
|
|
|
|
inputDescription={{ id: 'users-permissions.EditForm.inputToggle.description.sign-up' }}
|
2018-03-12 15:56:25 +01:00
|
|
|
name="settings.allow_register"
|
2018-01-18 15:26:33 +01:00
|
|
|
onChange={this.props.onChange}
|
|
|
|
type="toggle"
|
2018-03-12 15:56:25 +01:00
|
|
|
value={get(this.props.values.settings, 'allow_register')}
|
2018-01-18 15:26:33 +01:00
|
|
|
/>
|
|
|
|
</div>
|
2017-11-07 19:58:08 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-08 16:06:21 +01:00
|
|
|
EditForm.propTypes = {
|
|
|
|
onChange: PropTypes.func.isRequired,
|
2018-06-14 12:33:57 +02:00
|
|
|
showLoaders: PropTypes.bool.isRequired,
|
2017-11-08 16:06:21 +01:00
|
|
|
values: PropTypes.object.isRequired,
|
|
|
|
};
|
2017-11-07 19:58:08 +01:00
|
|
|
|
|
|
|
export default EditForm;
|