Skip to content

Commit

Permalink
Merge branch 'master' into feat-HospitalRun#1969
Browse files Browse the repository at this point in the history
  • Loading branch information
HospitalRun Bot committed Jun 2, 2020
2 parents 0677b2a + 43cafa6 commit 19b1e70
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/incidents/list/ViewIncidents.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Button } from '@hospitalrun/components'
import format from 'date-fns/format'
import React, { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
Expand All @@ -6,6 +7,7 @@ import { useHistory } from 'react-router-dom'

import SelectWithLabelFormGroup from '../../components/input/SelectWithLableFormGroup'
import Incident from '../../model/Incident'
import { useButtonToolbarSetter } from '../../page-header/ButtonBarProvider'
import useTitle from '../../page-header/useTitle'
import { RootState } from '../../store'
import IncidentFilter from '../IncidentFilter'
Expand All @@ -19,6 +21,25 @@ const ViewIncidents = () => {
const [searchFilter, setSearchFilter] = useState(IncidentFilter.reported)
const { incidents } = useSelector((state: RootState) => state.incidents)

const setButtonToolBar = useButtonToolbarSetter()
useEffect(() => {
setButtonToolBar([
<Button
key="newIncidentButton"
outlined
color="success"
icon="add"
onClick={() => history.push('/incidents/new')}
>
{t('incidents.reports.new')}
</Button>,
])

return () => {
setButtonToolBar([])
}
}, [dispatch, setButtonToolBar, t, history])

useEffect(() => {
dispatch(searchIncidents(searchFilter))
}, [dispatch, searchFilter])
Expand Down

0 comments on commit 19b1e70

Please sign in to comment.