@eka-care/abha 0.0.5 → 0.0.7

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 (85) 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 +136 -0
  4. package/package.json +2 -4
  5. package/.eslintignore +0 -3
  6. package/.eslintrc +0 -29
  7. package/.prettierrc +0 -7
  8. package/dev-abha-ios-android.zip +0 -0
  9. package/postcss.config.js +0 -6
  10. package/prod-abha-mixpanel.zip +0 -0
  11. package/scripts/build-purged-css.cjs +0 -70
  12. package/src/App.css +0 -0
  13. package/src/App.tsx +0 -32
  14. package/src/api-queries/use-get-profiles-patient.ts +0 -12
  15. package/src/api-queries/use-get-profiles-phr-user.ts +0 -27
  16. package/src/api-queries/use-post-abdm-login-verify-v1.ts +0 -25
  17. package/src/api-queries/use-post-auth-verify-v2.ts +0 -74
  18. package/src/api-queries/use-post-profile-switch.ts +0 -57
  19. package/src/api-queries/use-post-register-mobile-create-phr.ts +0 -39
  20. package/src/api-queries/user-post-abdm-profile-login-phr.ts +0 -25
  21. package/src/assets/react.svg +0 -1
  22. package/src/atoms/button/custom-button.tsx +0 -32
  23. package/src/atoms/button/index.tsx +0 -40
  24. package/src/atoms/button/types.d.ts +0 -31
  25. package/src/atoms/header.tsx +0 -25
  26. package/src/atoms/input-field/index.tsx +0 -62
  27. package/src/atoms/input-field/patient-input-field.tsx +0 -16
  28. package/src/atoms/input-field/types.ts +0 -24
  29. package/src/atoms/pds2-otp-input/index.tsx +0 -35
  30. package/src/atoms/pds2-otp-input/types.d.ts +0 -3
  31. package/src/atoms/single-input-chip/index.tsx +0 -32
  32. package/src/atoms/single-input-chip/types.ts +0 -6
  33. package/src/atoms/spinner.tsx +0 -33
  34. package/src/atoms/text-separator.tsx +0 -11
  35. package/src/index.css +0 -118
  36. package/src/main.tsx +0 -313
  37. package/src/molecules/abha/bottom-sheet/bottom-sheet-wrapper.tsx +0 -40
  38. package/src/molecules/abha/bottom-sheet/index.tsx +0 -66
  39. package/src/molecules/abha/spaced-input-component.tsx +0 -150
  40. package/src/molecules/copyright-year.tsx +0 -16
  41. package/src/molecules/exit-popup/index.tsx +0 -99
  42. package/src/molecules/pds2-otp-component/index.tsx +0 -148
  43. package/src/organisms/abha/abha-header.tsx +0 -25
  44. package/src/organisms/abha/error-bottom-sheet.tsx +0 -27
  45. package/src/organisms/abha/otp-card.tsx +0 -99
  46. package/src/organisms/abha/verification-status.tsx +0 -40
  47. package/src/organisms/choose-language/choose-language.tsx +0 -53
  48. package/src/organisms/choose-language/types.ts +0 -10
  49. package/src/organisms/screen-switcher/screen-switcher.tsx +0 -80
  50. package/src/routes/abha-aadhaar-verification-status-screen.tsx +0 -209
  51. package/src/routes/abha-created-screen.tsx +0 -45
  52. package/src/routes/abha-login-otp-verify-screen.tsx +0 -523
  53. package/src/routes/abha-mobile-linking-status-screen.tsx +0 -267
  54. package/src/routes/abha-otp-and-mobile-screen.tsx +0 -429
  55. package/src/routes/abha-phone-number-verification-screen.tsx +0 -373
  56. package/src/routes/create-abha-address-screen.tsx +0 -928
  57. package/src/routes/create-abha-with-aadhaar-screen.tsx +0 -984
  58. package/src/routes/create-eka-profile-screen.tsx +0 -777
  59. package/src/routes/get-all-profiles-screen.tsx +0 -161
  60. package/src/routes/login-or-create-abha-address-screen.tsx +0 -953
  61. package/src/routes/login-with-abha-screen.tsx +0 -448
  62. package/src/routes/select-abha-from-list-screen.tsx +0 -718
  63. package/src/routes/select-eka-profile-screen.tsx +0 -444
  64. package/src/routes/utils/trackAbhaEvent.ts +0 -41
  65. package/src/stores/auth-abha-store/index.ts +0 -138
  66. package/src/stores/auth-abha-store/types.ts +0 -204
  67. package/src/utils/mock-auth-response.ts +0 -31
  68. package/src/vite-env.d.ts +0 -1
  69. package/tailwind.config.ts +0 -9
  70. package/tsconfig.app.json +0 -26
  71. package/tsconfig.json +0 -25
  72. package/tsconfig.node.json +0 -10
  73. package/tsconfig.node.tsbuildinfo +0 -1
  74. package/tsconfig.tsbuildinfo +0 -1
  75. package/vite.config.d.ts +0 -2
  76. package/vite.config.js +0 -30
  77. package/vite.config.ts +0 -35
  78. /package/{public → dist}/images/adhaar.webp +0 -0
  79. /package/{public → dist}/images/at-the-rate.webp +0 -0
  80. /package/{public → dist}/images/avatar.webp +0 -0
  81. /package/{public → dist}/images/ayushman-bharat.webp +0 -0
  82. /package/{public → dist}/images/circle-checkmark.webp +0 -0
  83. /package/{public → dist}/images/link-abha.webp +0 -0
  84. /package/{public → dist}/images/national-authority.webp +0 -0
  85. /package/{public → dist}/images/three-dots.webp +0 -0
@@ -1,718 +0,0 @@
1
- import {
2
- ArrowLeftRegularIcon,
3
- // ChevronDownRegularIcon,
4
- // CircleCheckSolidIcon,
5
- // EkaIcon,
6
- PlusRegularIcon,
7
- // ProfileIcon,
8
- // XMarkRegularIcon,
9
- } from '@elixir/icons';
10
- import {
11
- ABHA_AUTH_FLOW_METHOD,
12
- LOADING_STATE,
13
- REGISTRATION_TYPE,
14
- TProfileRecord,
15
- } from '@elixir/types';
16
- import React, { useState } from 'react';
17
- import Pds2Button from '../atoms/button';
18
- import Pds2CustomButton from '../atoms/button/custom-button';
19
- import Pds2Header from '../atoms/header';
20
- import TextSeparator from '../atoms/text-separator';
21
- import AbhaErrorBottomSheet from '../organisms/abha/error-bottom-sheet';
22
- import useAuthAbhaStore from '../stores/auth-abha-store';
23
- import { SCREEN_NAMES, TAbhaAddress } from '../stores/auth-abha-store/types';
24
- import usePostAuthVerifyV2 from '../api-queries/use-post-auth-verify-v2';
25
- import ExitPopup from '../molecules/exit-popup';
26
- import usePostAbdmProfileLoginPhr from '../api-queries/user-post-abdm-profile-login-phr';
27
- import { onAbhaSuccess, unMount } from '../main';
28
- import { handleSendEvent } from '@elixir/utils';
29
- import { getMockAuthVerifyResponse } from '../utils/mock-auth-response';
30
- import { postRegisterAadhaarInit, postRegisterMobileInit } from 'apis';
31
- import { GET_EXTRA_HEADERS } from 'apis';
32
-
33
- type InitMethod = 'aadhaar' | 'mobile';
34
-
35
- const SelectAbhaFromListScreen = () => {
36
- const [selectedAbha, setSelectedAbha] = useState<TAbhaAddress | null>(null);
37
- const setScreen = useAuthAbhaStore((state) => state.setScreen);
38
- const goBackLoginScreen = useAuthAbhaStore((state) => state.goBackLoginScreen);
39
- const txnId = useAuthAbhaStore((state) => state.txnId);
40
- const authTxnId = useAuthAbhaStore((state) => state.authTxnId);
41
- const abhaAddressList = useAuthAbhaStore((state) => state.abhaAddressList);
42
- const setBottomsheetErrorInfo = useAuthAbhaStore((state) => state.setBottomsheetErrorInfo);
43
- const clearAbhaAuthStore = useAuthAbhaStore((state) => state.clearAbhaAuthStore);
44
- const setSelectedAbhaAddress = useAuthAbhaStore((state) => state.setSelectedAbhaAddress);
45
- const abhaAuthFlowMethod = useAuthAbhaStore((state) => state.abhaAuthFlowMethod);
46
- const loginIdentifierValue = useAuthAbhaStore((state) => state.loginIdentifierValue);
47
- const [error, setError] = useState<string | null>('');
48
- const [isExitPopupOpen, setIsExitPopupOpen] = useState<boolean>(false);
49
- const setEkaProfileInfo = useAuthAbhaStore((state) => state.setEkaProfileInfo);
50
- const setAadhaarVerificationSkipStateStatus = useAuthAbhaStore(
51
- (state) => state.setAadhaarVerificationSkipStateStatus
52
- );
53
-
54
- const [abdmLoginVerifyApiStatus, setAbdmLoginVerifyApiStatus] = useState<LOADING_STATE>(
55
- LOADING_STATE.IDLE
56
- );
57
-
58
- const validGenders = ['M', 'F', 'O', 'U'] as const;
59
-
60
- // const [isBottomSheetOpen, setIsBottomSheetOpen] = useState<boolean>(false);
61
- const { mutateAsync: postAuthVerifyV2Mutate } = usePostAuthVerifyV2();
62
- const { mutateAsync: postAbdmProfileLoginPhr } = usePostAbdmProfileLoginPhr();
63
- const ekaProfileInfo = useAuthAbhaStore((state) => state.ekaProfileInfo);
64
-
65
- const registrationType = useAuthAbhaStore((state) => state.registrationType);
66
- const clientId = useAuthAbhaStore((state) => state.clientId);
67
- const isEkaAppLogin = useAuthAbhaStore((state) => state.isEkaAppLogin);
68
- const setRegistrationType = useAuthAbhaStore((state) => state.setRegistrationType);
69
- const selectedMethod = useAuthAbhaStore((state) => state.abhaAuthFlowMethod);
70
- const identityValue = useAuthAbhaStore((state) => state.identityValue);
71
- const setMobileInitResponse = useAuthAbhaStore((state) => state.setMobileInitResponse);
72
- const [initApiStatus, setInitApiStatus] = useState<Record<InitMethod, LOADING_STATE>>({
73
- aadhaar: LOADING_STATE.IDLE,
74
- mobile: LOADING_STATE.IDLE,
75
- });
76
- const setAadhaarInitResponse = useAuthAbhaStore((state) => state.setAadhaarInitResponse);
77
- const setSelectedAbhaFlow = useAuthAbhaStore((state) => state.setSelectedAbhaFlow);
78
- const isNewLoginOrCreateFlow = useAuthAbhaStore((state) => state.isNewLoginOrCreateFlow);
79
- const extra_headers = GET_EXTRA_HEADERS();
80
-
81
- // Analytics event tracker
82
- const trackAbhaEvent = ({ name, data = {} }: { name: string; data?: Record<string, any> }) => {
83
- const baseProps = {
84
- login_platform: clientId,
85
- is_eka_app_login: isEkaAppLogin ? 'true' : 'false',
86
- is_new_login_or_create_flow: isNewLoginOrCreateFlow ? 'true' : 'false',
87
- txn_id: txnId || 'missing txnId',
88
- oid: extra_headers?.['X-User-ID'] ? 'true' : 'false',
89
- access_token: extra_headers?.['auth'] ? 'true' : 'false',
90
- flow: selectedMethod ?? ""
91
- };
92
-
93
- const eventData = {
94
- ...baseProps,
95
- ...data,
96
- };
97
-
98
- handleSendEvent({
99
- eventName: name,
100
- eventData,
101
- });
102
-
103
- window.curio?.pushToMixpanel?.(name, eventData);
104
- };
105
-
106
- const handleCreateABHAClick = async () => {
107
- trackAbhaEvent({
108
- name: 'abha_login_select_abha_init_started',
109
- data: {
110
- method: selectedMethod,
111
- platform: clientId,
112
- },
113
- });
114
-
115
- // Create a helper function to update status
116
- const updateInitStatus = (method: InitMethod, status: LOADING_STATE) => {
117
- setInitApiStatus((prev) => ({
118
- ...prev,
119
- [method]: status,
120
- }));
121
- };
122
-
123
- // set the registration type as create
124
- setRegistrationType(REGISTRATION_TYPE.CREATE);
125
-
126
- // call the registration verify api for corresponding abha app method
127
- if (selectedMethod === ABHA_AUTH_FLOW_METHOD.MOBILE) {
128
- const {
129
- txn_id,
130
- hint,
131
- error: mobileError,
132
- action: errorAction,
133
- } = await postRegisterMobileInit({
134
- mobile_number: identityValue,
135
- });
136
- if (txn_id && hint) {
137
- trackAbhaEvent({
138
- name: 'abha_login_select_abha_mobile_init_success',
139
- data: {
140
- method: selectedMethod,
141
- platform: clientId,
142
- txn_id,
143
- },
144
- });
145
- setMobileInitResponse({
146
- authTxnId,
147
- txnId: txn_id,
148
- mobileOtpSentToHint: hint,
149
- });
150
- setSelectedAbhaFlow('mobile');
151
- updateInitStatus('mobile', LOADING_STATE.RESOLVED);
152
- setRegistrationType(REGISTRATION_TYPE.CREATE);
153
- setScreen(SCREEN_NAMES.ABHA_PHONE_NUMBER_VERIFICATION);
154
- return;
155
- }
156
-
157
- trackAbhaEvent({
158
- name: 'abha_login_select_abha_init_failed',
159
- data: {
160
- method: selectedMethod,
161
- platform: clientId,
162
- reason: mobileError || 'unknown',
163
- reason_exists: !!mobileError,
164
- },
165
- });
166
-
167
- updateInitStatus('mobile', LOADING_STATE.REJECTED);
168
- if (errorAction) {
169
- setBottomsheetErrorInfo(errorAction);
170
- } else {
171
- setError(mobileError || 'Something went wrong');
172
- }
173
- } else if (selectedMethod === ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER) {
174
- const {
175
- txn_id,
176
- hint,
177
- error: aadhaarError,
178
- action: errorAction,
179
- } = await postRegisterAadhaarInit({
180
- aadhaar_number: identityValue,
181
- });
182
- if (txn_id && hint) {
183
- trackAbhaEvent({
184
- name: 'abha_login_select_abha_aadhaar_init_success',
185
- data: {
186
- method: selectedMethod,
187
- platform: clientId,
188
- txn_id,
189
- },
190
- });
191
- setAadhaarInitResponse({
192
- authTxnId,
193
- txnId: txn_id,
194
- aadhaarOtpSentToHint: hint,
195
- });
196
- updateInitStatus('aadhaar', LOADING_STATE.RESOLVED);
197
- setSelectedAbhaFlow('aadhaar');
198
- setRegistrationType(REGISTRATION_TYPE.CREATE);
199
- setScreen(SCREEN_NAMES.ABHA_OTP_AND_MOBILE);
200
- return;
201
- }
202
-
203
- trackAbhaEvent({
204
- name: 'abha_login_select_abha_init_failed',
205
- data: {
206
- method: selectedMethod,
207
- platform: clientId,
208
- reason: aadhaarError || 'unknown',
209
- reason_exists: !!aadhaarError,
210
- },
211
- });
212
-
213
- updateInitStatus('aadhaar', LOADING_STATE.REJECTED);
214
- if (errorAction) {
215
- trackAbhaEvent({
216
- name: 'abha_login_select_abha_error_action',
217
- data: {
218
- method: selectedMethod,
219
- platform: clientId,
220
- action: errorAction?.cta?.title || 'unknown',
221
- action_exists: !!errorAction?.cta?.title,
222
- },
223
- });
224
- setBottomsheetErrorInfo(errorAction);
225
- } else {
226
- setError(aadhaarError || 'Something went wrong');
227
- }
228
- return;
229
- }
230
- return;
231
- };
232
-
233
- const handleContinueClick = async () => {
234
- if (!selectedAbha) return;
235
- setSelectedAbhaAddress(selectedAbha.abha_address);
236
-
237
- console.log(abdmLoginVerifyApiStatus, "from abha" )
238
- if (!txnId) {
239
- trackAbhaEvent({
240
- name: 'abha_login_select_abha_txnId_not_found',
241
- data: {
242
- platform: clientId,
243
- reason: 'txnId missing',
244
- reason_exists: true,
245
- },
246
- });
247
- return;
248
- }
249
-
250
- setAbdmLoginVerifyApiStatus(LOADING_STATE.LOADING);
251
-
252
- trackAbhaEvent({
253
- name: 'abha_login_select_abha_verify_start',
254
- data: {
255
- platform: clientId,
256
- txn_id: txnId,
257
- },
258
- });
259
-
260
- const {
261
- error: abdmError,
262
- eka,
263
- profile,
264
- action: errorAction,
265
- skip_state,
266
- } = await postAbdmProfileLoginPhr({
267
- txn_id: txnId,
268
- phr_address: selectedAbha.abha_address,
269
- });
270
-
271
- if (errorAction) {
272
- trackAbhaEvent({
273
- name: 'abha_login_select_abha_error_action',
274
- data: {
275
- platform: clientId,
276
- txn_id: txnId,
277
- action: errorAction?.cta?.title || 'unknown',
278
- action_exists: !!errorAction?.cta?.title,
279
- },
280
- });
281
- setBottomsheetErrorInfo(errorAction);
282
- return;
283
- }
284
-
285
- if (abdmError || !eka) {
286
- trackAbhaEvent({
287
- name: 'abha_login_select_abha_abdm_error',
288
- data: {
289
- platform: clientId,
290
- txn_id: txnId,
291
- error_message: abdmError || 'eka object missing',
292
- error_exists: !!abdmError,
293
- },
294
- });
295
- setAbdmLoginVerifyApiStatus(LOADING_STATE.REJECTED);
296
- setError(abdmError);
297
- return;
298
- }
299
-
300
- if (!skip_state) {
301
- setError('skip State is missing');
302
- return;
303
- }
304
-
305
- trackAbhaEvent({
306
- name: 'abha_login_select_abha_verify_success',
307
- data: {
308
- platform: clientId,
309
- txn_id: txnId,
310
- skip_state: skip_state,
311
- },
312
- });
313
-
314
- setAadhaarVerificationSkipStateStatus(skip_state);
315
-
316
- if (profile) {
317
- trackAbhaEvent({
318
- name: 'abha_login_select_abha_profile_received',
319
- data: {
320
- platform: clientId,
321
- },
322
- });
323
-
324
- setEkaProfileInfo({
325
- date_of_birth: `${profile.year_of_birth}-${String(profile.month_of_birth).padStart(2, '0')}-${String(profile.day_of_birth).padStart(2, '0')}`,
326
- firstname: profile.first_name as string,
327
- lastname: profile.last_name as string,
328
- pincode: profile.pincode as string,
329
- gender: profile.gender as string,
330
- name: (profile.first_name + ' ' + profile.last_name) as string,
331
- mobile: profile.mobile,
332
- oid: eka?.oid,
333
- middlename: profile.middle_name as string,
334
- abha_address: profile.abha_address,
335
- abha_number: profile.abha_number,
336
- });
337
- setSelectedAbhaAddress(profile.abha_address);
338
- }
339
-
340
- // if the trigger is from inside the app(phr case)
341
- // or if the trigger from the eka doc app, then return here
342
- if (isEkaAppLogin) {
343
- if (!eka.oid) {
344
- trackAbhaEvent({
345
- name: 'abha_login_select_abha_oid_null',
346
- data: {
347
- platform: clientId,
348
- oid: eka?.oid ?? 'null_or_undefined',
349
- },
350
- });
351
- setAbdmLoginVerifyApiStatus(LOADING_STATE.REJECTED);
352
- return;
353
- }
354
-
355
- const gender = validGenders.includes(profile?.gender as any)
356
- ? (profile?.gender as 'M' | 'F' | 'O' | 'U')
357
- : undefined;
358
-
359
- const authProfile: TProfileRecord = {
360
- oid: eka?.oid || '',
361
- fln: (profile?.first_name + ' ' + profile?.last_name) as string,
362
- dob: `${profile?.year_of_birth}-${String(profile?.month_of_birth).padStart(2, '0')}-${String(profile?.day_of_birth).padStart(2, '0')}`,
363
- gen: gender,
364
- mobile: profile?.mobile,
365
- at: '',
366
- fn: profile?.first_name || '',
367
- mn: profile?.middle_name || '',
368
- ln: profile?.last_name || '',
369
- 'health-ids': profile?.abha_address ? [profile.abha_address] : undefined,
370
- abha_number: profile?.abha_number || '',
371
- };
372
- const authResponse = getMockAuthVerifyResponse(authProfile);
373
- setAbdmLoginVerifyApiStatus(LOADING_STATE.RESOLVED);
374
-
375
- trackAbhaEvent({
376
- name: 'abha_login_select_abha_inside_app_success',
377
- data: {
378
- platform: clientId,
379
- oid: eka.oid,
380
- },
381
- });
382
-
383
- // @ts-ignore
384
- if (window.EkaAbha && window.EkaAbha.onAbhaSuccess) {
385
- // @ts-ignore
386
- window.EkaAbha?.onAbhaSuccess(JSON.stringify({ response: authResponse }));
387
- return;
388
- }
389
- // @ts-ignore
390
- onAbhaSuccess({ response: authResponse });
391
-
392
- trackAbhaEvent({
393
- name: 'connectivity-debug-unmount',
394
- data: {
395
- platform: clientId,
396
- eka: eka,
397
- line: 397,
398
- function: "isEkaAppLogin",
399
- page: "select-abha-from-list-screen.tsx",
400
- flow: "debug",
401
- },
402
- });
403
-
404
- unMount();
405
- return;
406
- }
407
-
408
- if (!eka.min_token || !authTxnId) {
409
- trackAbhaEvent({
410
- name: 'abha_login_select_abha_min_token_missing',
411
- data: {
412
- platform: clientId,
413
- oid: eka?.oid ?? 'missing_oid',
414
- min_token: eka?.min_token ?? 'missing_min_token',
415
- auth_txnId: authTxnId ?? 'missing_authTxnId',
416
- },
417
- });
418
- setAbdmLoginVerifyApiStatus(LOADING_STATE.REJECTED);
419
- setError(abdmError || 'Something went wrong. Please try again.');
420
- return;
421
- }
422
-
423
- const authVerifyResponse = await postAuthVerifyV2Mutate({
424
- txn_id: authTxnId,
425
- token: eka.min_token,
426
- ...(eka.oid ? { oid: eka.oid } : null),
427
- });
428
-
429
- if (!authVerifyResponse.data) {
430
- trackAbhaEvent({
431
- name: 'abha_login_select_abha_auth_verify_failed',
432
- data: {
433
- platform: clientId,
434
- oid: eka?.oid ?? 'missing_oid',
435
- min_token: eka?.min_token ?? 'missing_min_token',
436
- auth_txnId: authTxnId ?? 'missing_authTxnId',
437
- },
438
- });
439
- setAbdmLoginVerifyApiStatus(LOADING_STATE.REJECTED);
440
- setError(authVerifyResponse.error?.message || 'Something went wrong, please try again');
441
- return;
442
- }
443
- setAbdmLoginVerifyApiStatus(LOADING_STATE.RESOLVED);
444
-
445
- trackAbhaEvent({
446
- name: 'abha_login_select_abha_auth_verify_success',
447
- data: {
448
- platform: clientId,
449
- oid: eka.oid,
450
- min_token: eka?.min_token,
451
- auth_txnId: authTxnId,
452
- },
453
- });
454
- return;
455
- };
456
-
457
- const handleErrorBottomsheetButtonClick = () => {
458
- const mobileNumber = useAuthAbhaStore.getState().initAbhaAppMobileNumber;
459
- const isAppLogin = useAuthAbhaStore.getState().isEkaAppLogin;
460
- goBackLoginScreen();
461
- clearAbhaAuthStore();
462
- useAuthAbhaStore.setState({ initAbhaAppMobileNumber: mobileNumber });
463
- useAuthAbhaStore.setState({ isEkaAppLogin: isAppLogin });
464
- };
465
-
466
- return (
467
- <div className="pds2-w-full pds2-flex pds2-flex-col pds2-h-screen pds2-bg-bg-01">
468
- <Pds2Header
469
- title="Select ABHA to continue"
470
- prefixIcon={
471
- <button
472
- className="pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple"
473
- onClick={() => setIsExitPopupOpen(true)}
474
- >
475
- <ArrowLeftRegularIcon />
476
- </button>
477
- }
478
- className="pds2-border-b pds2-border-bg-seperator-dark pds2-bg-bg-white"
479
- />
480
-
481
- {/* Scrollable area: list + optional text */}
482
- <div className="pds2-flex-1 pds2-overflow-y-auto pds2-flex pds2-flex-col pds2-p-16 pds2-space-y-16">
483
- <div className="pds2-text-text-03 Body1Regular pds2-text-center">
484
- We found {abhaAddressList?.length} ABHA addresses <br /> select one you want to log in
485
- with
486
- </div>
487
- <AbhaList
488
- list={abhaAddressList}
489
- selectedAbha={selectedAbha}
490
- setSelectedAbha={setSelectedAbha}
491
- />
492
- {(abhaAddressList?.length ?? 0) < 6 &&
493
- (abhaAuthFlowMethod === ABHA_AUTH_FLOW_METHOD.MOBILE ||
494
- abhaAuthFlowMethod === ABHA_AUTH_FLOW_METHOD.AADHAR_NUMBER) && (
495
- <>
496
- <TextSeparator title="or" />
497
- <Pds2CustomButton
498
- title="Create new ABHA Address"
499
- prefixIcon={<PlusRegularIcon />}
500
- className="pds2-justify-center pds2-text-text-brand pds2-border-bg-fab-bg-brand-04 Body1Semibold"
501
- onClick={handleCreateABHAClick}
502
- />
503
- </>
504
- )}
505
- </div>
506
-
507
- {/* Footer fixed at bottom */}
508
- <div className="pds2-bg-bg-white pds2-shadow-lg pds2-w-full pds2-sticky pds2-bottom-0 pds2-border-t pds2-border-border-brand-02 pds2-p-16 z-10">
509
- {error && <div className="pds2-text-text-error pds2-text-center pds2-mb-4">{error}</div>}
510
- {abhaAuthFlowMethod === ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER && (
511
- <div className="pds2-text-center pds2-bg-bg-warning-03 pds2-py-2 pds2-mb-4">
512
- <span className="pds2-text-text-03 Body2Regular">Your ABHA No:</span>
513
- <span className="pds2-text-text-01 Body2Semibold">{loginIdentifierValue}</span>
514
- </div>
515
- )}
516
- <Pds2Button
517
- title="Continue"
518
- state={selectedAbha === null || abdmLoginVerifyApiStatus === LOADING_STATE.LOADING ? 'disabled' : 'enabled'}
519
- isLoading={abdmLoginVerifyApiStatus === LOADING_STATE.LOADING}
520
- className="pds2-w-full"
521
- onClick={handleContinueClick}
522
- />
523
- </div>
524
-
525
- <AbhaErrorBottomSheet onSubmitClick={handleErrorBottomsheetButtonClick} />
526
- <ExitPopup open={isExitPopupOpen} setOpen={setIsExitPopupOpen} />
527
- </div>
528
- );
529
- };
530
-
531
- export default SelectAbhaFromListScreen;
532
-
533
- const AbhaList = ({
534
- list,
535
- selectedAbha,
536
- setSelectedAbha,
537
- }: {
538
- list: TAbhaAddress[] | null;
539
- selectedAbha: TAbhaAddress | null;
540
- setSelectedAbha: (abha: TAbhaAddress) => void;
541
- }) => {
542
- // const [tooltipAbhaId, setTooltipAbhaId] = useState<string | null>(null);
543
-
544
- return (
545
- <div className="pds2-bg-bg-white pds2-rounded-16 pds2-border pds2-border-border-brand-02 pds2-w-full pds2-relative">
546
- {list?.map((abha, index) => (
547
- <React.Fragment key={abha.abha_address}>
548
- <label className="pds2-p-16 pds2-flex pds2-space-x-8">
549
- <input
550
- className="pds2-self-start pds2-mt-4 pds2-w-14 pds2-h-14 pds2-p-2 checked:pds2-accent-text-brand"
551
- type="radio"
552
- value={abha.abha_address}
553
- checked={selectedAbha?.abha_address === abha.abha_address}
554
- onChange={() => {
555
- setSelectedAbha(abha);
556
- }}
557
- />
558
- <div className="pds2-flex pds2-flex-col pds2-space-y-4 pds2-flex-1">
559
- <div className="TitlesSubheadline pds2-text-text-primary pds2-flex pds2-flex-row pds2-items-center pds2-justify-between">
560
- <div>{abha?.abha_address}</div>
561
- {/* {abha?.name && <div className="Body3Regular pds2-text-text-03">{abha.name}</div>} */}
562
- {/* <div
563
- className="pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-8 pds2-cursor-pointer pds2-relative"
564
- onClick={(e) => {
565
- e.preventDefault();
566
- setTooltipAbhaId(tooltipAbhaId === abha.oid ? null : abha.oid);
567
- }}
568
- >
569
- <div className="pds2-bg-icon-orange-500 pds2-text-text-white pds2-rounded-full pds2-px-4 Label1Semibold">
570
- P
571
- </div>
572
- <CircleCheckSolidIcon className="pds2-w-14 pds2-h-14 pds2-text-icon-success-02" />
573
- {tooltipAbhaId === abha.oid && (
574
- <div className="pds2-absolute pds2-right-0 pds2-top-full pds2-mt-2 pds2-z-50 pds2-animate-fade-in">
575
- <TooltipContent />
576
- </div>
577
- )}
578
- </div> */}
579
- </div>
580
-
581
- <div className="pds2-text-text-03 Body3Regular pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-4">
582
- {abha?.name && <div className="Body3Regular pds2-text-text-03">{abha.name}</div>}
583
- {/* {abha?.eka_username ? (
584
- <>
585
- <EkaIcon className="pds2-w-12 pds2-h-12" />
586
- <span>
587
- {abha?.eka_username} ({abha?.age} • {abha?.gender})
588
- </span>
589
- </>
590
- ) : (
591
- <span>No Eka profile found</span>
592
- )} */}
593
- </div>
594
- </div>
595
- </label>
596
- {index !== list.length - 1 && (
597
- <div className="pds2-px-16">
598
- <div className="pds2-bg-border-03 pds2-h-1 pds2-w-full"></div>
599
- </div>
600
- )}
601
- </React.Fragment>
602
- ))}
603
- </div>
604
- );
605
- };
606
-
607
- // const TooltipContent = () => {
608
- // return (
609
- // <div className="pds2-flex pds2-flex-col pds2-p-16 pds2-bg-bg-purple-800 pds2-rounded-16 pds2-space-y-12 pds2-w-180 pds2-animate-slide-up">
610
- // <div className="pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-8">
611
- // <div className="pds2-bg-text-error pds2-text-text-white pds2-rounded-full pds2-px-4 Label1Semibold">
612
- // P
613
- // </div>
614
- // <div className="pds2-text-text-invert Body2Semibold">Preferred Address</div>
615
- // </div>
616
- // <div className="pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-8">
617
- // <div className="pds2-bg-bg-white pds2-rounded-full">
618
- // <CircleCheckSolidIcon className="pds2-w-14 pds2-h-14 pds2-text-icon-success-02" />
619
- // </div>
620
- // <div className="pds2-text-text-invert Body2Semibold">KYC</div>
621
- // </div>
622
- // </div>
623
- // );
624
- // };
625
-
626
- // const LinkThisAbhaAddressBottomSheet = ({
627
- // abha_address,
628
- // isOpen,
629
- // setIsOpen,
630
- // }: {
631
- // abha_address: string;
632
- // isOpen: boolean;
633
- // setIsOpen: (open: boolean) => void;
634
- // }) => {
635
- // // TODO: fetch these from the apis.
636
- // const dummyEkaProfiles = [
637
- // { id: '1', name: 'Eka Profile 1' },
638
- // { id: '2', name: 'Eka Profile 2' },
639
- // { id: '3', name: 'Eka Profile 3' },
640
- // ];
641
- // const [selectedProfile, setSelectedProfile] = useState<string | null>(null);
642
- // const setScreen = useAuthAbhaStore((state) => state.setScreen);
643
-
644
- // const handleCreateFamilyClick = () => {
645
- // setScreen(SCREEN_NAMES.CREATE_EKA_PROFILE);
646
- // };
647
-
648
- // return (
649
- // <BottomSheetWrapper isOpen={isOpen} setIsOpen={setIsOpen} shouldCloseOnClickOutside={true}>
650
- // <div className="pds2-flex pds2-flex-col pds2-items-center pds2-p-16">
651
- // <div className="pds2-flex pds2-justify-end pds2-items-center pds2-w-full">
652
- // <button className="pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple">
653
- // <XMarkRegularIcon
654
- // onClick={() => setIsOpen(false)}
655
- // className="pds2-w-18 pds2-h-18 pds2-text-text-03"
656
- // />
657
- // </button>
658
- // </div>
659
- // <div className="pds2-space-y-16 pds2-flex pds2-flex-col pds2-items-center pds2-text-center">
660
- // <img src="/images/link-abha.webp" alt="Link ABHA" className="pds2-w-163" />
661
- // <div className="pds2-space-y-4">
662
- // <div className="pds2-text-text-01 Heading3Semibold">Link this ABHA Address</div>
663
- // <div className="">
664
- // <span className="Body1Medium pds2-text-text-01">{abha_address}</span>
665
- // <span className="Body2Regular pds2-text-text-03">
666
- // {' '}
667
- // is not linked with any family member on Eka Care
668
- // </span>
669
- // </div>
670
- // </div>
671
- // </div>
672
- // <div className="pds2-py-32 pds2-w-full pds2-flex pds2-flex-col pds2-justify-center pds2-space-y-12">
673
- // <div className="pds2-text-text-03 Body2Medium pds2-text-center">Select Eka Profile</div>
674
- // {dummyEkaProfiles.map((profile) => {
675
- // const isSelected = selectedProfile === profile.id;
676
- // return (
677
- // <label
678
- // key={profile.id}
679
- // className={`pds2-flex pds2-items-center pds2-cursor-pointer pds2-p-16 pds2-rounded-16 pds2-bg-bg-01
680
- // ${
681
- // isSelected
682
- // ? 'pds2-border-2 pds2-border-border-brand-01 pds2-bg-bg-brand-02'
683
- // : 'pds2-border-1 pds2-border-border-03'
684
- // }
685
- // focus-within:pds2-ring-2 focus-within:pds2-ring-border-brand-01 focus-within:pds2-ring-offset-2
686
- // active:pds2-bg-bg-brand-02 hover:pds2-bg-bg-hover-01
687
- // pds2-transition-colors pds2-duration-200
688
- // `}
689
- // >
690
- // <input
691
- // type="radio"
692
- // name="ekaProfile"
693
- // value={profile.id}
694
- // checked={isSelected}
695
- // onChange={() => setSelectedProfile(profile.id)}
696
- // className="focus:pds2-outline-none pds2-appearance-none"
697
- // />
698
- // <div className="pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-8 pds2-flex-1">
699
- // <ProfileIcon className="pds2-w-32 pds2-h-32" />
700
- // <div className="TitlesSubheadline pds2-text-text-primary">{profile.name}</div>
701
- // <ChevronDownRegularIcon className="pds2-ml-auto pds2-w-14 pds2-h-14 pds2-text-text-03 -pds2-rotate-90" />
702
- // </div>
703
- // </label>
704
- // );
705
- // })}
706
- // </div>
707
- // <div className="pds2-w-full pds2-pt-16 pds2-bg-bg-white pds2-sticky pds2-bottom-0">
708
- // <Pds2CustomButton
709
- // title="Create New Family Member"
710
- // prefixIcon={<PlusRegularIcon />}
711
- // className="pds2-justify-center pds2-text-text-brand Body1Semibold pds2-bg-border-brand-02 pds2-border-none"
712
- // onClick={handleCreateFamilyClick}
713
- // />
714
- // </div>
715
- // </div>
716
- // </BottomSheetWrapper>
717
- // );
718
- // };