From db1a3acb1180e2a3217585db0a7d20118f33e805 Mon Sep 17 00:00:00 2001 From: Senad Uka Date: Thu, 20 Jun 2019 14:18:36 +0200 Subject: [PATCH] Start of PracticeSummaryReport --- .../components/MemberSummary.js | 72 +++++++++++++++++-- .../src/scenes/PracticeSummaryReport/index.js | 6 +- services/officeRnD/members.js | 1 + 3 files changed, 72 insertions(+), 7 deletions(-) diff --git a/client/src/scenes/PracticeSummaryReport/components/MemberSummary.js b/client/src/scenes/PracticeSummaryReport/components/MemberSummary.js index 3be23d6..687fed0 100644 --- a/client/src/scenes/PracticeSummaryReport/components/MemberSummary.js +++ b/client/src/scenes/PracticeSummaryReport/components/MemberSummary.js @@ -1,9 +1,69 @@ -import React, { Component } from 'react'; +import React from 'react'; +import { Loader, Grid } from 'semantic-ui-react'; + +import { UNSCHEDULED_INCIDENT, UNLOCKED_INCIDENT } from '../../../constants/enums'; + +const MemberSummary = props => { + const { loading } = props; + const incidents = props.incidents ? props.incidents : []; + + let totalUnscheduledFees = 0; + let totalUnlockedFees = 0; + + incidents.forEach((incident) => { + console.log(incident); + switch (incident.incidentType) { + case UNSCHEDULED_INCIDENT: + totalUnscheduledFees += parseFloat(incident.totalChargeFee); + break; + case UNLOCKED_INCIDENT: + totalUnlockedFees += parseFloat(incident.incidentPrice); + break; + } + }); + + const grandTotal = totalUnlockedFees + totalUnscheduledFees; + + const formattedUnscheduledFees = `$ ${totalUnscheduledFees.toFixed(2)}`; + const formattedUnlockedFees = `$ ${totalUnlockedFees.toFixed(2)}`; + const formattedGrandTotalFee = `$ ${grandTotal.toFixed(2)}`; + + return ( +
+

Member Summary for selected period

+ + { + !loading && + + + +

Unscheduled incidents total :

+
+ +

{formattedUnscheduledFees}

+
+
+ + +

Unlocked incidents total :

+
+ +

{formattedUnlockedFees}

+
+
+ + +

Grand Total :

+
+ +

{formattedGrandTotalFee}

+
+
+
+ } +
+ ); +}; -class MemberSummary extends Component { - render() { - return (

Member Summary

); - } -} export default MemberSummary; diff --git a/client/src/scenes/PracticeSummaryReport/index.js b/client/src/scenes/PracticeSummaryReport/index.js index baa1e42..70fa155 100644 --- a/client/src/scenes/PracticeSummaryReport/index.js +++ b/client/src/scenes/PracticeSummaryReport/index.js @@ -57,9 +57,13 @@ class PracticeSummaryReport extends Component { - + + { memberId: member['_id'], }); }); + cleanedResult.sort((member1, member2) => (member1.name > member2.name) ? 1 : -1 ); resolve(cleanedResult); }) .catch((error) => {