diff --git a/screens/Home/MyVcs/AddVcModalMachine.ts b/screens/Home/MyVcs/AddVcModalMachine.ts index 000e7a51..ec12be43 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: () => ({}), @@ -65,11 +70,9 @@ export const AddVcModalMachine = id: 'AddVcModal', initial: 'acceptingIdInput', on: { - INPUT_ID: { - actions: 'setId', - }, - SELECT_ID_TYPE: { - actions: ['clearIdError', 'setIdType'], + SET_INDIVIDUAL_ID: { + actions: ['clearIdError', 'clearId', 'setIdType', 'setId'], + target: '#AddVcModal.acceptingIdInput.idle', }, }, states: { @@ -97,6 +100,9 @@ export const AddVcModalMachine = idle: { entry: 'focusInput', on: { + SET_INDIVIDUAL_ID: { + actions: ['clearIdError', 'clearId', 'setIdType', 'setId'], + }, INPUT_ID: { actions: 'setId', }, @@ -216,7 +222,7 @@ export const AddVcModalMachine = cancelDownload: { on: { CANCEL: { - actions: ['resetIdInputRef', 'forwardToParent'], + actions: ['clearId', 'resetIdInputRef', 'forwardToParent'], }, WAIT: { target: 'acceptingOtpInput', diff --git a/screens/Home/MyVcs/AddVcModalMachine.typegen.ts b/screens/Home/MyVcs/AddVcModalMachine.typegen.ts index 7e3aa522..305a113d 100644 --- a/screens/Home/MyVcs/AddVcModalMachine.typegen.ts +++ b/screens/Home/MyVcs/AddVcModalMachine.typegen.ts @@ -43,9 +43,14 @@ export interface Typegen0 { services: never; }; eventsCausingActions: { - clearId: 'SELECT_ID_TYPE'; - clearIdError: 'INPUT_ID' | 'SELECT_ID_TYPE' | 'VALIDATE_INPUT'; + clearId: 'CANCEL' | 'SELECT_ID_TYPE' | 'SET_INDIVIDUAL_ID'; + clearIdError: + | 'INPUT_ID' + | 'SELECT_ID_TYPE' + | 'SET_INDIVIDUAL_ID' + | 'VALIDATE_INPUT'; clearOtp: + | 'SET_INDIVIDUAL_ID' | 'WAIT' | 'done.invoke.AddVcModal.acceptingIdInput.requestingOtp:invocation[0]' | 'error.platform.AddVcModal.acceptingOtpInput.resendOTP:invocation[0]' @@ -54,6 +59,7 @@ export interface Typegen0 { focusInput: | 'INPUT_ID' | 'SELECT_ID_TYPE' + | 'SET_INDIVIDUAL_ID' | 'VALIDATE_INPUT' | 'error.platform.AddVcModal.acceptingIdInput.requestingOtp:invocation[0]' | 'error.platform.AddVcModal.acceptingOtpInput.resendOTP:invocation[0]' @@ -61,7 +67,7 @@ export interface Typegen0 { | 'xstate.after(100)#AddVcModal.acceptingIdInput.focusing'; forwardToParent: 'CANCEL' | 'DISMISS'; resetIdInputRef: 'CANCEL'; - setId: 'INPUT_ID'; + setId: 'INPUT_ID' | 'SET_INDIVIDUAL_ID'; setIdBackendError: | 'error.platform.AddVcModal.acceptingIdInput.requestingOtp:invocation[0]' | 'error.platform.AddVcModal.acceptingOtpInput.resendOTP:invocation[0]' @@ -69,11 +75,12 @@ export interface Typegen0 { setIdErrorEmpty: 'VALIDATE_INPUT'; setIdErrorWrongFormat: 'VALIDATE_INPUT'; setIdInputRef: 'READY'; - setIdType: 'SELECT_ID_TYPE'; + setIdType: 'SELECT_ID_TYPE' | 'SET_INDIVIDUAL_ID'; setOtp: 'INPUT_OTP'; setOtpError: 'error.platform.AddVcModal.requestingCredential:invocation[0]'; setRequestId: 'done.invoke.AddVcModal.requestingCredential:invocation[0]'; setTransactionId: + | 'SET_INDIVIDUAL_ID' | 'error.platform.AddVcModal.acceptingOtpInput.resendOTP:invocation[0]' | 'error.platform.AddVcModal.requestingCredential:invocation[0]' | 'xstate.init'; diff --git a/screens/Home/MyVcs/IdInputModal.tsx b/screens/Home/MyVcs/IdInputModal.tsx index 5b6505fe..ecb7dea5 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 c24df997..229539bb 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/screens/Home/MyVcs/OtpVerificationModal.tsx b/screens/Home/MyVcs/OtpVerificationModal.tsx index 145f5312..bcdff293 100644 --- a/screens/Home/MyVcs/OtpVerificationModal.tsx +++ b/screens/Home/MyVcs/OtpVerificationModal.tsx @@ -17,7 +17,7 @@ import { OtpVerificationModalProps, useOtpVerificationModal, } from './OtpVerificationModalController'; -import {isIOS} from '../../../shared/constants'; +import {GET_INDIVIDUAL_ID, isIOS} from '../../../shared/constants'; export const OtpVerificationModal: React.FC< OtpVerificationModalProps @@ -68,6 +68,11 @@ export const OtpVerificationModal: React.FC< props.onInputDone(otp); }; + const handleRequestOTPCancel = () => { + GET_INDIVIDUAL_ID({id: '', idType: 'UIN'}); + controller.CANCEL(); + }; + return ( diff --git a/shared/constants.ts b/shared/constants.ts index 900a2c16..874a23f2 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;