Files
old-crm-integration/client/src/scenes/IncidentsReport/index.js

66 lines
2.1 KiB
JavaScript
Raw Normal View History

import React, { Component } from 'react';
import { connect } from 'react-redux';
2019-06-19 11:23:58 +02:00
import { Container } from 'semantic-ui-react';
import MainMenu from '../../components/MainMenu';
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
import { fetchIncidents } from '../../store/actions';
class IncidentsReport extends Component {
2019-07-25 06:53:32 +02:00
state = {dateRange: null};
onDatesUpdate = (dateRange) => {
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
};
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;
});
}
return (
<Container>
<MainMenu/>
<h3>Incidents Report</h3>
<hr/>
<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} />
</Container>
);
}
}
const mapStateToProps = (state) => ({
pendingIncidents: state.incidentsReport.pending,
incidents: state.incidentsReport.result,
2019-07-25 06:53:32 +02:00
pendingAddFeesStatus: state.addFeesStatus.pending,
});
const mapDispatchToProps = (dispatch) => ({
fetchIncidents: (dateRange) => fetchIncidents(dispatch, dateRange)
});
export default connect(mapStateToProps, mapDispatchToProps)(IncidentsReport);