Skip to content

Commit

Permalink
(refactor) Refactor Mark patient deceased form and Mark patient alive…
Browse files Browse the repository at this point in the history
… modal
  • Loading branch information
denniskigen committed Jun 18, 2024
1 parent a983505 commit 37cefb0
Show file tree
Hide file tree
Showing 14 changed files with 403 additions and 412 deletions.
2 changes: 1 addition & 1 deletion packages/esm-patient-chart-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.workspace.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@ import React, { useCallback } from 'react';
import { OverflowMenuItem } from '@carbon/react';
import { useTranslation } from 'react-i18next';
import { showModal } from '@openmrs/esm-framework';
import { usePatientDeceased } from '../deceased/deceased.resource';
import { usePatientDeceasedStatus } from '../mark-patient-deceased/deceased.resource';

interface MarkPatientAliveOverflowMenuItemProps {
patientUuid?: string;
}

const MarkPatientAliveOverflowMenuItem: React.FC<MarkPatientAliveOverflowMenuItemProps> = ({ patientUuid }) => {
const { t } = useTranslation();

const { isDead, isLoading: isPatientLoading } = usePatientDeceased(patientUuid);
const { isDead, isLoading: isPatientLoading } = usePatientDeceasedStatus(patientUuid);

const openModal = useCallback(() => {
const dispose = showModal('confirm-alive-modal', {
patientUuid,
const dispose = showModal('mark-patient-alive-modal', {
closeDialog: () => dispose(),
patientUuid,
});
}, [patientUuid]);

return (
!isPatientLoading &&
isDead && (
<OverflowMenuItem
itemText={t('markAlive', 'Mark alive')}
itemText={t('markPatientAlive', 'Mark patient alive')}
onClick={openModal}
style={{
maxWidth: '100vw',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import React, { useCallback } from 'react';
import { OverflowMenuItem } from '@carbon/react';
import { useTranslation } from 'react-i18next';
import { launchPatientWorkspace } from '@openmrs/esm-patient-common-lib';
import { usePatientDeceased } from '../deceased/deceased.resource';
import { usePatientDeceasedStatus } from '../mark-patient-deceased/deceased.resource';

const MarkPatientDeceasedOverflowMenuItem = ({ patientUuid }) => {
const { t } = useTranslation();
const handleClick = useCallback(() => launchPatientWorkspace('mark-patient-deceased-workspace-form'), []);
const { isDead, isLoading: isPatientLoading } = usePatientDeceased(patientUuid);
const { isDead, isLoading: isPatientLoading } = usePatientDeceasedStatus(patientUuid);

return (
!isPatientLoading &&
!isDead && (
<OverflowMenuItem
itemText={t('markDeceased', 'Mark deceased')}
itemText={t('markPatientDeceased', 'Mark patient deceased')}
onClick={handleClick}
style={{
maxWidth: '100vw',
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 37cefb0

Please sign in to comment.