From 5a03057923852f42caaaa7b17149f1f179d7c005 Mon Sep 17 00:00:00 2001 From: Benny Lo Date: Wed, 31 Aug 2022 16:09:20 +1000 Subject: [PATCH 01/14] Update lodash version to fix npm start error --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 739ab3dbc4..93f202fc88 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "@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/lodash": "~4.14.182", "@types/node": "~17.0.0", "@types/pouchdb": "~6.4.0", "@types/react": "~17.0.0", From 777dc6bff34fe751ae31c63a92053b9a1729df72 Mon Sep 17 00:00:00 2001 From: Benny Date: Wed, 31 Aug 2022 17:27:27 +1000 Subject: [PATCH 02/14] Update lodash version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 93f202fc88..b4c9260c64 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "i18next-browser-languagedetector": "~6.1.0", "i18next-xhr-backend": "~3.2.2", "json2csv": "~5.0.1", - "lodash": "^4.17.15", + "lodash": "^4.14.182", "node-sass": "~7.0.0", "pouchdb": "~7.2.1", "pouchdb-adapter-memory": "~7.2.1", From 67a02ef2a0a1952b5f0fbd6da1dc243348e9401a Mon Sep 17 00:00:00 2001 From: Benny Date: Thu, 1 Sep 2022 10:33:11 +1000 Subject: [PATCH 03/14] Pin lodash version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b4c9260c64..e0b4214dd6 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "@types/escape-string-regexp": "~2.0.1", "@types/json2csv": "~5.0.1", "@types/pouchdb-find": "~6.3.4", + "@types/lodash": "4.14.182", "bootstrap": "~5.1.0", "date-fns": "~2.28.0", "escape-string-regexp": "~4.0.0", @@ -17,7 +18,6 @@ "i18next-browser-languagedetector": "~6.1.0", "i18next-xhr-backend": "~3.2.2", "json2csv": "~5.0.1", - "lodash": "^4.14.182", "node-sass": "~7.0.0", "pouchdb": "~7.2.1", "pouchdb-adapter-memory": "~7.2.1", @@ -69,7 +69,7 @@ "@testing-library/react-hooks": "~7.0.0", "@testing-library/user-event": "~12.8.3", "@types/jest": "~27.0.3", - "@types/lodash": "~4.14.182", + "@types/lodash": "4.14.182", "@types/node": "~17.0.0", "@types/pouchdb": "~6.4.0", "@types/react": "~17.0.0", From f3938c5d37a05865e416ac4e48e02bcb8020629e Mon Sep 17 00:00:00 2001 From: Benny Date: Thu, 1 Sep 2022 12:24:00 +1000 Subject: [PATCH 04/14] Fix node npm start error --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 739ab3dbc4..a3082f1050 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "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", @@ -70,7 +71,7 @@ "@testing-library/user-event": "~12.8.3", "@types/jest": "~27.0.3", "@types/lodash": "^4.14.150", - "@types/node": "~17.0.0", + "@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", From 17fb52c3f4a5ebb5450ed35432747cc9874ec799 Mon Sep 17 00:00:00 2001 From: Xhefri Bala <70955537+xhefribala@users.noreply.github.com> Date: Tue, 6 Sep 2022 11:32:03 +1000 Subject: [PATCH 05/14] fixed user login issue --- src/incidents/hooks/useReportIncident.tsx | 6 ++++-- src/incidents/report/ReportIncident.tsx | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/incidents/hooks/useReportIncident.tsx b/src/incidents/hooks/useReportIncident.tsx index 1421e4ff88..0dabe862b7 100644 --- a/src/incidents/hooks/useReportIncident.tsx +++ b/src/incidents/hooks/useReportIncident.tsx @@ -6,16 +6,18 @@ import IncidentRepository from '../../shared/db/IncidentRepository' import Incident from '../../shared/model/Incident' import validateIncident from '../util/validate-incident' + const getIncidentCode = (): string => `I-${shortid.generate()}` export function reportIncident(incident: Incident): Promise { const error = validateIncident(incident) + if (isEmpty(error)) { const updatedIncident: Incident = { ...incident, code: getIncidentCode(), status: 'reported', - reportedBy: 'some user', + //reportedBy: 'some user', reportedOn: new Date(Date.now()).toISOString(), } return IncidentRepository.save(updatedIncident) @@ -31,4 +33,4 @@ export default function useReportIncident() { }, throwOnError: true, }) -} +} \ No newline at end of file diff --git a/src/incidents/report/ReportIncident.tsx b/src/incidents/report/ReportIncident.tsx index 62bee68cf8..f2dcc02807 100644 --- a/src/incidents/report/ReportIncident.tsx +++ b/src/incidents/report/ReportIncident.tsx @@ -13,23 +13,28 @@ import Incident from '../../shared/model/Incident' import Patient from '../../shared/model/Patient' import useReportIncident from '../hooks/useReportIncident' import { IncidentError } from '../util/validate-incident' +import {useSelector } from 'react-redux' +import { RootState } from '../../shared/store' const ReportIncident = () => { const [mutate] = useReportIncident() const history = useHistory() const { t } = useTranslator() const updateTitle = useUpdateTitle() + const {user} = useSelector((state: RootState) => state.user) + useEffect(() => { updateTitle(t('incidents.reports.new')) }) const breadcrumbs = [ { - i18nKey: 'incidents.reports.new', + i18nKey: 'incidents.reports.new', location: `/incidents/new`, }, ] useAddBreadcrumbs(breadcrumbs) const [incident, setIncident] = useState({ + reportedBy: user?.id, //|| 'some user', //user is read from redux store state.user and the id is used while showing details date: new Date().toISOString(), department: '', category: '', @@ -179,4 +184,4 @@ const ReportIncident = () => { ) } -export default ReportIncident +export default ReportIncident \ No newline at end of file From f2b547b35082dbb0a5fce6b7c1e3a7ab95c84104 Mon Sep 17 00:00:00 2001 From: Xhefri Bala <70955537+xhefribala@users.noreply.github.com> Date: Tue, 6 Sep 2022 17:01:13 +1000 Subject: [PATCH 06/14] change from userID to userFullname in reportIncidentList --- src/incidents/list/ViewIncidents.tsx | 3 +-- src/incidents/report/ReportIncident.tsx | 3 ++- src/shared/model/Incident.ts | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/incidents/list/ViewIncidents.tsx b/src/incidents/list/ViewIncidents.tsx index a103fde05e..f59c44f9ab 100644 --- a/src/incidents/list/ViewIncidents.tsx +++ b/src/incidents/list/ViewIncidents.tsx @@ -23,8 +23,7 @@ const ViewIncidents = () => { setButtonToolBar([