Commit 4c3bd2be authored by Nicolas Frandeboeuf's avatar Nicolas Frandeboeuf Committed by Benjamin Bouvier
Browse files

Use stateless component in emails/modal

parent 10cc7e18
......@@ -8,96 +8,88 @@ import Modal from '../../ui/modal';
import AccountSelector from './account-select';
class ReportCreationModal extends React.Component {
const ReportCreationModal = props => {
constructor(props) {
super(props);
this.handleCreate = this.handleCreate.bind(this);
this.accountSelector = null;
this.frequencySelector = null;
}
handleCreate() {
let accountSelector = null;
let frequencySelector = null;
const handleCreate = () => {
let newAlert = {
type: 'report',
bankAccount: this.accountSelector.getWrappedInstance().value(),
frequency: this.frequencySelector.value
};
this.props.createAlert(newAlert);
}
render() {
let modalTitle = $t('client.settings.emails.add_report');
let accountSelectorCb = selector => {
this.accountSelector = selector;
};
let frequencySelectorCb = input => {
this.frequencySelector = input;
bankAccount: accountSelector.getWrappedInstance().value(),
frequency: frequencySelector.value
};
let modalBody = (
<div>
<div className="form-group">
<label htmlFor="account">
{ $t('client.settings.emails.account') }
</label>
<AccountSelector
ref={ accountSelectorCb }
id="account"
/>
</div>
props.createAlert(newAlert);
};
<div className="form-group">
<span>{ $t('client.settings.emails.send_report') }&nbsp;</span>
let modalTitle = $t('client.settings.emails.add_report');
let accountSelectorCb = selector => {
accountSelector = selector;
};
let frequencySelectorCb = input => {
frequencySelector = input;
};
<select
className="form-control"
ref={ frequencySelectorCb }>
<option value="daily">
{ $t('client.settings.emails.daily') }
</option>
<option value="weekly">
{ $t('client.settings.emails.weekly') }
</option>
<option value="monthly">
{ $t('client.settings.emails.monthly') }
</option>
</select>
</div>
let modalBody = (
<div>
<div className="form-group">
<label htmlFor="account">
{ $t('client.settings.emails.account') }
</label>
<AccountSelector
ref={ accountSelectorCb }
id="account"
/>
</div>
);
let modalFooter = (
<div>
<button
type="button"
className="btn btn-default"
data-dismiss="modal">
{ $t('client.settings.emails.cancel') }
</button>
<button
type="button"
className="btn btn-success"
data-dismiss="modal"
onClick={ this.handleCreate }>
{ $t('client.settings.emails.create') }
</button>
<div className="form-group">
<span>{ $t('client.settings.emails.send_report') }&nbsp;</span>
<select
className="form-control"
ref={ frequencySelectorCb }>
<option value="daily">
{ $t('client.settings.emails.daily') }
</option>
<option value="weekly">
{ $t('client.settings.emails.weekly') }
</option>
<option value="monthly">
{ $t('client.settings.emails.monthly') }
</option>
</select>
</div>
);
return (
<Modal
modalId="report-creation"
modalTitle={ modalTitle }
modalBody={ modalBody }
modalFooter={ modalFooter }
/>
);
}
}
</div>
);
let modalFooter = (
<div>
<button
type="button"
className="btn btn-default"
data-dismiss="modal">
{ $t('client.settings.emails.cancel') }
</button>
<button
type="button"
className="btn btn-success"
data-dismiss="modal"
onClick={ handleCreate }>
{ $t('client.settings.emails.create') }
</button>
</div>
);
return (
<Modal
modalId="report-creation"
modalTitle={ modalTitle }
modalBody={ modalBody }
modalFooter={ modalFooter }
/>
);
};
export default connect(() => {
return {};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment