From 72d06f53f58a44d867dd632f4605e56b516255f5 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Mon, 5 Aug 2019 12:06:18 +0200 Subject: [PATCH] add structure for fetching member practice summary from backend --- .../scenes/MemberPracticeSummaryReport/index.js | 9 +++++++-- client/src/store/actions/integrationActions.js | 14 ++++++++++++++ client/src/store/constants.js | 4 ++++ constants/constants.js | 1 + controllers/integration.js | 13 ++++++++++++- routes/index.js | 5 +++++ services/integration/reports.js | 7 +++++++ 7 files changed, 50 insertions(+), 3 deletions(-) diff --git a/client/src/scenes/MemberPracticeSummaryReport/index.js b/client/src/scenes/MemberPracticeSummaryReport/index.js index 082e92e..d371b95 100644 --- a/client/src/scenes/MemberPracticeSummaryReport/index.js +++ b/client/src/scenes/MemberPracticeSummaryReport/index.js @@ -4,21 +4,26 @@ import { Container, Button } from 'semantic-ui-react'; import MainMenu from '../../components/MainMenu'; +import { fetchMemberPracticeSummaryReport } from '../../store/actions'; + class MemberPracticeSummaryReport extends Component { render () { + const { fetchMemberPracticeSummaryReport } = this.props; return (

Member Practice Summary Report



- +
); } } const mapStateToProps = (state) => ({}); -const mapDispatchToProps = (dispatch) => ({}); +const mapDispatchToProps = (dispatch) => ({ + fetchMemberPracticeSummaryReport: () => fetchMemberPracticeSummaryReport(dispatch), +}); export default connect(mapStateToProps, mapDispatchToProps)(MemberPracticeSummaryReport); diff --git a/client/src/store/actions/integrationActions.js b/client/src/store/actions/integrationActions.js index 3cb1ef1..7dafa5c 100644 --- a/client/src/store/actions/integrationActions.js +++ b/client/src/store/actions/integrationActions.js @@ -20,6 +20,9 @@ import { CHECK_PROCESSING_PENDING, CHECK_PROCESSING_SUCCESS, CHECK_PROCESSING_FAILED, + FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_PENDING, + FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_SUCCESS, + FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_FAILED, } from '../constants'; import API from '../../utilities/api'; @@ -109,3 +112,14 @@ export const checkProcessing = (dispatch) => { dispatch({type: CHECK_PROCESSING_FAILED, payload: error.response}); }); }; + +export const fetchMemberPracticeSummaryReport = (dispatch) => { + dispatch({type: FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_PENDING}); + API.get('integration/report/practiceSummary') + .then(response => { + dispatch({type: FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_SUCCESS, payload: response.data}); + }) + .catch(error => { + dispatch({type: FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_FAILED, payload: error.response}); + }); +}; diff --git a/client/src/store/constants.js b/client/src/store/constants.js index f2c950a..9bd3338 100644 --- a/client/src/store/constants.js +++ b/client/src/store/constants.js @@ -29,3 +29,7 @@ export const ADD_FEES_TO_ORD_FAILED = 'ADD_FEES_TO_ORD_FAILED'; export const CHECK_PROCESSING_PENDING = 'CHECK_PROCESSING_PENDING'; export const CHECK_PROCESSING_SUCCESS = 'CHECK_PROCESSING_SUCCESS'; export const CHECK_PROCESSING_FAILED = 'CHECK_PROCESSING_FAILED'; + +export const FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_PENDING = 'FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_PENDING'; +export const FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_SUCCESS = 'FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_SUCCESS'; +export const FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_FAILED = 'FETCH_MEMBER_PRACTICE_SUMMARY_REPORT_FAILED'; diff --git a/constants/constants.js b/constants/constants.js index 95fdd47..8c02881 100644 --- a/constants/constants.js +++ b/constants/constants.js @@ -68,6 +68,7 @@ const integrationServiceErrors = { FAILED_TO_SAVE_DOOR_LOCK_ENTRIES: 'Failed to save door lock entries', FAILED_TO_SAVE_DATA_GENERIC: 'Failed to save data', INVALID_DATE_RANGE: 'Dates in date range are invalid', + FAILED_TO_GENERATE_MEMBER_PRACTICE_SUMMARY: 'Failed to generate Member Practice Summary', }; const incidentType = { diff --git a/controllers/integration.js b/controllers/integration.js index 3c83bed..9184e47 100644 --- a/controllers/integration.js +++ b/controllers/integration.js @@ -1,7 +1,7 @@ 'use strict'; const { getMappingsFromDatabase, fetchOffices, fetchResources, saveNewMappingToDatabase } = require('../services/officeRnD/resources'); -const { getAllIncidents } = require('../services/integration/reports'); +const { getAllIncidents, getMemberPracticeSummaryReport } = require('../services/integration/reports'); const { getMembersFeesForDateRange } = require('../services/integration/invoiceIntegration'); const { deleteFeesFromORD, addFeesToORD } = require('../services/officeRnD/fees'); const { checkBookingChanges } = require('../services/integration/checkBookingChange'); @@ -126,6 +126,16 @@ const checkProcessingStatus = (req, res) => { }); }; +const getPracticeSummaryReport = (req, res) => { + getMemberPracticeSummaryReport() + .then(() => { + res.send(); + }) + .catch((error) => { + res.status(500).send(error); + }); +}; + module.exports = { getKnownOfficeResourceMappings, addNewMapping, @@ -133,4 +143,5 @@ module.exports = { getMemberIncidents, addFees, checkProcessingStatus, + getPracticeSummaryReport, }; diff --git a/routes/index.js b/routes/index.js index 46284bd..47f0b46 100644 --- a/routes/index.js +++ b/routes/index.js @@ -10,6 +10,7 @@ const { getMemberIncidents, addFees, checkProcessingStatus, + getPracticeSummaryReport, } = require('../controllers/integration'); const { calculateDoorLockCharges } = require('../services/integration/doorLockCharges'); @@ -32,6 +33,10 @@ router.post('/integration/addFees', addFees); router.get('/integration/processing', checkProcessingStatus); +router.get('/integration/report/practiceSummary', getPracticeSummaryReport); + + + // temporary route, manually trigger door lock charge calculations router.get('/calculate', (req, res) => { calculateDoorLockCharges(); res.send();}); diff --git a/services/integration/reports.js b/services/integration/reports.js index ccab8d1..3873d9b 100644 --- a/services/integration/reports.js +++ b/services/integration/reports.js @@ -313,6 +313,13 @@ const getAllIncidents = (dateRange, memberIds) => { }); }; +const getMemberPracticeSummaryReport = () => { + return new Promise((resolve, reject) => { + resolve(); + }); +}; + module.exports = { getAllIncidents, + getMemberPracticeSummaryReport, };