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

fix(incidents): add loading during fetch phase #2085

Merged
merged 7 commits into from
May 20, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 68 additions & 66 deletions src/incidents/view/ViewIncident.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,72 +31,74 @@ const ViewIncident = () => {
dispatch(fetchIncident(id))
}
}, [dispatch, id])

return (
<>
<Row>
<Column>
<div className="form-group incident-date">
<h4>{t('incidents.reports.dateOfIncident')}</h4>
<h5>{format(new Date(incident?.date || ''), 'yyyy-MM-dd hh:mm a')}</h5>
</div>
</Column>
<Column>
<div className="form-group incident-status">
<h4>{t('incidents.reports.status')}</h4>
<h5>{incident?.status}</h5>
</div>
</Column>
<Column>
<div className="form-group incident-reported-by">
<h4>{t('incidents.reports.reportedBy')}</h4>
<h5>{incident?.reportedBy}</h5>
</div>
</Column>
<Column>
<div className="form-group incident-reported-on">
<h4>{t('incidents.reports.reportedOn')}</h4>
<h5>{format(new Date(incident?.reportedOn || ''), 'yyyy-MM-dd hh:mm a')}</h5>
</div>
</Column>
</Row>
<div className="border-bottom mb-2" />
<Row>
<Column md={12}>
<TextInputWithLabelFormGroup
label={t('incidents.reports.department')}
name="department"
value={incident?.department}
/>
</Column>
</Row>
<Row>
<Column md={6}>
<TextInputWithLabelFormGroup
name="category"
label={t('incidents.reports.category')}
value={incident?.category}
/>
</Column>
<Column md={6}>
<TextInputWithLabelFormGroup
label={t('incidents.reports.categoryItem')}
name="categoryItem"
value={incident?.categoryItem}
/>
</Column>
</Row>
<Row>
<Column md={12}>
<TextFieldWithLabelFormGroup
label={t('incidents.reports.description')}
name="description"
value={incident?.description}
/>
</Column>
</Row>
</>
)
if (incident) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a loading status as part of the incident slice that we should add into this check as well.

return (
<>
<Row>
<Column>
<div className="form-group incident-date">
<h4>{t('incidents.reports.dateOfIncident')}</h4>
<h5>{format(new Date(incident?.date || ''), 'yyyy-MM-dd hh:mm a')}</h5>
</div>
</Column>
<Column>
<div className="form-group incident-status">
<h4>{t('incidents.reports.status')}</h4>
<h5>{incident?.status}</h5>
marcosvega91 marked this conversation as resolved.
Show resolved Hide resolved
</div>
</Column>
<Column>
<div className="form-group incident-reported-by">
<h4>{t('incidents.reports.reportedBy')}</h4>
<h5>{incident?.reportedBy}</h5>
</div>
</Column>
<Column>
<div className="form-group incident-reported-on">
<h4>{t('incidents.reports.reportedOn')}</h4>
<h5>{format(new Date(incident?.reportedOn || ''), 'yyyy-MM-dd hh:mm a')}</h5>
</div>
</Column>
</Row>
<div className="border-bottom mb-2" />
<Row>
<Column md={12}>
<TextInputWithLabelFormGroup
label={t('incidents.reports.department')}
name="department"
value={incident?.department}
/>
</Column>
</Row>
<Row>
<Column md={6}>
<TextInputWithLabelFormGroup
name="category"
label={t('incidents.reports.category')}
value={incident?.category}
/>
</Column>
<Column md={6}>
<TextInputWithLabelFormGroup
label={t('incidents.reports.categoryItem')}
name="categoryItem"
value={incident?.categoryItem}
/>
</Column>
</Row>
<Row>
<Column md={12}>
<TextFieldWithLabelFormGroup
label={t('incidents.reports.description')}
name="description"
value={incident?.description}
/>
</Column>
</Row>
</>
)
}
return <h1>Loading...</h1>
marcosvega91 marked this conversation as resolved.
Show resolved Hide resolved
}

export default ViewIncident