@@ -3,13 +3,14 @@ import { useTranslation } from 'react-i18next';
3
3
import { useField } from 'formik' ;
4
4
import { Button } from '@carbon/react' ;
5
5
import { TrashCan , Edit , Reset } from '@carbon/react/icons' ;
6
- import { ResourcesContext } from '../../../../offline.resources ' ;
6
+ import { type RegistrationConfig } from '../../../../config-schema ' ;
7
7
import { showModal , useConfig , UserHasAccess } from '@openmrs/esm-framework' ;
8
- import { shouldBlockPatientIdentifierInOfflineMode } from './utils' ;
9
8
import { deleteIdentifierType , setIdentifierSource } from '../../../field/id/id-field.component' ;
10
- import { type PatientIdentifierValue } from '../../../patient-registration.types' ;
11
- import { PatientRegistrationContext } from '../../../patient-registration-context' ;
12
9
import { Input } from '../../basic-input/input/input.component' ;
10
+ import { PatientRegistrationContext } from '../../../patient-registration-context' ;
11
+ import { ResourcesContext } from '../../../../offline.resources' ;
12
+ import { shouldBlockPatientIdentifierInOfflineMode } from './utils' ;
13
+ import { type PatientIdentifierValue } from '../../../patient-registration.types' ;
13
14
import styles from '../../input.scss' ;
14
15
15
16
interface IdentifierInputProps {
@@ -19,7 +20,7 @@ interface IdentifierInputProps {
19
20
20
21
const IdentifierInput : React . FC < IdentifierInputProps > = ( { patientIdentifier, fieldName } ) => {
21
22
const { t } = useTranslation ( ) ;
22
- const { defaultPatientIdentifierTypes } = useConfig ( ) ;
23
+ const { defaultPatientIdentifierTypes } = useConfig < RegistrationConfig > ( ) ;
23
24
const { identifierTypes } = useContext ( ResourcesContext ) ;
24
25
const { isOffline, values, setFieldValue } = useContext ( PatientRegistrationContext ) ;
25
26
const identifierType = useMemo (
@@ -70,13 +71,13 @@ const IdentifierInput: React.FC<IdentifierInputProps> = ({ patientIdentifier, fi
70
71
*/
71
72
72
73
if ( initialValue ) {
73
- const confirmDeleteIdentifierModal = showModal ( 'delete-identifier-confirmation-modal' , {
74
- closeModal : ( ) => confirmDeleteIdentifierModal ( ) ,
75
- deleteIdentifier : ( confirmed ) => {
76
- if ( confirmed ) {
74
+ const dispose = showModal ( 'delete-identifier-confirmation-modal' , {
75
+ closeModal : ( ) => dispose ( ) ,
76
+ deleteIdentifier : ( isConfirmed ) => {
77
+ if ( isConfirmed ) {
77
78
setFieldValue ( 'identifiers' , deleteIdentifierType ( values . identifiers , fieldName ) ) ;
78
79
}
79
- confirmDeleteIdentifierModal ( ) ;
80
+ dispose ( ) ;
80
81
} ,
81
82
identifierName,
82
83
identifierValue : initialValue ,
0 commit comments