diff --git a/package.json b/package.json index 739ab3dbc4..89732176ad 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,11 @@ "i18next": "~21.6.0", "i18next-browser-languagedetector": "~6.1.0", "i18next-xhr-backend": "~3.2.2", + "install": "~0.13.0", "json2csv": "~5.0.1", - "lodash": "^4.17.15", "node-sass": "~7.0.0", "pouchdb": "~7.2.1", + "lodash": "4.17.15", "pouchdb-adapter-memory": "~7.2.1", "pouchdb-authentication": "~1.1.3", "pouchdb-find": "~7.2.1", @@ -69,8 +70,8 @@ "@testing-library/react-hooks": "~7.0.0", "@testing-library/user-event": "~12.8.3", "@types/jest": "~27.0.3", - "@types/lodash": "^4.14.150", - "@types/node": "~17.0.0", + "@types/lodash": "4.14.182", + "@types/node": "~15.6.1", "@types/pouchdb": "~6.4.0", "@types/react": "~17.0.0", "@types/react-dom": "~17.0.0", @@ -83,7 +84,7 @@ "@types/validator": "~13.7.0", "@typescript-eslint/eslint-plugin": "~3.10.0", "@typescript-eslint/parser": "~3.10.0", - "chalk": "^5.0.0", + "chalk": "~4.1.2", "commitizen": "~4.2.0", "commitlint-config-cz": "~0.13.0", "cross-env": "~7.0.0", diff --git a/src/__tests__/incidents/hooks/useReportIncident.test.tsx b/src/__tests__/incidents/hooks/useReportIncident.test.tsx index 7753dceedf..e5c78eeef6 100644 --- a/src/__tests__/incidents/hooks/useReportIncident.test.tsx +++ b/src/__tests__/incidents/hooks/useReportIncident.test.tsx @@ -27,6 +27,8 @@ describe('useReportIncident', () => { date: subDays(new Date(), 3).toISOString(), department: 'some department', description: 'some description', + reportedBy: 'some user', + reportByUserID: 'some id', } as Incident const expectedIncident = { diff --git a/src/incidents/hooks/useReportIncident.tsx b/src/incidents/hooks/useReportIncident.tsx index 1421e4ff88..06ba9e3ad3 100644 --- a/src/incidents/hooks/useReportIncident.tsx +++ b/src/incidents/hooks/useReportIncident.tsx @@ -15,7 +15,6 @@ export function reportIncident(incident: Incident): Promise { ...incident, code: getIncidentCode(), status: 'reported', - reportedBy: 'some user', reportedOn: new Date(Date.now()).toISOString(), } return IncidentRepository.save(updatedIncident) diff --git a/src/incidents/report/ReportIncident.tsx b/src/incidents/report/ReportIncident.tsx index 62bee68cf8..88702d8f1a 100644 --- a/src/incidents/report/ReportIncident.tsx +++ b/src/incidents/report/ReportIncident.tsx @@ -1,5 +1,6 @@ import { Button, Row, Column, Typeahead, Label } 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' @@ -11,6 +12,7 @@ import PatientRepository from '../../shared/db/PatientRepository' import useTranslator from '../../shared/hooks/useTranslator' import Incident from '../../shared/model/Incident' import Patient from '../../shared/model/Patient' +import { RootState } from '../../shared/store' import useReportIncident from '../hooks/useReportIncident' import { IncidentError } from '../util/validate-incident' @@ -19,6 +21,8 @@ const ReportIncident = () => { const history = useHistory() const { t } = useTranslator() const updateTitle = useUpdateTitle() + const { user } = useSelector((state: RootState) => state.user) + useEffect(() => { updateTitle(t('incidents.reports.new')) }) @@ -30,6 +34,8 @@ const ReportIncident = () => { ] useAddBreadcrumbs(breadcrumbs) const [incident, setIncident] = useState({ + reportedBy: user?.fullName, // user is read from redux store state.user and the fullName is used while showing details + reportByUserID: user?.id, date: new Date().toISOString(), department: '', category: '', diff --git a/src/shared/model/Incident.ts b/src/shared/model/Incident.ts index a07dd2cad0..3af0571eb9 100644 --- a/src/shared/model/Incident.ts +++ b/src/shared/model/Incident.ts @@ -12,4 +12,5 @@ export default interface Incident extends AbstractDBModel { status: 'reported' | 'resolved' resolvedOn: string patient?: string + reportByUserID: string }