From 9ad4cbf71ce06f3b3fe9a013d935a8335b845c30 Mon Sep 17 00:00:00 2001 From: marcosvega91 Date: Sun, 17 May 2020 10:40:22 +0200 Subject: [PATCH 1/2] fix(viewincident): add loading during fetch phase fix #2081 --- src/incidents/view/ViewIncident.tsx | 134 ++++++++++++++-------------- 1 file changed, 68 insertions(+), 66 deletions(-) diff --git a/src/incidents/view/ViewIncident.tsx b/src/incidents/view/ViewIncident.tsx index fae2e0c7ec..228b05f330 100644 --- a/src/incidents/view/ViewIncident.tsx +++ b/src/incidents/view/ViewIncident.tsx @@ -31,72 +31,74 @@ const ViewIncident = () => { dispatch(fetchIncident(id)) } }, [dispatch, id]) - - return ( - <> - - -
-

{t('incidents.reports.dateOfIncident')}

-
{format(new Date(incident?.date || ''), 'yyyy-MM-dd hh:mm a')}
-
-
- -
-

{t('incidents.reports.status')}

-
{incident?.status}
-
-
- -
-

{t('incidents.reports.reportedBy')}

-
{incident?.reportedBy}
-
-
- -
-

{t('incidents.reports.reportedOn')}

-
{format(new Date(incident?.reportedOn || ''), 'yyyy-MM-dd hh:mm a')}
-
-
-
-
- - - - - - - - - - - - - - - - - - - - ) + if (incident) { + return ( + <> + + +
+

{t('incidents.reports.dateOfIncident')}

+
{format(new Date(incident?.date || ''), 'yyyy-MM-dd hh:mm a')}
+
+
+ +
+

{t('incidents.reports.status')}

+
{incident?.status}
+
+
+ +
+

{t('incidents.reports.reportedBy')}

+
{incident?.reportedBy}
+
+
+ +
+

{t('incidents.reports.reportedOn')}

+
{format(new Date(incident?.reportedOn || ''), 'yyyy-MM-dd hh:mm a')}
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + ) + } + return

Loading...

} export default ViewIncident From 5e2e76d16bffa517bf136e71655680f68bb5a89c Mon Sep 17 00:00:00 2001 From: marcosvega91 Date: Mon, 18 May 2020 09:33:46 +0200 Subject: [PATCH 2/2] fix(viewincident): fix after review --- src/incidents/view/ViewIncident.tsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/incidents/view/ViewIncident.tsx b/src/incidents/view/ViewIncident.tsx index 228b05f330..e68436cf26 100644 --- a/src/incidents/view/ViewIncident.tsx +++ b/src/incidents/view/ViewIncident.tsx @@ -1,4 +1,4 @@ -import { Column, Row } from '@hospitalrun/components' +import { Column, Row, Spinner } from '@hospitalrun/components' import format from 'date-fns/format' import React, { useEffect } from 'react' import { useTranslation } from 'react-i18next' @@ -38,25 +38,25 @@ const ViewIncident = () => {

{t('incidents.reports.dateOfIncident')}

-
{format(new Date(incident?.date || ''), 'yyyy-MM-dd hh:mm a')}
+
{format(new Date(incident.date || ''), 'yyyy-MM-dd hh:mm a')}

{t('incidents.reports.status')}

-
{incident?.status}
+
{incident.status}

{t('incidents.reports.reportedBy')}

-
{incident?.reportedBy}
+
{incident.reportedBy}

{t('incidents.reports.reportedOn')}

-
{format(new Date(incident?.reportedOn || ''), 'yyyy-MM-dd hh:mm a')}
+
{format(new Date(incident.reportedOn || ''), 'yyyy-MM-dd hh:mm a')}
@@ -66,7 +66,7 @@ const ViewIncident = () => { @@ -75,14 +75,14 @@ const ViewIncident = () => { @@ -91,14 +91,14 @@ const ViewIncident = () => { ) } - return

Loading...

+ return } export default ViewIncident