From f7c30919e67668bb2fd23af0e57d112990443768 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Fri, 21 Jun 2019 11:36:17 +0200 Subject: [PATCH] add link to member summary report from incidents table --- client/src/components/MainMenu/index.js | 21 ++++++++++------- .../components/MemberIncidentsTable/index.js | 23 ++++++++++++++++--- client/src/constants/menuItems.js | 10 ++++++++ client/src/scenes/IncidentsReport/index.js | 2 +- .../components/MemberSummary.js | 4 ++-- .../src/scenes/PracticeSummaryReport/index.js | 2 +- 6 files changed, 47 insertions(+), 15 deletions(-) diff --git a/client/src/components/MainMenu/index.js b/client/src/components/MainMenu/index.js index 6890a4c..1fd8f65 100644 --- a/client/src/components/MainMenu/index.js +++ b/client/src/components/MainMenu/index.js @@ -7,14 +7,19 @@ import { mainMenuItems } from '../../constants/menuItems'; const MainMenu = () => ( { - mainMenuItems.map(mainMenuItem => - - {mainMenuItem.title} - ) + mainMenuItems.map(mainMenuItem => { + if (!mainMenuItem.showInMenu){ + return null; + } else { + return ( + + {mainMenuItem.title} + ) + }}) } ); diff --git a/client/src/components/MemberIncidentsTable/index.js b/client/src/components/MemberIncidentsTable/index.js index 2e6b44f..6f79f59 100644 --- a/client/src/components/MemberIncidentsTable/index.js +++ b/client/src/components/MemberIncidentsTable/index.js @@ -2,6 +2,7 @@ import React from 'react'; import { Loader } from 'semantic-ui-react'; import ReactTable from 'react-table'; import 'react-table/react-table.css'; +import { NavLink } from 'react-router-dom'; import {incidentsReportHeaderTitles} from '../../constants/menuItems'; import { @@ -13,7 +14,7 @@ import { const MemberIncidentsTable = props => { - const { loading, title } = props; + const { loading, title, openMemberSummaryOnMemberClick } = props; const incidents = props.incidents ? props.incidents : []; const columns = []; @@ -34,9 +35,15 @@ const MemberIncidentsTable = props => { Header: incidentsReportHeaderTitles[header], accessor: header, Cell: props => { - let cellValue; + let cellValue = ''; + let urlValue = undefined; switch (props.column.id) { + case 'memberName': + const memberId = props.row['_original'].memberId; + urlValue = `/practice-summary-report/${memberId}`; + cellValue = props.value; + break; case 'incidentType': cellValue = incidentDescriptions[props.value]; break; @@ -68,7 +75,17 @@ const MemberIncidentsTable = props => { cellValue = props.value; } - return
{cellValue}
+ if (openMemberSummaryOnMemberClick && urlValue){ + return {cellValue} + }else{ + return
{cellValue}
+ } + + // return + //
{cellValue}
+ //
+ + // return
{cellValue}
} }); } diff --git a/client/src/constants/menuItems.js b/client/src/constants/menuItems.js index e2ab184..07b6c96 100644 --- a/client/src/constants/menuItems.js +++ b/client/src/constants/menuItems.js @@ -6,24 +6,34 @@ import PracticeSummaryReport from '../scenes/PracticeSummaryReport'; export const mainMenuItems = [ { id: 'home', + showInMenu: true, title: 'Home', url: '/', component: Home, }, { id: 'practiceSummaryReport', + showInMenu: true, title: 'Practice Summary Report', url: '/practice-summary-report', component: PracticeSummaryReport, }, + { + id: 'practiceSummaryReportWithMemberId', + showInMenu: false, + url: '/practice-summary-report/:memberId', + component: PracticeSummaryReport, + }, { id: 'report', + showInMenu: true, title: 'Incidents Report', url: '/incidents-report', component: IncidentsReport, }, { id: 'uploadDLockData', + showInMenu: true, title: 'DLock', url: '/dlock', component: UploadDLockData, diff --git a/client/src/scenes/IncidentsReport/index.js b/client/src/scenes/IncidentsReport/index.js index 6501d47..fa464ac 100644 --- a/client/src/scenes/IncidentsReport/index.js +++ b/client/src/scenes/IncidentsReport/index.js @@ -24,7 +24,7 @@ class IncidentsReport extends Component {

- + ); } diff --git a/client/src/scenes/PracticeSummaryReport/components/MemberSummary.js b/client/src/scenes/PracticeSummaryReport/components/MemberSummary.js index 687fed0..6f15622 100644 --- a/client/src/scenes/PracticeSummaryReport/components/MemberSummary.js +++ b/client/src/scenes/PracticeSummaryReport/components/MemberSummary.js @@ -11,7 +11,6 @@ const MemberSummary = props => { let totalUnlockedFees = 0; incidents.forEach((incident) => { - console.log(incident); switch (incident.incidentType) { case UNSCHEDULED_INCIDENT: totalUnscheduledFees += parseFloat(incident.totalChargeFee); @@ -19,6 +18,8 @@ const MemberSummary = props => { case UNLOCKED_INCIDENT: totalUnlockedFees += parseFloat(incident.incidentPrice); break; + default: + break; } }); @@ -65,5 +66,4 @@ const MemberSummary = props => { ); }; - export default MemberSummary; diff --git a/client/src/scenes/PracticeSummaryReport/index.js b/client/src/scenes/PracticeSummaryReport/index.js index b53050f..32ea48e 100644 --- a/client/src/scenes/PracticeSummaryReport/index.js +++ b/client/src/scenes/PracticeSummaryReport/index.js @@ -16,7 +16,7 @@ class PracticeSummaryReport extends Component { this.state = { dateRange: null, - memberId: null, + memberId: props.match.params.memberId, }; }