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 ( +
Unscheduled incidents total :
+{formattedUnscheduledFees}
+Unlocked incidents total :
+{formattedUnlockedFees}
+Grand Total :
+{formattedGrandTotalFee}
+