Skip to content

Commit

Permalink
fix(fullname): added extractFullName() template
Browse files Browse the repository at this point in the history
  • Loading branch information
jameszheng405 committed Feb 21, 2021
1 parent 56b005c commit 2a0ecfb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/incidents/hooks/useReportIncident.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ const getIncidentCode = (): string => `I-${shortid.generate()}`

export function reportIncident(incident: Incident): Promise<Incident> {
const error = validateIncident(incident)

if (isEmpty(error)) {
const updatedIncident: Incident = {
...incident,
code: getIncidentCode(),
status: 'reported',
reportedBy: 'some user',
reportedOn: new Date(Date.now()).toISOString(),
}
return IncidentRepository.save(updatedIncident)
Expand Down
4 changes: 4 additions & 0 deletions src/incidents/report/ReportIncident.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Button, Row, Column } from '@hospitalrun/components'
import React, { useState, useEffect } from 'react'
import { useSelector } from 'react-redux'
import { useHistory } from 'react-router-dom'

import useAddBreadcrumbs from '../../page-header/breadcrumbs/useAddBreadcrumbs'
Expand All @@ -9,6 +10,7 @@ import TextFieldWithLabelFormGroup from '../../shared/components/input/TextField
import TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup'
import useTranslator from '../../shared/hooks/useTranslator'
import Incident from '../../shared/model/Incident'
import { RootState } from '../../shared/store'
import useReportIncident from '../hooks/useReportIncident'
import { IncidentError } from '../util/validate-incident'

Expand All @@ -17,6 +19,7 @@ const ReportIncident = () => {
const history = useHistory()
const { t } = useTranslator()
const updateTitle = useUpdateTitle()
const { user } = useSelector((state: RootState) => state.user)
useEffect(() => {
updateTitle(t('incidents.reports.new'))
})
Expand All @@ -28,6 +31,7 @@ const ReportIncident = () => {
]
useAddBreadcrumbs(breadcrumbs)
const [incident, setIncident] = useState({
reportedBy: user?.id || 'some user',
date: new Date().toISOString(),
department: '',
category: '',
Expand Down
4 changes: 2 additions & 2 deletions src/incidents/view/ViewIncidentDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import TextFieldWithLabelFormGroup from '../../shared/components/input/TextField
import TextInputWithLabelFormGroup from '../../shared/components/input/TextInputWithLabelFormGroup'
import useTranslator from '../../shared/hooks/useTranslator'
import Permissions from '../../shared/model/Permissions'
import { extractUsername } from '../../shared/util/extractUsername'
import { extractFullName } from '../../shared/util/extractFullname'
import useIncident from '../hooks/useIncident'
import useResolveIncident from '../hooks/useResolveIncident'

Expand Down Expand Up @@ -86,7 +86,7 @@ function ViewIncidentDetails(props: Props) {
<Column>
<div className="form-group incident-reported-by">
<h4>{t('incidents.reports.reportedBy')}</h4>
<h5>{extractUsername(data.reportedBy)}</h5>
<h5>{extractFullName(data.reportedBy)}</h5>
</div>
</Column>
<Column>
Expand Down
2 changes: 2 additions & 0 deletions src/shared/util/extractFullName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// TODO: extract fullname from userID when we have information on other users
export const extractFullName = (userID: string) => userID

0 comments on commit 2a0ecfb

Please sign in to comment.