Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
hdf1996 committed Oct 30, 2019
2 parents 57a9d2b + 6116363 commit 7a03cd3
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
19 changes: 17 additions & 2 deletions app/components/AntibioticConsumptionStatsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ type ComponentProps = {
dispatch: Dispatch,
antibioticConsumptionStatsList: {
antibioticName: string,
antibioticConsumptionStats: Page
antibioticConsumptionStats: Page,
antibiotic?: {
strength: string,
form: string,
name: string,
packSize: string,
brand: string
}
},
antibioticId: string,
site: {
Expand Down Expand Up @@ -99,6 +106,10 @@ class AntibioticConsumptionStatsList extends Component<Props, State> {
recipientFacility,
recipientUnit
} = this.state;
const { strength, form, name, packSize, brand } =
(antibioticConsumptionStatsList &&
antibioticConsumptionStatsList.antibiotic) ||
{};

return (
<div>
Expand All @@ -109,9 +120,13 @@ class AntibioticConsumptionStatsList extends Component<Props, State> {
<MaterialIcon icon="arrow_back" />
</Link>
{antibioticConsumptionStatsList &&
antibioticConsumptionStatsList.antibioticName}
`${name || ''} ${packSize || ''}`}
</>
}
subtitle={
antibioticConsumptionStatsList &&
`${strength || ''} ${form || ''} ${(brand && `(${brand})`) || ''}`
}
pagination
items={antibioticConsumptionStats.items}
totalCount={antibioticConsumptionStats.totalCount}
Expand Down
16 changes: 14 additions & 2 deletions app/components/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type ComponentProps = {
entityName?: string,
onClick?: () => void,
title?: string,
subtitle?: string,
rowClassName?: () => [string],
lastRow?: typeof Component,
pagination?: boolean,
Expand Down Expand Up @@ -61,7 +62,8 @@ class Table extends Component<Props, State> {
prevPage: null,
nextPage: null,
search: null,
filters: null
filters: null,
subtitle: null
};

render() {
Expand All @@ -83,7 +85,8 @@ class Table extends Component<Props, State> {
history,
onReload,
search,
filters
filters,
subtitle
} = this.props;
const { searchText, searchTimeout } = this.state;
return (
Expand All @@ -98,6 +101,15 @@ class Table extends Component<Props, State> {
{title || `${totalCount} ${entityName}`}
</h2>
</Cell>
{subtitle && (
<Cell
columns={12 - (search ? 3 : 0) - (filters ? 6 : 0)}
align="middle"
>
<h3 className={styles.tableSubtitle}>{subtitle}</h3>
</Cell>
)}

{filters && (
<Cell columns={6} align="middle">
{filters}
Expand Down
5 changes: 5 additions & 0 deletions app/components/Table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ tbody tr:hover {
color: var(--black);
}

.tableSubtitle,
.tableSubtitle a {
color: var(--medium-gray);
}

.filters {
text-align: right;
}
Expand Down
13 changes: 12 additions & 1 deletion app/reducers/antibioticConsumptionStatsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import type { Action, State } from './types';

const initialState = {
antibioticName: null,
antibiotic: {
strength: null,
form: null,
name: null,
packSize: null,
brand: null
},
antibioticConsumptionStats: {
items: [],
totalCount: 0,
Expand All @@ -25,7 +32,11 @@ export default function(state: State = initialState, action: Action) {
let newItems;
switch (action.type) {
case FETCHED_ANTIBIOTIC:
return { ...state, antibioticName: action.antibiotic.name };
return {
...state,
antibioticName: action.antibiotic.name,
antibiotic: action.antibiotic
};
case FETCH_ANTIBIOTIC_CONSUMPTION_STATS_LIST_SUCCEEDED:
return { ...state, antibioticConsumptionStats: action };
case ADD_CREATED_ANTIBIOTIC_CONSUMPTION_STAT_TO_LIST:
Expand Down

0 comments on commit 7a03cd3

Please sign in to comment.