From 1be210552820569924ca3fb8934d0ff5ddce8a4a Mon Sep 17 00:00:00 2001 From: Alka Date: Tue, 12 Dec 2023 15:49:37 +0530 Subject: [PATCH] [INJI-332]: update logic to clear idType on change the idType from dropdown Signed-off-by: Alka --- screens/Home/MyVcs/AddVcModalMachine.ts | 10 +++++++++- screens/Home/MyVcs/IdInputModal.tsx | 3 +-- screens/Home/MyVcs/IdInputModalController.ts | 3 +++ shared/constants.ts | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/screens/Home/MyVcs/AddVcModalMachine.ts b/screens/Home/MyVcs/AddVcModalMachine.ts index ebeac2f94b..22677ac59f 100644 --- a/screens/Home/MyVcs/AddVcModalMachine.ts +++ b/screens/Home/MyVcs/AddVcModalMachine.ts @@ -21,6 +21,7 @@ import { import {TelemetryConstants} from '../../../shared/telemetry/TelemetryConstants'; import {API_URLS} from '../../../shared/api'; +import {IndividualId} from '../../../shared/constants'; const model = createModel( { @@ -36,6 +37,10 @@ const model = createModel( }, { events: { + SET_INDIVIDUAL_ID: (individualId: IndividualId) => ({ + id: individualId.id, + idType: individualId.idType, + }), INPUT_ID: (id: string) => ({id}), INPUT_OTP: (otp: string) => ({otp}), RESEND_OTP: () => ({}), @@ -89,6 +94,9 @@ export const AddVcModalMachine = idle: { entry: 'focusInput', on: { + SET_INDIVIDUAL_ID: { + actions: ['clearIdError', 'clearId', 'setIdType', 'setId'], + }, INPUT_ID: { actions: 'setId', }, @@ -107,7 +115,7 @@ export const AddVcModalMachine = }, ], SELECT_ID_TYPE: { - actions: ['clearIdError', 'setIdType'], + actions: ['clearIdError', 'setIdType', 'clearId'], }, }, }, diff --git a/screens/Home/MyVcs/IdInputModal.tsx b/screens/Home/MyVcs/IdInputModal.tsx index 5b6505fe63..ecb7dea5ca 100644 --- a/screens/Home/MyVcs/IdInputModal.tsx +++ b/screens/Home/MyVcs/IdInputModal.tsx @@ -24,8 +24,7 @@ export const IdInputModal: React.FC = props => { const controller = useIdInputModal(props); const setIndividualID = () => { - controller.INPUT_ID(individualId.id); - controller.SELECT_ID_TYPE(individualId.idType); + controller.SET_INDIVIDUAL_ID(individualId); }; const dismissInput = () => { diff --git a/screens/Home/MyVcs/IdInputModalController.ts b/screens/Home/MyVcs/IdInputModalController.ts index c24df9973b..229539bbba 100644 --- a/screens/Home/MyVcs/IdInputModalController.ts +++ b/screens/Home/MyVcs/IdInputModalController.ts @@ -15,6 +15,7 @@ import { selectIdType, } from './AddVcModalMachine'; import {VcIdType} from '../../../types/VC/ExistingMosipVC/vc'; +import {IndividualId} from '../../../shared/constants'; export function useIdInputModal({service}: IdInputModalProps) { return { @@ -28,6 +29,8 @@ export function useIdInputModal({service}: IdInputModalProps) { isAcceptingOtpInput: useSelector(service, selectIsAcceptingOtpInput), isRequestingOtp: useSelector(service, selectIsRequestingOtp), + SET_INDIVIDUAL_ID: (individualId: IndividualId) => + service.send(AddVcModalEvents.SET_INDIVIDUAL_ID(individualId)), INPUT_ID: (id: string) => service.send(AddVcModalEvents.INPUT_ID(id)), SELECT_ID_TYPE: (selectedValue: VcIdType) => service.send(AddVcModalEvents.SELECT_ID_TYPE(selectedValue)), diff --git a/shared/constants.ts b/shared/constants.ts index 900a2c166d..874a23f2de 100644 --- a/shared/constants.ts +++ b/shared/constants.ts @@ -1,7 +1,7 @@ import {Platform} from 'react-native'; import {MIMOTO_HOST, ESIGNET_HOST, DEBUG_MODE} from 'react-native-dotenv'; import {Argon2iConfig} from './commonUtil'; -import {VcIdType} from '../types/vc'; +import {VcIdType} from '../types/VC/ExistingMosipVC/vc'; export let MIMOTO_BASE_URL = MIMOTO_HOST; export let ESIGNET_BASE_URL = ESIGNET_HOST;