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

feat(settings): add navbar dropdown and settings page #2096

Merged
merged 10 commits into from May 28, 2020
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": false,
"license": "MIT",
"dependencies": {
"@hospitalrun/components": "^1.5.0",
"@hospitalrun/components": "^1.6.0",
"@reduxjs/toolkit": "~1.3.0",
"@types/escape-string-regexp": "~2.0.1",
"@types/pouchdb-find": "~6.3.4",
Expand Down
2 changes: 2 additions & 0 deletions src/HospitalRun.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ButtonBarProvider } from './page-header/ButtonBarProvider'
import ButtonToolBar from './page-header/ButtonToolBar'
import Patients from './patients/Patients'
import Appointments from './scheduling/appointments/Appointments'
import Settings from './settings/Settings'
import { RootState } from './store'

const HospitalRun = () => {
Expand Down Expand Up @@ -45,6 +46,7 @@ const HospitalRun = () => {
<PrivateRoute isAuthenticated path="/patients" component={Patients} />
<PrivateRoute isAuthenticated path="/labs" component={Labs} />
<PrivateRoute isAuthenticated path="/incidents" component={Incidents} />
<PrivateRoute isAuthenticated path="/settings" component={Settings} />
This conversation was marked as resolved.
Show resolved Hide resolved
</Switch>
</div>
<Toaster autoClose={5000} hideProgressBar draggable />
Expand Down
20 changes: 19 additions & 1 deletion src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Navbar = () => {
variant="dark"
navItems={[
{
type: 'icon',
type: 'image',
src:
'data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53%0D%0AMy5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5r%0D%0AIiB2aWV3Qm94PSIwIDAgMjk5IDI5OSI+PGRlZnM+PHN0eWxlPi5jbHM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ined,
},
{
type: 'link-list-icon',
alignRight: true,
children: [
{
type: 'link',
label: t('settings.label'),
onClick: () => {
history.push('/settings')
},
},
],
className: 'pl-4',
iconClassName: 'align-bottom',
label: 'Patient',
name: 'patient',
size: 'lg',
},
]}
/>
)
Expand Down
14 changes: 13 additions & 1 deletion src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,49 @@ import translationPtBR from './locales/ptBr/translations'
import translationRU from './locales/ru/translations'
import translationZhCN from './locales/zhCN/translations'

const resources = {
const resources: { [language: string]: any } = {
it: {
name: 'Italian',
translation: translationIT,
},
ar: {
name: 'Arabic',
translation: translationAR,
},
de: {
name: 'German',
translation: translationDE,
},
en: {
name: 'English, American',
translation: translationEnUs,
},
es: {
name: 'Spanish',
translation: translationES,
},
fr: {
name: 'French',
translation: translationFR,
},
id: {
name: 'Indonesian',
translation: translationID,
},
ja: {
name: 'Japanese',
translation: translationJA,
},
ptBR: {
name: 'Portuguese',
translation: translationPtBR,
},
ru: {
name: 'Russian',
translation: translationRU,
},
zhCN: {
name: 'Chinese',
translation: translationZhCN,
},
}
Expand All @@ -70,3 +81,4 @@ i18n
})

export default i18n
export { resources }
2 changes: 2 additions & 0 deletions src/locales/ar/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import actions from './actions'
import dashboard from './dashboard'
import patient from './patient'
import patients from './patients'
import settings from './settings'

export default {
...actions,
...dashboard,
...patient,
...patients,
...settings,
}
3 changes: 3 additions & 0 deletions src/locales/ar/translations/settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
settings: {},
}
2 changes: 2 additions & 0 deletions src/locales/de/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import labs from './labs'
import patient from './patient'
import patients from './patients'
import scheduling from './scheduling'
import settings from './settings'
import sex from './sex'
import states from './states'

Expand All @@ -13,6 +14,7 @@ export default {
...dashboard,
...patient,
...patients,
...settings,
...scheduling,
...states,
...sex,
Expand Down
3 changes: 3 additions & 0 deletions src/locales/de/translations/settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
settings: {},
}
2 changes: 2 additions & 0 deletions src/locales/enUs/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import labs from './labs'
import patient from './patient'
import patients from './patients'
import scheduling from './scheduling'
import settings from './settings'
import sex from './sex'
import states from './states'

Expand All @@ -18,4 +19,5 @@ export default {
...sex,
...labs,
...incidents,
...settings,
}
8 changes: 8 additions & 0 deletions src/locales/enUs/translations/settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
settings: {
label: 'Settings',
language: {
label: 'Language',
},
},
}
2 changes: 2 additions & 0 deletions src/locales/es/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import dashboard from './dashboard'
import labs from './labs'
import patient from './patient'
import patients from './patients'
import settings from './settings'

export default {
...actions,
...dashboard,
...labs,
...patient,
...patients,
...settings,
}
3 changes: 3 additions & 0 deletions src/locales/es/translations/settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
settings: {},
}
2 changes: 2 additions & 0 deletions src/locales/fr/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import labs from './labs'
import patient from './patient'
import patients from './patients'
import scheduling from './scheduling'
import settings from './settings'
import sex from './sex'
import states from './states'

Expand All @@ -16,4 +17,5 @@ export default {
...states,
...sex,
...labs,
...settings,
}
3 changes: 3 additions & 0 deletions src/locales/fr/translations/settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
settings: {},
}
2 changes: 2 additions & 0 deletions src/locales/id/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import dashboard from './dashboard'
import labs from './labs'
import patient from './patient'
import patients from './patients'
import settings from './settings'

export default {
...actions,
...dashboard,
...labs,
...patient,
...patients,
...settings,
}
3 changes: 3 additions & 0 deletions src/locales/id/translations/settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
settings: {},
}
2 changes: 2 additions & 0 deletions src/locales/it/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import labs from './labs'
import patient from './patient'
import patients from './patients'
import scheduling from './scheduling'
import settings from './settings'
import sex from './sex'
import states from './states'

Expand All @@ -16,4 +17,5 @@ export default {
...states,
...sex,
...labs,
...settings,
}
3 changes: 3 additions & 0 deletions src/locales/it/translations/settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
settings: {},
}
2 changes: 2 additions & 0 deletions src/locales/ja/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import dashboard from './dashboard'
import labs from './labs'
import patient from './patient'
import patients from './patients'
import settings from './settings'

export default {
...actions,
...dashboard,
...labs,
...patient,
...patients,
...settings,
}
8 changes: 8 additions & 0 deletions src/locales/ja/translations/settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
settings: {
label: '設定',
language: {
label: '言語',
},
},
}
2 changes: 2 additions & 0 deletions src/locales/ptBr/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import labs from './labs'
import patient from './patient'
import patients from './patients'
import scheduling from './scheduling'
import settings from './settings'
import sex from './sex'
import states from './states'

Expand All @@ -16,4 +17,5 @@ export default {
...states,
...sex,
...labs,
...settings,
}
3 changes: 3 additions & 0 deletions src/locales/ptBr/translations/settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
settings: {},
}
2 changes: 2 additions & 0 deletions src/locales/ru/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import dashboard from './dashboard'
import labs from './labs'
import patient from './patient'
import patients from './patients'
import settings from './settings'

export default {
...actions,
...dashboard,
...labs,
...patient,
...patients,
...settings,
}
3 changes: 3 additions & 0 deletions src/locales/ru/translations/settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
settings: {},
}
2 changes: 2 additions & 0 deletions src/locales/zhCN/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import dashboard from './dashboard'
import labs from './labs'
import patient from './patient'
import patients from './patients'
import settings from './settings'

export default {
...actions,
...dashboard,
...labs,
...patient,
...patients,
...settings,
}
3 changes: 3 additions & 0 deletions src/locales/zhCN/translations/settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
settings: {},
}
66 changes: 66 additions & 0 deletions src/settings/Settings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React, { useState } from 'react'
import { useTranslation } from 'react-i18next'

import SelectWithLabelFormGroup from '../components/input/SelectWithLableFormGroup'
import i18n, { resources } from '../i18n'
import useTitle from '../page-header/useTitle'

const Settings = () => {
const { t } = useTranslation()
useTitle(t('settings.label'))
This conversation was marked as resolved.
Show resolved Hide resolved

// Language section
const languageOptions = Object.keys(resources)
.map((abbr) => ({
label: resources[abbr].name,
value: abbr,
}))
.sort((a, b) => (a.label > b.label ? 1 : -1))
This conversation was marked as resolved.
Show resolved Hide resolved

const onLanguageChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
const selected = event.target.value
i18n.changeLanguage(selected)
}

// Temp
const tempOptions = [
{ label: 'Option A', value: 'option-a' },
{ label: 'Option B', value: 'option-b' },
]

const [temp, setTemp] = useState(tempOptions[0].value)
This conversation was marked as resolved.
Show resolved Hide resolved

const onTempChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
setTemp(event.target.value)
}
This conversation was marked as resolved.
Show resolved Hide resolved

return (
<>
{/* language selection */}
<div className="w-75" style={{ minWidth: '350px', maxWidth: '500px' }}>
This conversation was marked as resolved.
Show resolved Hide resolved
<SelectWithLabelFormGroup
name="language"
value={i18n.language}
label={t('settings.language.label')}
isEditable
options={languageOptions}
onChange={onLanguageChange}
This conversation was marked as resolved.
Show resolved Hide resolved
/>
</div>

{/* temp: another setting */}
<div className="w-75" style={{ minWidth: '350px', maxWidth: '500px' }}>
<SelectWithLabelFormGroup
name="temp"
value={temp}
label="Temp setting"
isEditable
options={tempOptions}
onChange={onTempChange}
/>
</div>
This conversation was marked as resolved.
Show resolved Hide resolved
</>
)
}

export default Settings