forked from openmrs/openmrs-esm-form-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix) Various UI fixes for the Audit Details tab (openmrs#196)
- Loading branch information
1 parent
07cadce
commit 7639fbd
Showing
12 changed files
with
151 additions
and
115 deletions.
There are no files selected for viewing
115 changes: 115 additions & 0 deletions
115
src/components/audit-details/audit-details.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { formatDatetime, parseDate } from '@openmrs/esm-framework'; | ||
import { StructuredListWrapper, StructuredListRow, StructuredListCell, StructuredListBody } from '@carbon/react'; | ||
import type { EncounterType } from '../../types'; | ||
|
||
interface AuditDetailsProps { | ||
form: FormGroupData; | ||
} | ||
|
||
export interface AuditInfo { | ||
creator: Creator; | ||
dateCreated: string; | ||
changedBy: ChangedBy; | ||
dateChanged: string; | ||
} | ||
|
||
interface Creator { | ||
display: string; | ||
} | ||
|
||
interface ChangedBy { | ||
uuid: string; | ||
display: string; | ||
} | ||
|
||
interface FormGroupData { | ||
auditInfo: AuditInfo; | ||
name: string; | ||
uuid: string; | ||
version: string; | ||
encounterType: EncounterType; | ||
description: string; | ||
display?: string; | ||
published?: boolean; | ||
retired?: boolean; | ||
} | ||
|
||
const AuditDetails: React.FC<AuditDetailsProps> = ({ form }) => { | ||
console.log('form: ', form); | ||
|
||
const { t } = useTranslation(); | ||
const [description, setDescription] = useState(''); | ||
const [encounterType, setEncounterType] = useState(''); | ||
const [name, setName] = useState(''); | ||
const [published, setPublished] = useState(false); | ||
const [retired, setRetired] = useState(false); | ||
const [version, setVersion] = useState(''); | ||
|
||
useEffect(() => { | ||
if (form) { | ||
setName(form.name); | ||
setDescription(form.description); | ||
setEncounterType(`${form.encounterType.display} - ${form.encounterType.uuid}`); | ||
setVersion(form.version); | ||
setPublished(form.published); | ||
setRetired(form.retired); | ||
} | ||
}, [form]); | ||
|
||
return ( | ||
<StructuredListWrapper isCondensed selection={false}> | ||
<StructuredListBody> | ||
<StructuredListRow> | ||
<StructuredListCell> | ||
<b>{t('formName', 'Form Name')}</b> | ||
</StructuredListCell> | ||
<StructuredListCell>{name}</StructuredListCell> | ||
</StructuredListRow> | ||
<StructuredListRow> | ||
<StructuredListCell>{t('description', 'Description')}</StructuredListCell> | ||
<StructuredListCell>{description}</StructuredListCell> | ||
</StructuredListRow> | ||
<StructuredListRow> | ||
<StructuredListCell>{t('formUuid', 'Form UUID')}</StructuredListCell> | ||
<StructuredListCell>{form?.uuid}</StructuredListCell> | ||
</StructuredListRow> | ||
<StructuredListRow> | ||
<StructuredListCell>{t('version', 'Version')}</StructuredListCell> | ||
<StructuredListCell>{version}</StructuredListCell> | ||
</StructuredListRow> | ||
<StructuredListRow> | ||
<StructuredListCell>{t('encounterType', 'Encounter Type')}</StructuredListCell> | ||
<StructuredListCell>{encounterType}</StructuredListCell> | ||
</StructuredListRow> | ||
<StructuredListRow> | ||
<StructuredListCell>{t('createdBy', 'Created By')}</StructuredListCell> | ||
<StructuredListCell> | ||
{`${form?.auditInfo?.creator?.display ?? t('unknownUser', 'Unknown')} on ${formatDatetime( | ||
parseDate(form?.auditInfo?.dateCreated), | ||
)}`} | ||
</StructuredListCell> | ||
</StructuredListRow> | ||
<StructuredListRow> | ||
<StructuredListCell>{t('lastEditedBy', 'Last Edited By')}</StructuredListCell> | ||
<StructuredListCell> | ||
{form?.auditInfo?.dateChanged | ||
? `${form?.auditInfo?.changedBy.display} on ${formatDatetime(parseDate(form?.auditInfo?.dateChanged))}` | ||
: t('uneditedFormMsg', 'This form has never been edited')} | ||
</StructuredListCell> | ||
</StructuredListRow> | ||
<StructuredListRow> | ||
<StructuredListCell>{t('published', 'Published')}</StructuredListCell> | ||
<StructuredListCell>{published ? t('yes', 'Yes') : t('no', 'No')}</StructuredListCell> | ||
</StructuredListRow> | ||
<StructuredListRow> | ||
<StructuredListCell>{t('retired', 'Retired')}</StructuredListCell> | ||
<StructuredListCell>{retired ? t('yes', 'Yes') : t('no', 'No')}</StructuredListCell> | ||
</StructuredListRow> | ||
</StructuredListBody> | ||
</StructuredListWrapper> | ||
); | ||
}; | ||
|
||
export default AuditDetails; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.