Commit 905bbd2b authored by ZeHiro's avatar ZeHiro
Browse files

Harmonize display of alert accounts. Fixes #541

parent e983a386
Pipeline #14251 passed with stage
in 3 minutes and 29 seconds
......@@ -48,7 +48,7 @@ export default connect(state => {
for (let account of accounts) {
pairs.push({
key: account.accountNumber,
val: `${access.name} - ${account.title}`
val: `${access.name} ${account.title}`
});
}
}
......
......@@ -2,7 +2,7 @@ import React from 'react';
import { connect } from 'react-redux';
import { assert, translate as $t } from '../../../helpers';
import { actions } from '../../../store';
import { actions, get } from '../../../store';
import ConfirmDeleteModal from '../../ui/confirm-delete-modal';
import AmountInput from '../../ui/amount-input';
......@@ -25,14 +25,14 @@ const AlertItem = props => {
props.update({ limit: value });
};
let { account, alert } = props;
let { account, alert, access } = props;
let { limit, type, id } = alert;
assert(alert.order === 'gt' || alert.order === 'lt');
return (
<tr>
<td className="col-md-3">{ account.title }</td>
<td className="col-md-3">{ `${access.name}${account.title}` }</td>
<td className="col-md-3">
<span className="condition">{ props.sendIfText }</span>
</td>
......@@ -99,11 +99,15 @@ AlertItem.propTypes = {
update: React.PropTypes.func.isRequired,
// The alert deletion function
handleDelete: React.PropTypes.func.isRequired
handleDelete: React.PropTypes.func.isRequired,
// The bank access to which is attached the account of the alert
access: React.PropTypes.object.isRequired
};
export default connect(() => {
return {};
export default connect((state, ownProps) => {
let access = get.accessById(state, ownProps.account.bankAccess);
return { access };
}, (dispatch, props) => {
return {
update(newFields) {
......
......@@ -2,7 +2,7 @@ import React from 'react';
import { connect } from 'react-redux';
import { assert, assertHas, translate as $t } from '../../../helpers';
import { actions } from '../../../store';
import { actions, get } from '../../../store';
import ConfirmDeleteModal from '../../ui/confirm-delete-modal';
......@@ -16,14 +16,14 @@ const ReportItem = props => {
props.update({ frequency: newValue });
};
let { account, alert } = props;
let { account, alert, access } = props;
assertHas(alert, 'frequency');
assert(alert.type === 'report');
return (
<tr>
<td className="col-md-3">{ account.title }</td>
<td className="col-md-3">{ `${access.name}${account.title}` }</td>
<td className="col-md-3">
<span className="condition">
{ $t('client.settings.emails.send_report') }
......@@ -78,8 +78,9 @@ ReportItem.propTypes = {
handleDelete: React.PropTypes.func.isRequired
};
export default connect(() => {
return {};
export default connect((state, ownProps) => {
let access = get.accessById(state, ownProps.account.bankAccess);
return { access };
}, (dispatch, props) => {
return {
update(newFields) {
......
......@@ -1077,7 +1077,8 @@ export function getAccesses(state) {
}
export function accessById(state, accessId) {
return state.accesses.filter(access => access.id === accessId)[0];
let candidate = state.accesses.find(access => access.id === accessId);
return typeof candidate !== 'undefined' ? candidate : null;
}
export function byUuid(state, uuid) {
......
......@@ -100,6 +100,11 @@ export const get = {
}
),
accessById(state, accessId) {
assertDefined(state);
return Bank.accessById(state.banks, accessId);
},
// [Access]
accesses(state) {
assertDefined(state);
......
Markdown is supported
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