Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
feat(navbar): add shortcut icon to the create pages
Browse files Browse the repository at this point in the history
  • Loading branch information
kumikokashii committed May 29, 2020
1 parent e5677fe commit b1a8cdf
Showing 1 changed file with 53 additions and 1 deletion.
54 changes: 53 additions & 1 deletion src/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,53 @@
import { Navbar as HospitalRunNavbar } from '@hospitalrun/components'
import React from 'react'
import { useTranslation } from 'react-i18next'
import { useSelector } from 'react-redux'
import { useHistory } from 'react-router-dom'

import Permissions from '../model/Permissions'
import { RootState } from '../store'

const Navbar = () => {
const { permissions } = useSelector((state: RootState) => state.user)
const { t } = useTranslation()
const history = useHistory()

const addPages = [
{
permission: Permissions.WritePatients,
label: t('patients.newPatient'),
path: '/patients/new',
},
{
permission: Permissions.WriteAppointments,
label: t('scheduling.appointments.new'),
path: '/appointments/new',
},
{
permission: Permissions.RequestLab,
label: t('labs.requests.new'),
path: '/labs/new',
},
{
permission: Permissions.ReportIncident,
label: t('incidents.reports.new'),
path: '/incidents/new',
},
]

const addDropdownList: { type: string; label: string; onClick: () => void }[] = []
addPages.forEach((page) => {
if (permissions.includes(page.permission)) {
addDropdownList.push({
type: 'link',
label: page.label,
onClick: () => {
history.push(page.path)
},
})
}
})

return (
<HospitalRunNavbar
bg="dark"
Expand Down Expand Up @@ -100,6 +142,16 @@ const Navbar = () => {
onClickButton: () => undefined,
onChangeInput: () => undefined,
},
{
type: 'link-list-icon',
alignRight: true,
children: addDropdownList,
className: 'pl-4',
iconClassName: 'align-bottom',
label: 'Add',
name: 'add',
size: 'lg',
},
{
type: 'link-list-icon',
alignRight: true,
Expand All @@ -112,7 +164,7 @@ const Navbar = () => {
},
},
],
className: 'pl-4',
className: 'pl-2',
iconClassName: 'align-bottom',
label: 'Patient',
name: 'patient',
Expand Down

0 comments on commit b1a8cdf

Please sign in to comment.