@eka-care/abha-stg 0.1.36 → 0.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/{index.html → dist/index.html} +2 -1
  2. package/dist/sdk/abha/css/abha.css +1 -0
  3. package/dist/sdk/abha/js/abha.js +63 -0
  4. package/package.json +1 -1
  5. package/.turbo/daemon/7f0c6427972069cb-turbo.log.2025-11-12 +0 -0
  6. package/package/styles/pds2/border.ts +0 -69
  7. package/package/styles/pds2/colors.ts +0 -70
  8. package/package/styles/pds2/spacing.ts +0 -1007
  9. package/package/tailwind/tailwind.config.ts +0 -124
  10. package/postcss.config.js +0 -6
  11. package/scripts/build-purged-css.cjs +0 -70
  12. package/src/App.css +0 -0
  13. package/src/App.tsx +0 -43
  14. package/src/api-queries/aorta-go/v3/get-profile-patient.ts +0 -32
  15. package/src/api-queries/aorta-go/v3/get-profiles-phr-user.ts +0 -26
  16. package/src/api-queries/aorta-go/v3/post-auth-init-v2.ts +0 -34
  17. package/src/api-queries/aorta-go/v3/post-auth-logout-v2.ts +0 -32
  18. package/src/api-queries/aorta-go/v3/post-auth-verify-v2.ts +0 -38
  19. package/src/api-queries/aorta-go/v3/post-profile-switch.ts +0 -39
  20. package/src/api-queries/ndhm/get-abdm-register-suggest.ts +0 -37
  21. package/src/api-queries/ndhm/get-pincode-details.ts +0 -28
  22. package/src/api-queries/ndhm/post-abdm-login-init.ts +0 -37
  23. package/src/api-queries/ndhm/post-abdm-login-phr.ts +0 -37
  24. package/src/api-queries/ndhm/post-abdm-login-verify.ts +0 -37
  25. package/src/api-queries/ndhm/post-abdm-profile-eka-link-phr.ts +0 -40
  26. package/src/api-queries/ndhm/post-abdm-profile-eka.ts +0 -66
  27. package/src/api-queries/ndhm/post-abdm-register-abha-number-create-phr.ts +0 -37
  28. package/src/api-queries/ndhm/post-abdm-register-mobile-create-phr.ts +0 -66
  29. package/src/api-queries/ndhm/post-abdm-register-mobile-resend-otp.ts +0 -32
  30. package/src/api-queries/ndhm/post-abdm-register-mobile-verify.ts +0 -38
  31. package/src/api-queries/ndhm/post-abdm-register-phr-check.ts +0 -34
  32. package/src/api-queries/ndhm/post-register-aadhaar-create-phr.ts +0 -37
  33. package/src/api-queries/ndhm/post-register-aadhaar-init.ts +0 -34
  34. package/src/api-queries/ndhm/post-register-aadhaar-mobile-resend-otp.ts +0 -34
  35. package/src/api-queries/ndhm/post-register-aadhaar-mobile-verify.ts +0 -37
  36. package/src/api-queries/ndhm/post-register-aadhaar-resend-otp.ts +0 -34
  37. package/src/api-queries/ndhm/post-register-aadhaar-verify.ts +0 -40
  38. package/src/api-queries/ndhm/post-register-mobile-init.ts +0 -34
  39. package/src/api-queries/use-get-profiles-patient.ts +0 -12
  40. package/src/api-queries/use-get-profiles-phr-user.ts +0 -28
  41. package/src/api-queries/use-post-abdm-login-verify-v1.ts +0 -26
  42. package/src/api-queries/use-post-auth-verify-v2.ts +0 -50
  43. package/src/api-queries/use-post-profile-switch.ts +0 -58
  44. package/src/api-queries/use-post-register-mobile-create-phr.ts +0 -39
  45. package/src/api-queries/user-post-abdm-profile-login-phr.ts +0 -26
  46. package/src/assets/Success.json +0 -1
  47. package/src/assets/react.svg +0 -1
  48. package/src/atoms/button/custom-button.tsx +0 -32
  49. package/src/atoms/button/index.tsx +0 -40
  50. package/src/atoms/button/types.d.ts +0 -31
  51. package/src/atoms/header.tsx +0 -25
  52. package/src/atoms/input-field/index.tsx +0 -63
  53. package/src/atoms/input-field/patient-input-field.tsx +0 -16
  54. package/src/atoms/input-field/types.ts +0 -24
  55. package/src/atoms/pds2-otp-input/index.tsx +0 -35
  56. package/src/atoms/pds2-otp-input/types.d.ts +0 -3
  57. package/src/atoms/single-input-chip/index.tsx +0 -32
  58. package/src/atoms/single-input-chip/types.ts +0 -6
  59. package/src/atoms/spinner.tsx +0 -33
  60. package/src/atoms/text-separator.tsx +0 -11
  61. package/src/atoms/ui/spinner.tsx +0 -75
  62. package/src/constants/constants.ts +0 -376
  63. package/src/fetch-client/index.ts +0 -164
  64. package/src/index.css +0 -152
  65. package/src/main.tsx +0 -374
  66. package/src/molecules/abha/bottom-sheet/bottom-sheet-wrapper.tsx +0 -40
  67. package/src/molecules/abha/bottom-sheet/index.tsx +0 -66
  68. package/src/molecules/abha/spaced-input-component.tsx +0 -168
  69. package/src/molecules/copyright-year.tsx +0 -16
  70. package/src/molecules/exit-popup/index.tsx +0 -101
  71. package/src/molecules/pds2-otp-component/index.tsx +0 -147
  72. package/src/organisms/abha/abha-header.tsx +0 -25
  73. package/src/organisms/abha/abha-stepper.tsx +0 -83
  74. package/src/organisms/abha/error-bottom-sheet.tsx +0 -27
  75. package/src/organisms/abha/otp-card.tsx +0 -99
  76. package/src/organisms/abha/verification-status.tsx +0 -30
  77. package/src/organisms/choose-language/choose-language.tsx +0 -53
  78. package/src/organisms/choose-language/types.ts +0 -10
  79. package/src/organisms/screen-switcher/screen-switcher.tsx +0 -80
  80. package/src/routes/abha-aadhaar-verification-status-screen.tsx +0 -246
  81. package/src/routes/abha-created-screen.tsx +0 -45
  82. package/src/routes/abha-login-otp-verify-screen.tsx +0 -519
  83. package/src/routes/abha-mobile-linking-status-screen.tsx +0 -267
  84. package/src/routes/abha-otp-and-mobile-screen.tsx +0 -435
  85. package/src/routes/abha-phone-number-verification-screen.tsx +0 -388
  86. package/src/routes/create-abha-address-screen.tsx +0 -928
  87. package/src/routes/create-abha-with-aadhaar-screen.tsx +0 -986
  88. package/src/routes/create-eka-profile-screen.tsx +0 -831
  89. package/src/routes/get-all-profiles-screen.tsx +0 -161
  90. package/src/routes/login-or-create-abha-address-screen.tsx +0 -1056
  91. package/src/routes/login-with-abha-screen.tsx +0 -454
  92. package/src/routes/select-abha-from-list-screen.tsx +0 -792
  93. package/src/routes/select-eka-profile-screen.tsx +0 -446
  94. package/src/routes/utils/trackAbhaEvent.ts +0 -41
  95. package/src/stores/auth-abha-store/index.ts +0 -152
  96. package/src/stores/auth-abha-store/types.ts +0 -217
  97. package/src/utils/mock-auth-response.ts +0 -29
  98. package/src/utils/send-event-utils.ts +0 -76
  99. package/src/utils/validations.ts +0 -89
  100. package/src/vite-env.d.ts +0 -1
  101. package/tailwind.config.ts +0 -9
  102. package/tsconfig.json +0 -25
  103. package/tsconfig.node.json +0 -10
  104. package/tsconfig.node.tsbuildinfo +0 -1
  105. package/tsconfig.tsbuildinfo +0 -1
  106. package/vite.config.d.ts +0 -2
  107. package/vite.config.js +0 -30
  108. package/vite.config.ts +0 -35
  109. /package/{public → dist}/images/adhaar.webp +0 -0
  110. /package/{public → dist}/images/at-the-rate.webp +0 -0
  111. /package/{public → dist}/images/avatar.webp +0 -0
  112. /package/{public → dist}/images/ayushman-bharat.webp +0 -0
  113. /package/{public → dist}/images/circle-checkmark.webp +0 -0
  114. /package/{public → dist}/images/link-abha.webp +0 -0
  115. /package/{public → dist}/images/national-authority.webp +0 -0
  116. /package/{public → dist}/images/three-dots.webp +0 -0
@@ -1,519 +0,0 @@
1
- import { ArrowLeftRegularIcon, EkaIcon } from '@eka-care/icons';
2
- import { useState, useEffect } from 'react';
3
- import usePostAuthVerifyV2 from '../api-queries/use-post-auth-verify-v2';
4
- import Pds2Button from '../atoms/button';
5
- import AbhaHeader from '../organisms/abha/abha-header';
6
- import AbhaErrorBottomSheet from '../organisms/abha/error-bottom-sheet';
7
- import AbhaOtpCard from '../organisms/abha/otp-card';
8
- import useAuthAbhaStore from '../stores/auth-abha-store';
9
- import { SCREEN_NAMES } from '../stores/auth-abha-store/types';
10
- import usePostAbdmLoginVerify from '../api-queries/use-post-abdm-login-verify-v1';
11
- import ExitPopup from '../molecules/exit-popup';
12
- import { onAbhaSuccess, unMount } from '../main';
13
- import handleSendEvent from '../utils/send-event-utils';
14
- import { getMockAuthVerifyResponse } from '../utils/mock-auth-response';
15
- import AbhaStepper from '../organisms/abha/abha-stepper';
16
- import { ABHA_AUTH_FLOW_METHOD, ABHA_V3_SKIP_STATES, GET_EXTRA_HEADERS, LOADING_STATE, TProfileRecord } from '../constants/constants';
17
- import postAbdmLoginInit from '../api-queries/ndhm/post-abdm-login-init';
18
-
19
- const AbhaLoginOtpVerifyScreen = () => {
20
- const authTxnId = useAuthAbhaStore((state) => state.authTxnId);
21
- const txnId = useAuthAbhaStore((state) => state.txnId);
22
- const setAbhaAddressList = useAuthAbhaStore((state) => state.setAbhaAddressList);
23
- const clearAbhaAuthStore = useAuthAbhaStore((state) => state.clearAbhaAuthStore);
24
- const aadhaarOtpSentToHint = useAuthAbhaStore((state) => state.aadhaarOtpSentToHint);
25
- const loginIdentifierValue = useAuthAbhaStore((state) => state.loginIdentifierValue);
26
- const abhaAuthFlowMethod = useAuthAbhaStore((state) => state.abhaAuthFlowMethod);
27
- const setScreen = useAuthAbhaStore((state) => state.setScreen);
28
- const goBackLoginScreen = useAuthAbhaStore((state) => state.goBackLoginScreen);
29
- const setTxnId = useAuthAbhaStore((state) => state.setTxnId);
30
- const setBottomsheetErrorInfo = useAuthAbhaStore((state) => state.setBottomsheetErrorInfo);
31
- const [isExitPopupOpen, setIsExitPopupOpen] = useState<boolean>(false);
32
- const setEkaProfileInfo = useAuthAbhaStore((state) => state.setEkaProfileInfo);
33
- const setAadhaarVerificationSkipStateStatus = useAuthAbhaStore(
34
- (state) => state.setAadhaarVerificationSkipStateStatus
35
- );
36
- const setSelectedAbhaAddress = useAuthAbhaStore((state) => state.setSelectedAbhaAddress);
37
-
38
- const [otp, setOtp] = useState('');
39
- const [isOtpValid, setIsOtpValid] = useState(false);
40
- const [error, setError] = useState<string | null>('');
41
- const [abdmLoginVerifyApiStatus, setAbdmLoginVerifyApiStatus] = useState<LOADING_STATE>(
42
- LOADING_STATE.IDLE
43
- );
44
- const validGenders = ['M', 'F', 'O', 'U'] as const;
45
-
46
- const { mutateAsync: postAuthVerifyV2Mutate } = usePostAuthVerifyV2();
47
- const { mutateAsync: postAbdmLoginVerify } = usePostAbdmLoginVerify();
48
- const isEkaAppLogin = useAuthAbhaStore((state) => state.isEkaAppLogin);
49
- const clientId = useAuthAbhaStore((state) => state.clientId);
50
- const oid = useAuthAbhaStore((state) => state.oid);
51
- const isNewLoginOrCreateFlow = useAuthAbhaStore((state) => state.isNewLoginOrCreateFlow);
52
- const extra_headers = GET_EXTRA_HEADERS();
53
-
54
- // Analytics event tracker
55
- const trackAbhaEvent = ({ name, data = {} }: { name: string; data?: Record<string, any> }) => {
56
- const baseProps = {
57
- login_platform: clientId,
58
- is_eka_app_login: isEkaAppLogin ? 'true' : 'false',
59
- is_new_login_or_create_flow: isNewLoginOrCreateFlow ? 'true' : 'false',
60
- txn_id: txnId || 'missing txnId',
61
- oid: extra_headers?.['X-User-ID'] ? 'true' : 'false',
62
- access_token: extra_headers?.['auth'] ? 'true' : 'false',
63
- };
64
-
65
- const eventData = {
66
- ...baseProps,
67
- ...data,
68
- };
69
-
70
- handleSendEvent({
71
- eventName: name,
72
- eventData,
73
- });
74
-
75
- window.curio?.pushToMixpanel?.(name, eventData);
76
- };
77
-
78
- useEffect(() => {
79
- trackAbhaEvent({
80
- name: 'page_view',
81
- data: {
82
- page_view: 'abha_login_otp_verify',
83
- platform: clientId,
84
- },
85
- });
86
- }, []);
87
-
88
- const handleErrorBottomsheetButtonClick = () => {
89
- trackAbhaEvent({
90
- name: 'abha_login_otp_verify_error_bottomsheet_dismissed',
91
- data: { platform: clientId },
92
- });
93
- goBackLoginScreen();
94
- const isAppLogin = useAuthAbhaStore.getState().isEkaAppLogin;
95
- clearAbhaAuthStore();
96
- useAuthAbhaStore.setState({ isEkaAppLogin: isAppLogin });
97
- };
98
-
99
- const handleOtpCompletion = ({ otp: newOtp }: { otp: string }) => {
100
- setOtp(newOtp);
101
- trackAbhaEvent({
102
- name: 'abha_login_otp_completion',
103
- data: {
104
- type: 'verify',
105
- platform: clientId,
106
- txn_id: txnId,
107
- otp_entered: true,
108
- method: abhaAuthFlowMethod,
109
- },
110
- });
111
- handleVerifyClick(newOtp);
112
- };
113
-
114
- const handleVerifyClick = async (otpToSubmit: string) => {
115
- if (!txnId) {
116
- trackAbhaEvent({
117
- name: 'abha_login_otp_verify_txnId_not_found',
118
- data: {
119
- type: 'verify',
120
- platform: clientId,
121
- txn_id: txnId || 'missing_txn_id',
122
- txn_id_exists: !!txnId,
123
- method: abhaAuthFlowMethod?.toLowerCase() || 'unknown_method',
124
- },
125
- });
126
- return;
127
- }
128
- trackAbhaEvent({
129
- name: 'abha_login_otp_verify',
130
- data: {
131
- type: 'verify',
132
- platform: clientId,
133
- txn_id: txnId,
134
- },
135
- });
136
-
137
- setAbdmLoginVerifyApiStatus(LOADING_STATE.LOADING);
138
- const {
139
- abha_profiles = [],
140
- skip_state,
141
- profile,
142
- error: verifyError,
143
- action: errorAction,
144
- eka,
145
- } = await postAbdmLoginVerify({ otp: otpToSubmit, txn_id: txnId });
146
-
147
- if (errorAction) {
148
- trackAbhaEvent({
149
- name: 'abha_login_otp_verify_error_action',
150
- data: {
151
- type: 'verify',
152
- platform: clientId,
153
- error_action: errorAction || 'no_error_action',
154
- error_message: verifyError || 'no_error_message',
155
- error_action_exists: !!errorAction,
156
- error_message_exists: !!verifyError,
157
- },
158
- });
159
- setBottomsheetErrorInfo(errorAction);
160
- return;
161
- }
162
-
163
- if (verifyError) {
164
- trackAbhaEvent({
165
- name: 'abha_login_otp_verify_error',
166
- data: {
167
- type: 'verify',
168
- platform: clientId,
169
- error_message: verifyError || 'unknown_error',
170
- error_message_exists: !!verifyError,
171
- },
172
- });
173
- setAbdmLoginVerifyApiStatus(LOADING_STATE.REJECTED);
174
- setError(verifyError);
175
- return;
176
- }
177
-
178
- if (!skip_state) {
179
- setError('Skip State is missing');
180
- trackAbhaEvent({
181
- name: 'abha_login_skip_state_missing',
182
- data: {
183
- platform: clientId,
184
- skipState: skip_state || 'missing_skip_state',
185
- skipState_exists: !!skip_state,
186
- },
187
- });
188
- return;
189
- }
190
-
191
- setAadhaarVerificationSkipStateStatus(skip_state);
192
- if (profile) {
193
- setSelectedAbhaAddress(profile.abha_address);
194
- }
195
-
196
- // if profile data exists, then set in store
197
- if (profile) {
198
- setEkaProfileInfo({
199
- date_of_birth: `${profile.year_of_birth}-${String(profile.month_of_birth).padStart(2, '0')}-${String(profile.day_of_birth).padStart(2, '0')}`,
200
- firstname: profile.first_name as string,
201
- lastname: profile.last_name as string,
202
- pincode: profile.pincode as string,
203
- gender: profile.gender as string,
204
- name: (profile.first_name + ' ' + profile.last_name) as string,
205
- mobile: profile.mobile,
206
- oid: eka?.oid,
207
- abha_address: profile?.abha_address,
208
- abha_number: profile?.abha_number,
209
- });
210
- }
211
-
212
- const gender = validGenders.includes(profile?.gender as any)
213
- ? (profile?.gender as 'M' | 'F' | 'O' | 'U')
214
- : undefined;
215
-
216
- const authProfile: TProfileRecord = {
217
- oid: eka?.oid || '',
218
- fln: profile?.first_name + ' ' + profile?.last_name,
219
- dob: `${profile?.year_of_birth}-${String(profile?.month_of_birth).padStart(2, '0')}-${String(profile?.day_of_birth).padStart(2, '0')}`,
220
- gen: gender,
221
- mobile: profile?.mobile,
222
- at: '',
223
- fn: profile?.first_name || '',
224
- mn: profile?.middle_name || '',
225
- ln: profile?.last_name || '',
226
- 'health-ids': profile?.abha_address ? [profile.abha_address] : undefined,
227
- abha_number: profile?.abha_number || '',
228
- };
229
-
230
- // ABHA_V3_SKIP_STATES.ABHA_END
231
- if (skip_state === ABHA_V3_SKIP_STATES.ABHA_END) {
232
- /**
233
- * check for min_token and oid
234
- * if min_token is present, call auth verify
235
- * if not show error
236
- */
237
- // if the auth token and oid is present in the headers, then do not trigger auth verify api
238
- if (isEkaAppLogin) {
239
- trackAbhaEvent({
240
- name: 'abha_login_otp_verify_eka_app',
241
- data: {
242
- type: 'verify',
243
- platform: clientId,
244
- txn_id: txnId,
245
- skip_state: skip_state,
246
- },
247
- });
248
- setAbdmLoginVerifyApiStatus(LOADING_STATE.RESOLVED);
249
- if (!eka) {
250
- trackAbhaEvent({
251
- name: 'abha_login_otp_verify_eka_app_error',
252
- data: {
253
- type: 'null_oid',
254
- platform: clientId,
255
- txn_id: txnId || 'missing_txn_id',
256
- txn_id_exists: !!txnId,
257
- eka: eka || 'missing_eka',
258
- eka_exists: !!eka,
259
- skip_state: skip_state || 'missing_skip_state',
260
- skip_state_exists: !!skip_state,
261
- },
262
- });
263
- setAbdmLoginVerifyApiStatus(LOADING_STATE.REJECTED);
264
- setError('Something went wrong, please try again');
265
- return;
266
- }
267
-
268
- const authResponse = getMockAuthVerifyResponse(authProfile);
269
- // for ios specific handling
270
- trackAbhaEvent({
271
- name: 'abha_login_otp_verify_success',
272
- data: {
273
- type: 'verify',
274
- platform: clientId,
275
- txn_id: txnId,
276
- skip_state: skip_state,
277
- method: abhaAuthFlowMethod,
278
- },
279
- });
280
- if (window.EkaAbha && window.EkaAbha.onAbhaSuccess) {
281
- window.EkaAbha?.onAbhaSuccess(JSON.stringify({ response: authResponse }));
282
- return;
283
- }
284
- //@ts-ignore
285
- onAbhaSuccess({ response: authResponse });
286
- unMount();
287
- return;
288
- }
289
- if (!eka || !eka.min_token || !authTxnId) {
290
- trackAbhaEvent({
291
- name: 'abha_login_otp_verify_eka_error',
292
- data: {
293
- type: 'verify',
294
- platform: clientId,
295
- eka: eka || 'missing_eka',
296
- eka_exists: !!eka,
297
- auth_txnId: authTxnId || 'missing_auth_txnId',
298
- auth_txnId_exists: !!authTxnId,
299
- skip_state: skip_state || 'missing_skip_state',
300
- skip_state_exists: !!skip_state,
301
- },
302
- });
303
- setAbdmLoginVerifyApiStatus(LOADING_STATE.REJECTED);
304
- setError('Something went wrong, please try again');
305
- return;
306
- }
307
-
308
- const authVerifyResponse = await postAuthVerifyV2Mutate({
309
- txn_id: authTxnId,
310
- token: eka.min_token,
311
- ...(eka.oid ? { oid: eka.oid } : null),
312
- });
313
-
314
- if (!authVerifyResponse.data) {
315
- trackAbhaEvent({
316
- name: 'abha_login_otp_verify_auth_verify_error',
317
- data: {
318
- type: 'verify',
319
- platform: clientId,
320
- skip_state: skip_state || 'missing_skip_state',
321
- skip_state_exists: !!skip_state,
322
- auth_verify_data_exists: false,
323
- },
324
- });
325
- setAbdmLoginVerifyApiStatus(LOADING_STATE.REJECTED);
326
- setError(authVerifyResponse.error?.message || 'Something went wrong, please try again');
327
- return;
328
- }
329
-
330
- trackAbhaEvent({
331
- name: 'abha_login_otp_verify_abha_end_success',
332
- data: {
333
- type: 'verify',
334
- platform: clientId,
335
- txn_id: txnId,
336
- skip_state: skip_state,
337
- },
338
- });
339
- setAbdmLoginVerifyApiStatus(LOADING_STATE.RESOLVED);
340
- return;
341
- }
342
-
343
- // ABHA_V3_SKIP_STATES.ABHA_SELECT
344
- if (skip_state === ABHA_V3_SKIP_STATES.ABHA_SELECT && abha_profiles.length > 0) {
345
- trackAbhaEvent({
346
- name: 'abha_login_otp_verify_abha_select',
347
- data: {
348
- type: 'verify',
349
- platform: clientId,
350
- },
351
- });
352
- setScreen(SCREEN_NAMES.SELECT_ABHA_FROM_LIST);
353
- setAbhaAddressList(abha_profiles);
354
- return;
355
- }
356
-
357
- // ABHA_V3_SKIP_STATES.ABHA_CREATE && LOGIN METHOD IS MOBILE
358
- if (
359
- skip_state === ABHA_V3_SKIP_STATES.ABHA_CREATE &&
360
- abhaAuthFlowMethod === ABHA_AUTH_FLOW_METHOD.MOBILE
361
- ) {
362
- setScreen(SCREEN_NAMES.CREATE_EKA_PROFILE);
363
- return;
364
- }
365
-
366
- // ABHA_V3_SKIP_STATES.ABHA_CREATE && LOGIN METHOD IS ABHA NUMBER
367
- if (skip_state === ABHA_V3_SKIP_STATES.ABHA_CREATE) {
368
- setScreen(SCREEN_NAMES.CREATE_ABHA_ADDRESS);
369
- return;
370
- }
371
-
372
- // if the auth token and oid is present in the headers, then do not trigger auth verify api
373
- if (isEkaAppLogin) {
374
- if (!eka) {
375
- trackAbhaEvent({
376
- name: 'abha_login_otp_verify_eka_failed',
377
- data: {
378
- type: 'verify',
379
- platform: clientId,
380
- txn_id: authTxnId || 'missing_authTxnId',
381
- txn_id_exists: !!authTxnId,
382
- },
383
- });
384
- setAbdmLoginVerifyApiStatus(LOADING_STATE.REJECTED);
385
- setError('Something went wrong, please try again');
386
- return;
387
- }
388
- const authResponse = getMockAuthVerifyResponse(authProfile);
389
-
390
- setAbdmLoginVerifyApiStatus(LOADING_STATE.RESOLVED);
391
- // for ios specific handling
392
- if (window.EkaAbha && window.EkaAbha.onAbhaSuccess) {
393
- window.EkaAbha?.onAbhaSuccess(JSON.stringify({ response: authResponse }));
394
- return;
395
- }
396
- //@ts-ignore
397
- onAbhaSuccess({ response: authResponse });
398
- unMount();
399
- return;
400
- }
401
-
402
- if (!skip_state || !eka?.min_token) {
403
- setAbdmLoginVerifyApiStatus(LOADING_STATE.REJECTED);
404
- setError(verifyError || 'Something went wrong, please try again');
405
- if (errorAction) {
406
- setBottomsheetErrorInfo(errorAction);
407
- }
408
- return;
409
- }
410
-
411
- if (eka.min_token && authTxnId) {
412
- const authVerifyResponse = await postAuthVerifyV2Mutate({
413
- txn_id: authTxnId,
414
- token: eka.min_token,
415
- });
416
-
417
- if (!authVerifyResponse.data) {
418
- trackAbhaEvent({
419
- name: 'abha_login_auth_verify_failed',
420
- data: {
421
- platform: clientId,
422
- txn_id: authTxnId || 'missing_authTxnId',
423
- txn_id_exists: !!authTxnId,
424
- error_message: authVerifyResponse?.error?.message || 'unknown_error',
425
- error_message_exists: !!authVerifyResponse?.error?.message,
426
- },
427
- });
428
- setAbdmLoginVerifyApiStatus(LOADING_STATE.REJECTED);
429
- setError(authVerifyResponse.error?.message || 'Something went wrong, please try again');
430
- } else {
431
- trackAbhaEvent({
432
- name: 'abha_login_auth_verify_success',
433
- data: {
434
- platform: clientId,
435
- txn_id: authTxnId,
436
- },
437
- });
438
- }
439
- }
440
-
441
- setAbdmLoginVerifyApiStatus(LOADING_STATE.RESOLVED);
442
- };
443
-
444
- const handleResendOtpClick = async () => {
445
- if (loginIdentifierValue && abhaAuthFlowMethod) {
446
- const { txn_id } = await postAbdmLoginInit({
447
- method: abhaAuthFlowMethod,
448
- identifier: loginIdentifierValue,
449
- });
450
- trackAbhaEvent({
451
- name: 'abha_login_verify_resend_otp',
452
- data: {
453
- method: abhaAuthFlowMethod,
454
- platform: clientId,
455
- txn_id: txn_id,
456
- },
457
- });
458
- if (txn_id) {
459
- setTxnId(txn_id);
460
- }
461
- }
462
- };
463
-
464
- return (
465
- <div className="pds2-flex pds2-flex-col pds2-w-full pds2-h-full pds2-bg-bg-white">
466
- <AbhaHeader
467
- prefixIcon={
468
- <button
469
- className="pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple"
470
- onClick={() => setIsExitPopupOpen(true)}
471
- >
472
- <ArrowLeftRegularIcon className="" />
473
- </button>
474
- }
475
- title="OTP Verification"
476
- suffixIcon={<EkaIcon className="pds2-w-20 pds2-h-20" />}
477
- className="pds2-border-b-1 pds2-border-bg-seperator-dark"
478
- />
479
- <AbhaStepper/>
480
- <div className="pds2-p-16 pds2-space-y-16 pds2-overflow-y-auto pds2-flex-1 pds2-bg-bg-01">
481
- <AbhaOtpCard
482
- otpSentToText={
483
- aadhaarOtpSentToHint || 'Enter OTP sent on mobile number linked with your Aadhaar'
484
- }
485
- onOtpCompletion={handleOtpCompletion}
486
- onResendOtpClick={handleResendOtpClick}
487
- error={error}
488
- setIsValid={(val) => {
489
- error && setError(null);
490
- setIsOtpValid(val);
491
- }}
492
- prefixIcon={
493
- <img
494
- src="https://cdn.eka.care/vagus/cm6hreldp000b0tfwf0nj156l.webp"
495
- alt="abha"
496
- className="pds2-w-48"
497
- />
498
- }
499
- />
500
- </div>
501
- {/* removing this error , since it is handled inside otp card */}
502
- {/* {error && <div className="pds2-p-16 pds2-text-text-error pds2-text-center">{error}</div>} */}
503
- <div className="pds2-p-16 pds2-sticky pds2-bottom-0 pds2-bg-bg-white pds2-w-full pds2-border pds2-border-border-brand-02">
504
- <Pds2Button
505
- title="Verify"
506
- state={!isOtpValid || abdmLoginVerifyApiStatus === LOADING_STATE.LOADING ? 'disabled' : 'enabled'}
507
- className="pds2-w-full"
508
- onClick={() => handleVerifyClick(otp)}
509
- isLoading={abdmLoginVerifyApiStatus === LOADING_STATE.LOADING}
510
- />
511
- </div>
512
-
513
- <AbhaErrorBottomSheet onSubmitClick={handleErrorBottomsheetButtonClick} />
514
- <ExitPopup open={isExitPopupOpen} setOpen={setIsExitPopupOpen} />
515
- </div>
516
- );
517
- };
518
-
519
- export default AbhaLoginOtpVerifyScreen;