Merge branch 'add-door-lock-charges-screen' into 'master'

add link to member summary report from incidents table

See merge request saburly/psihologija!16
This commit was merged in pull request #16.
This commit is contained in:
Bilal Catic
2019-06-21 09:39:39 +00:00
6 changed files with 47 additions and 15 deletions

View File

@@ -7,7 +7,11 @@ import { mainMenuItems } from '../../constants/menuItems';
const MainMenu = () => const MainMenu = () =>
(<Menu> (<Menu>
{ {
mainMenuItems.map(mainMenuItem => mainMenuItems.map(mainMenuItem => {
if (!mainMenuItem.showInMenu){
return null;
} else {
return (
<Menu.Item key={mainMenuItem.id} <Menu.Item key={mainMenuItem.id}
as={NavLink} as={NavLink}
to={mainMenuItem.url} to={mainMenuItem.url}
@@ -15,6 +19,7 @@ const MainMenu = () =>
> >
{mainMenuItem.title} {mainMenuItem.title}
</Menu.Item>) </Menu.Item>)
}})
} }
</Menu>); </Menu>);

View File

@@ -2,6 +2,7 @@ import React from 'react';
import { Loader } from 'semantic-ui-react'; import { Loader } from 'semantic-ui-react';
import ReactTable from 'react-table'; import ReactTable from 'react-table';
import 'react-table/react-table.css'; import 'react-table/react-table.css';
import { NavLink } from 'react-router-dom';
import {incidentsReportHeaderTitles} from '../../constants/menuItems'; import {incidentsReportHeaderTitles} from '../../constants/menuItems';
import { import {
@@ -13,7 +14,7 @@ import {
const MemberIncidentsTable = props => { const MemberIncidentsTable = props => {
const { loading, title } = props; const { loading, title, openMemberSummaryOnMemberClick } = props;
const incidents = props.incidents ? props.incidents : []; const incidents = props.incidents ? props.incidents : [];
const columns = []; const columns = [];
@@ -34,9 +35,15 @@ const MemberIncidentsTable = props => {
Header: incidentsReportHeaderTitles[header], Header: incidentsReportHeaderTitles[header],
accessor: header, accessor: header,
Cell: props => { Cell: props => {
let cellValue; let cellValue = '';
let urlValue = undefined;
switch (props.column.id) { switch (props.column.id) {
case 'memberName':
const memberId = props.row['_original'].memberId;
urlValue = `/practice-summary-report/${memberId}`;
cellValue = props.value;
break;
case 'incidentType': case 'incidentType':
cellValue = incidentDescriptions[props.value]; cellValue = incidentDescriptions[props.value];
break; break;
@@ -68,8 +75,18 @@ const MemberIncidentsTable = props => {
cellValue = props.value; cellValue = props.value;
} }
if (openMemberSummaryOnMemberClick && urlValue){
return <NavLink to={urlValue}>{cellValue}</NavLink>
}else{
return <div style={{ textAlign: columnContentsAlignment }}>{cellValue}</div> return <div style={{ textAlign: columnContentsAlignment }}>{cellValue}</div>
} }
// return <NavLink to={urlValue}>
// <div>{cellValue}</div>
// </NavLink>
// return <div style={{ textAlign: columnContentsAlignment }}><a href={'www.gogole.com'} >{cellValue}</a></div>
}
}); });
} }
}); });

View File

@@ -6,24 +6,34 @@ import PracticeSummaryReport from '../scenes/PracticeSummaryReport';
export const mainMenuItems = [ export const mainMenuItems = [
{ {
id: 'home', id: 'home',
showInMenu: true,
title: 'Home', title: 'Home',
url: '/', url: '/',
component: Home, component: Home,
}, },
{ {
id: 'practiceSummaryReport', id: 'practiceSummaryReport',
showInMenu: true,
title: 'Practice Summary Report', title: 'Practice Summary Report',
url: '/practice-summary-report', url: '/practice-summary-report',
component: PracticeSummaryReport, component: PracticeSummaryReport,
}, },
{
id: 'practiceSummaryReportWithMemberId',
showInMenu: false,
url: '/practice-summary-report/:memberId',
component: PracticeSummaryReport,
},
{ {
id: 'report', id: 'report',
showInMenu: true,
title: 'Incidents Report', title: 'Incidents Report',
url: '/incidents-report', url: '/incidents-report',
component: IncidentsReport, component: IncidentsReport,
}, },
{ {
id: 'uploadDLockData', id: 'uploadDLockData',
showInMenu: true,
title: 'DLock', title: 'DLock',
url: '/dlock', url: '/dlock',
component: UploadDLockData, component: UploadDLockData,

View File

@@ -24,7 +24,7 @@ class IncidentsReport extends Component {
<hr/> <hr/>
<DateRangePicker buttonLabel="Show report" onDatesUpdate={this.onDatesUpdate.bind(this)} /> <DateRangePicker buttonLabel="Show report" onDatesUpdate={this.onDatesUpdate.bind(this)} />
<br/> <br/>
<MemberIncidentsTable loading={pendingIncidents} incidents={incidents} /> <MemberIncidentsTable loading={pendingIncidents} incidents={incidents} openMemberSummaryOnMemberClick />
</Container> </Container>
); );
} }

View File

@@ -11,7 +11,6 @@ const MemberSummary = props => {
let totalUnlockedFees = 0; let totalUnlockedFees = 0;
incidents.forEach((incident) => { incidents.forEach((incident) => {
console.log(incident);
switch (incident.incidentType) { switch (incident.incidentType) {
case UNSCHEDULED_INCIDENT: case UNSCHEDULED_INCIDENT:
totalUnscheduledFees += parseFloat(incident.totalChargeFee); totalUnscheduledFees += parseFloat(incident.totalChargeFee);
@@ -19,6 +18,8 @@ const MemberSummary = props => {
case UNLOCKED_INCIDENT: case UNLOCKED_INCIDENT:
totalUnlockedFees += parseFloat(incident.incidentPrice); totalUnlockedFees += parseFloat(incident.incidentPrice);
break; break;
default:
break;
} }
}); });
@@ -65,5 +66,4 @@ const MemberSummary = props => {
); );
}; };
export default MemberSummary; export default MemberSummary;

View File

@@ -16,7 +16,7 @@ class PracticeSummaryReport extends Component {
this.state = { this.state = {
dateRange: null, dateRange: null,
memberId: null, memberId: props.match.params.memberId,
}; };
} }