Skip to content

Commit

Permalink
feat(incident): Added Report Incident button
Browse files Browse the repository at this point in the history
  • Loading branch information
alti21 authored Jun 2, 2020
1 parent c0d3138 commit 43cafa6
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 43cafa6

Please sign in to comment.