2019-06-17 13:24:34 +02:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
import { connect } from 'react-redux';
|
2019-06-19 11:23:58 +02:00
|
|
|
import { Container } from 'semantic-ui-react';
|
2019-06-17 13:24:34 +02:00
|
|
|
|
|
|
|
|
import MainMenu from '../../components/MainMenu';
|
2019-08-27 05:53:59 +02:00
|
|
|
import MonthSelector from '../../components/MonthSelector';
|
2019-07-07 07:02:42 +02:00
|
|
|
import MemberIncidentsTables from '../../components/MemberIncidentsTables';
|
2019-07-25 06:53:32 +02:00
|
|
|
import GenerateFeesInORDButton from '../../components/GenerateFeesInORDButton';
|
2019-06-19 11:23:58 +02:00
|
|
|
|
2019-08-31 06:11:15 +02:00
|
|
|
import { fetchIncidents } from '../../store/actions';
|
2019-06-17 13:24:34 +02:00
|
|
|
|
|
|
|
|
class IncidentsReport extends Component {
|
2019-07-25 06:53:32 +02:00
|
|
|
state = {dateRange: null};
|
|
|
|
|
|
|
|
|
|
onDatesUpdate = (dateRange) => {
|
2019-06-17 13:24:34 +02:00
|
|
|
const { fetchIncidents } = this.props;
|
2019-07-25 06:53:32 +02:00
|
|
|
|
|
|
|
|
this.setState({dateRange});
|
2019-06-19 11:23:58 +02:00
|
|
|
fetchIncidents(dateRange);
|
2019-07-25 06:53:32 +02:00
|
|
|
};
|
2019-06-17 13:24:34 +02:00
|
|
|
|
|
|
|
|
render () {
|
2019-07-25 06:53:32 +02:00
|
|
|
const { pendingIncidents, incidents, pendingAddFeesStatus } = this.props;
|
|
|
|
|
const { dateRange } = this.state;
|
|
|
|
|
|
|
|
|
|
const loading = pendingIncidents || pendingAddFeesStatus;
|
|
|
|
|
|
|
|
|
|
const membersMap = {};
|
|
|
|
|
if (incidents && Array.isArray(incidents)) {
|
|
|
|
|
incidents.forEach((incident) => {
|
|
|
|
|
membersMap[incident.memberId] = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
2019-06-17 13:24:34 +02:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Container>
|
|
|
|
|
<MainMenu/>
|
|
|
|
|
<h3>Incidents Report</h3>
|
|
|
|
|
<hr/>
|
2019-08-27 05:53:59 +02:00
|
|
|
<MonthSelector buttonLabel="Show report" onDatesUpdate={this.onDatesUpdate} inlineButton />
|
2019-07-25 06:53:32 +02:00
|
|
|
<br/>
|
|
|
|
|
<GenerateFeesInORDButton
|
|
|
|
|
disabled={loading}
|
|
|
|
|
dateRange={dateRange}
|
|
|
|
|
/>
|
|
|
|
|
<br/><br/>
|
|
|
|
|
<hr/>
|
2019-06-19 11:23:58 +02:00
|
|
|
<br/>
|
2019-07-25 06:53:32 +02:00
|
|
|
<MemberIncidentsTables pendingIncidents={loading} incidents={incidents} />
|
2019-06-17 13:24:34 +02:00
|
|
|
</Container>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => ({
|
|
|
|
|
pendingIncidents: state.incidentsReport.pending,
|
|
|
|
|
incidents: state.incidentsReport.result,
|
2019-07-25 06:53:32 +02:00
|
|
|
pendingAddFeesStatus: state.addFeesStatus.pending,
|
2019-06-17 13:24:34 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
2019-08-31 06:11:15 +02:00
|
|
|
fetchIncidents: (dateRange) => fetchIncidents(dispatch, dateRange)
|
2019-06-17 13:24:34 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(IncidentsReport);
|