import React, { type ComponentProps } from 'react'; import { useTranslation } from 'react-i18next'; import { Button, DataTableSkeleton, InlineLoading } from '@carbon/react'; import { AddIcon, launchWorkspace, useLayoutType } from '@openmrs/esm-framework'; import { CardHeader, EmptyState, ErrorState, launchStartVisitPrompt, usePatientChartStore, } from '@openmrs/esm-patient-common-lib'; import { useVisitNotes } from './visit-notes.resource'; import PaginatedNotes from './paginated-notes.component'; import styles from './notes-overview.scss'; interface NotesOverviewProps { patientUuid: string; patient: fhir.Patient; basePath: string; } /** * This extension uses the patient chart store and MUST only be mounted within the patient chart */ const NotesOverview: React.FC = ({ patientUuid, patient, basePath }) => { const pageSize = 5; const { t } = useTranslation(); const pageUrl = `\${openmrsSpaBase}/patient/${patient.id}/chart/visits`; const urlLabel = t('seeAll', 'See all'); const { visitContext } = usePatientChartStore(patientUuid); const displayText = t('visitNotes', 'Visit notes'); const headerTitle = t('visitNotes', 'Visit notes'); const { visitNotes, error, isLoading, isValidating } = useVisitNotes(patientUuid); const layout = useLayoutType(); const isDesktop = layout === 'large-desktop' || layout === 'small-desktop'; const launchVisitNoteForm = React.useCallback(() => { if (visitContext) { launchWorkspace('visit-notes-form-workspace'); } else { launchStartVisitPrompt(); } }, [visitContext]); if (isLoading) { return ; } if (error) { return ; } if (!visitNotes?.length) { return ; } return (
{isValidating ? : null}
); }; export default NotesOverview;