Skip to content

Commit

Permalink
[INJI-332]: update logic to clear idType on change the idType from dr…
Browse files Browse the repository at this point in the history
…opdown

Signed-off-by: Alka <[email protected]>
  • Loading branch information
Alka1703 committed Dec 12, 2023
1 parent 08878e2 commit 1be2105
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
10 changes: 9 additions & 1 deletion screens/Home/MyVcs/AddVcModalMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand All @@ -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: () => ({}),
Expand Down Expand Up @@ -89,6 +94,9 @@ export const AddVcModalMachine =
idle: {
entry: 'focusInput',
on: {
SET_INDIVIDUAL_ID: {
actions: ['clearIdError', 'clearId', 'setIdType', 'setId'],
},
INPUT_ID: {
actions: 'setId',
},
Expand All @@ -107,7 +115,7 @@ export const AddVcModalMachine =
},
],
SELECT_ID_TYPE: {
actions: ['clearIdError', 'setIdType'],
actions: ['clearIdError', 'setIdType', 'clearId'],
},
},
},
Expand Down
3 changes: 1 addition & 2 deletions screens/Home/MyVcs/IdInputModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export const IdInputModal: React.FC<IdInputModalProps> = 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 = () => {
Expand Down
3 changes: 3 additions & 0 deletions screens/Home/MyVcs/IdInputModalController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)),
Expand Down
2 changes: 1 addition & 1 deletion shared/constants.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 1be2105

Please sign in to comment.