import React 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 = ({ form }) => { const { t } = useTranslation(); return ( {t('formName', 'Form Name')} {form.name} {t('description', 'Description')} {form.description} {t('formUuid', 'Form UUID')} {form.uuid} {t('version', 'Version')} {form.version} {t('encounterType', 'Encounter Type')} {form.encounterType.uuid} {t('createdBy', 'Created By')} {`${form?.auditInfo?.creator?.display ?? t('unknownUser', 'Unknown')} on ${formatDatetime( parseDate(form?.auditInfo?.dateCreated), )}`} {t('lastEditedBy', 'Last Edited By')} {form?.auditInfo?.dateChanged ? `${form?.auditInfo?.changedBy.display} on ${formatDatetime(parseDate(form?.auditInfo?.dateChanged))}` : t('uneditedFormMsg', 'This form has never been edited')} {t('published', 'Published')} {form.published ? t('yes', 'Yes') : t('no', 'No')} {t('retired', 'Retired')} {form.retired ? t('yes', 'Yes') : t('no', 'No')} ); }; export default AuditDetails;