@eka-care/abha 0.0.6 → 0.0.8

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 +1 -1
  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,444 +0,0 @@
1
- import { ArrowLeftRegularIcon, PlusRegularIcon } from '@elixir/icons';
2
- import {
3
- ABHA_V3_SKIP_STATES,
4
- LOADING_STATE,
5
- REGISTRATION_TYPE,
6
- TProfileRecord,
7
- } from '@elixir/types';
8
- import { postAbdmProfileEkaLinkPhr } from 'apis';
9
- import { TGetProfilePhrUserResponse } from 'apis/src/types/aorta-go';
10
- import { useState, useEffect } from 'react';
11
- import usePostProfileSwitch from '../api-queries/use-post-profile-switch';
12
- import { queryClient } from '../App';
13
- import Pds2Button from '../atoms/button';
14
- import Pds2CustomButton from '../atoms/button/custom-button';
15
- import Pds2Header from '../atoms/header';
16
- import TextSeparator from '../atoms/text-separator';
17
- import ExitPopup from '../molecules/exit-popup';
18
- import AbhaErrorBottomSheet from '../organisms/abha/error-bottom-sheet';
19
- import useAuthAbhaStore from '../stores/auth-abha-store';
20
- import { SCREEN_NAMES } from '../stores/auth-abha-store/types';
21
- import { handleSendEvent } from '@elixir/utils';
22
- import { GET_EXTRA_HEADERS } from 'apis';
23
-
24
- const SelectEkaProfileScreen = () => {
25
- const setScreen = useAuthAbhaStore((state) => state.setScreen);
26
- const setEkaProfileInfo = useAuthAbhaStore((state) => state.setEkaProfileInfo);
27
- const registrationType = useAuthAbhaStore((state) => state.registrationType);
28
- const goBackLoginScreen = useAuthAbhaStore((state) => state.goBackLoginScreen);
29
- const [selectedProfileOid, setSelectedProfileOid] = useState<string | null>(null);
30
- const setBottomsheetErrorInfo = useAuthAbhaStore((state) => state.setBottomsheetErrorInfo);
31
- const clearAbhaAuthStore = useAuthAbhaStore((state) => state.clearAbhaAuthStore);
32
- const [isLoading, setIsLoading] = useState<LOADING_STATE>(LOADING_STATE.IDLE);
33
- const [isExitPopupOpen, setIsExitPopupOpen] = useState<boolean>(false);
34
- const [error, setError] = useState<string | null>(null);
35
- const dummyEkaProfiles: TProfileRecord[] = [
36
- {
37
- oid: '1',
38
- fln: 'Eka Profile 1',
39
- dob: '1990-01-01',
40
- gen: 'M',
41
- fn: 'Eka',
42
- ln: 'Profile 1',
43
- at: 'eka',
44
- },
45
- {
46
- oid: '2',
47
- fln: 'Eka Profile 2',
48
- dob: '1992-02-02',
49
- gen: 'F',
50
- fn: 'Eka',
51
- ln: 'Profile 2',
52
- at: 'eka',
53
- },
54
- {
55
- oid: '3',
56
- fln: 'Eka Profile 3',
57
- dob: '1994-03-03',
58
- gen: 'M',
59
- fn: 'Eka',
60
- ln: 'Profile 3',
61
- at: 'eka',
62
- },
63
- {
64
- oid: '4',
65
- fln: 'Eka Profile 4',
66
- dob: '1996-04-04',
67
- gen: 'F',
68
- fn: 'Eka',
69
- ln: 'Profile 4',
70
- at: 'eka',
71
- },
72
- ];
73
- const selectedAbhaAddress = useAuthAbhaStore((state) => state.selectedAbhaAddress);
74
- const aadhaarVerificationSkipStateStatus = useAuthAbhaStore(
75
- (state) => state.aadhaarVerificationSkipStateStatus
76
- );
77
-
78
- const { mutateAsync: postProfileSwitchMutate } = usePostProfileSwitch();
79
- const profilesPhrResponse = queryClient.getQueryData<TGetProfilePhrUserResponse>([
80
- 'profilesPhrUserResponse',
81
- ]);
82
-
83
- const clientId = useAuthAbhaStore((state) => state.clientId);
84
- const isEkaAppLogin = useAuthAbhaStore((state) => state.isEkaAppLogin);
85
- const isNewLoginOrCreateFlow = useAuthAbhaStore((state) => state.isNewLoginOrCreateFlow);
86
- const txnId = useAuthAbhaStore((state) => state.txnId);
87
- const extra_headers = GET_EXTRA_HEADERS();
88
- const selectedMethod = useAuthAbhaStore((state) => state.abhaAuthFlowMethod);
89
-
90
- // Analytics event tracker
91
- const trackAbhaEvent = ({ name, data = {} }: { name: string; data?: Record<string, any> }) => {
92
- const baseProps = {
93
- login_platform: clientId,
94
- is_eka_app_login: isEkaAppLogin ? 'true' : 'false',
95
- is_new_login_or_create_flow: isNewLoginOrCreateFlow ? 'true' : 'false',
96
- txn_id: txnId || 'missing txnId',
97
- oid: extra_headers?.['X-User-ID'] ? 'true' : 'false',
98
- access_token: extra_headers?.['auth'] ? 'true' : 'false',
99
- flow: selectedMethod ?? ""
100
- };
101
-
102
- const eventData = {
103
- ...baseProps,
104
- ...data,
105
- };
106
-
107
- handleSendEvent({
108
- eventName: name,
109
- eventData,
110
- });
111
-
112
- window.curio?.pushToMixpanel?.(name, eventData);
113
- };
114
-
115
- useEffect(() => {
116
- // Track page view event when component mounts or clientId changes
117
- trackAbhaEvent({
118
- name: 'choose_eka_profile_screen',
119
- data: {
120
- platform: clientId,
121
- type: 'select',
122
- },
123
- });
124
- }, [clientId]);
125
-
126
- /**
127
- * Handler for clicking on "Create Family Profile" button.
128
- * Tracks user intent and navigates to the appropriate screen based on ABHA skip state.
129
- */
130
- const handleCreateFamilyClick = () => {
131
- // Track the click on create family profile button with skip state info
132
- trackAbhaEvent({
133
- name: 'create_family_profile_clicks',
134
- data: {
135
- platform: clientId,
136
- type: 'create',
137
- skip_state: aadhaarVerificationSkipStateStatus,
138
- },
139
- });
140
-
141
- // Conditional navigation based on ABHA skip state
142
- if (aadhaarVerificationSkipStateStatus === ABHA_V3_SKIP_STATES.ABHA_END) {
143
- // User has completed ABHA verification, navigate to PHR Eka profile creation
144
- trackAbhaEvent({
145
- name: 'navigate_to_create_phr_profile_screen',
146
- data: {
147
- platform: clientId,
148
- },
149
- });
150
- setScreen(SCREEN_NAMES.CREATE_PHR_EKA_PROFILE);
151
- return;
152
- }
153
- // Otherwise, navigate to standard Eka profile creation screen
154
- trackAbhaEvent({
155
- name: 'navigate_to_create_eka_profile_screen',
156
- data: {
157
- platform: clientId,
158
- },
159
- });
160
- setScreen(SCREEN_NAMES.CREATE_EKA_PROFILE);
161
- };
162
-
163
- /**
164
- * Handler when the user selects an existing profile from the list.
165
- * Tracks the selected profile's OID.
166
- */
167
- const handleSelectProfile = async ({ profile }: { profile: TProfileRecord }) => {
168
- // Track profile selection event with profile OID and platform info
169
- trackAbhaEvent({
170
- name: 'select_profile_clicks',
171
- data: {
172
- platform: clientId,
173
- oid: profile.oid,
174
- },
175
- });
176
- setSelectedProfileOid(profile.oid);
177
- };
178
-
179
- /**
180
- * Handler for the Continue button click after selecting a profile.
181
- * Handles profile creation, linking, and switching with detailed event tracking.
182
- */
183
- const handleContinueClick = async () => {
184
- // Track continue click event with selected profile and registration context
185
- trackAbhaEvent({
186
- name: 'continue_click_on_choose_eka_profile',
187
- data: {
188
- platform: clientId,
189
- selectedProfileOid,
190
- registrationType,
191
- skip_state: aadhaarVerificationSkipStateStatus,
192
- },
193
- });
194
- // If ABHA skip state requires profile creation flow, prepare profile info and navigate
195
- if (
196
- selectedProfileOid &&
197
- aadhaarVerificationSkipStateStatus === ABHA_V3_SKIP_STATES.ABHA_CREATE
198
- ) {
199
- // Find profile details in response by OID
200
- const profileToStore = profilesPhrResponse?.profiles.find(
201
- (profile) => profile.oid === selectedProfileOid
202
- );
203
- // Track missing profile case and abort if profile not found
204
- if (!profileToStore) {
205
- trackAbhaEvent({
206
- name: 'continue_click_profile_not_found',
207
- data: {
208
- platform: clientId,
209
- oid: selectedProfileOid || 'unknown_oid',
210
- oid_exists: !!selectedProfileOid,
211
- },
212
- });
213
- return;
214
- }
215
- // Track navigation intent to create Eka profile screen from ABHA create flow
216
- trackAbhaEvent({
217
- name: 'navigate_to_create_eka_profile_screen_from_abha_create',
218
- data: {
219
- platform: clientId,
220
- oid: profileToStore.oid,
221
- },
222
- });
223
- // Set Eka profile info state for further steps
224
- setEkaProfileInfo({
225
- oid: profileToStore.oid,
226
- date_of_birth: profileToStore.dob as string,
227
- firstname: profileToStore.fn,
228
- lastname: profileToStore.ln as string,
229
- pincode: '',
230
- gender: profileToStore.gen as string,
231
- mobile: profileToStore.mobile as string,
232
- name: profileToStore.fln as string,
233
- middlename: profileToStore.mn as string,
234
- abha_address: profileToStore?.['health-ids']?.[0],
235
- abha_number: profileToStore.abha_number,
236
- });
237
- // Navigate to profile creation screen
238
- setScreen(SCREEN_NAMES.CREATE_EKA_PROFILE);
239
- return;
240
- }
241
- // If essential inputs missing, track and abort early
242
- if (!selectedAbhaAddress || !selectedProfileOid) {
243
- trackAbhaEvent({
244
- name: 'continue_click_missing_profile_or_abha',
245
- data: {
246
- platform: clientId,
247
- oid: selectedProfileOid || 'missing_oid',
248
- oid_exists: !!selectedProfileOid,
249
- },
250
- });
251
- return;
252
- }
253
- // Track the start of linking ABHA address to selected profile
254
- trackAbhaEvent({
255
- name: 'linking_abha_to_profile_start',
256
- data: {
257
- platform: clientId,
258
- oid: selectedProfileOid || 'missing_oid',
259
- oid_exists: !!selectedProfileOid,
260
- },
261
- });
262
-
263
- setIsLoading(LOADING_STATE.LOADING);
264
-
265
- // Attempt linking the ABHA profile
266
- const {
267
- error: linkPhrError,
268
- action: errorAction,
269
- eka,
270
- } = await postAbdmProfileEkaLinkPhr({
271
- abha_address: selectedAbhaAddress,
272
- oid: selectedProfileOid,
273
- });
274
-
275
- // Handle any error action returned by the API and track it
276
- if (errorAction) {
277
- trackAbhaEvent({
278
- name: 'linking_abha_to_profile_error_action',
279
- data: {
280
- platform: clientId,
281
- oid: selectedProfileOid || 'missing_oid',
282
- oid_exists: !!selectedProfileOid,
283
- },
284
- });
285
- setBottomsheetErrorInfo(errorAction);
286
- return;
287
- }
288
-
289
- // Handle linking errors or missing eka data, track failure event
290
- if (linkPhrError || !eka || !eka.oid) {
291
- trackAbhaEvent({
292
- name: 'linking_abha_to_profile_failed',
293
- data: {
294
- platform: clientId,
295
- oid: selectedProfileOid || 'missing_oid',
296
- oid_exists: !!selectedProfileOid,
297
- error: linkPhrError || 'No EKA/OID',
298
- error_exists: !!linkPhrError,
299
- },
300
- });
301
-
302
- setIsLoading(LOADING_STATE.REJECTED);
303
- setError(linkPhrError || 'Something went wrong. Please try again.');
304
- return;
305
- }
306
-
307
- // Attempt to switch profile after successful linking
308
- const profileSwitchResponse = await postProfileSwitchMutate({
309
- oid: eka.oid,
310
- });
311
-
312
- // Track failure if profile switch errors out
313
- if (profileSwitchResponse.error) {
314
- trackAbhaEvent({
315
- name: 'profile_switch_failed_after_link',
316
- data: {
317
- platform: clientId,
318
- oid: eka?.oid || 'missing_oid',
319
- oid_exists: !!eka?.oid,
320
- error: profileSwitchResponse.error?.message || 'unknown_error',
321
- error_exists: !!profileSwitchResponse.error?.message,
322
- },
323
- });
324
- setIsLoading(LOADING_STATE.REJECTED);
325
- setError(profileSwitchResponse.error?.message || 'Something went wrong, please try again');
326
- return;
327
- }
328
-
329
- // Track success of linking and profile switch
330
- trackAbhaEvent({
331
- name: 'linking_abha_to_profile_success',
332
- data: {
333
- platform: clientId,
334
- oid: eka.oid,
335
- },
336
- });
337
-
338
- // Mark loading as resolved to allow next steps
339
- setIsLoading(LOADING_STATE.RESOLVED);
340
- return;
341
- };
342
-
343
- const handleErrorBottomsheetButtonClick = () => {
344
- goBackLoginScreen();
345
- const isAppLogin = useAuthAbhaStore.getState().isEkaAppLogin;
346
- clearAbhaAuthStore();
347
- useAuthAbhaStore.setState({ isEkaAppLogin: isAppLogin });
348
- };
349
-
350
- return (
351
- <div className="pds2-w-full pds2-h-screen pds2-flex pds2-flex-col pds2-bg-bg-01">
352
- <Pds2Header
353
- title="Select Eka Profile"
354
- prefixIcon={
355
- <button
356
- className="pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple"
357
- onClick={() => setIsExitPopupOpen(true)}
358
- >
359
- <ArrowLeftRegularIcon />
360
- </button>
361
- }
362
- className="pds2-border-b pds2-border-bg-seperator-dark pds2-bg-bg-white"
363
- />
364
-
365
- {/* Main content */}
366
- <div className="pds2-flex-1 pds2-flex pds2-flex-col pds2-relative">
367
- {/* Scrollable section constrained to avoid covering sticky button */}
368
- <div className="pds2-flex-1 pds2-overflow-y-auto pds2-px-16 pds2-pt-24 pds2-pb-32">
369
- <div className="pds2-space-y-16 pds2-flex pds2-flex-col pds2-items-center pds2-text-center">
370
- <img
371
- src="https://cdn.eka.care/vagus/cm6agrs5000090tfwfz984x5b.webp"
372
- alt="Link ABHA"
373
- className="pds2-w-163"
374
- />
375
- <div className="pds2-space-y-4">
376
- <div className="pds2-text-text-01 Heading3Semibold">Choose an Eka Profile</div>
377
- <span className="Body1Regular pds2-text-text-03">
378
- Select the person for whom you want to create an ABHA address.
379
- </span>
380
- </div>
381
- </div>
382
- <div className="pds2-w-full pds2-flex pds2-flex-col pds2-justify-center pds2-space-y-12 pds2-mt-24">
383
- <div className="pds2-text-text-03 Body2Medium pds2-text-center">Select Eka Profile</div>
384
-
385
- <div className="pds2-space-y-8">
386
- {profilesPhrResponse?.profiles?.map((profile) => {
387
- const isSelected = selectedProfileOid === profile.oid;
388
- return (
389
- <label
390
- key={profile.oid}
391
- className="pds2-flex pds2-items-center pds2-gap-x-8 pds2-cursor-pointer pds2-p-16 pds2-rounded-16 pds2-bg-bg-white pds2-border
392
- pds2-border-border-03 hover:pds2-bg-bg-hover-01
393
- pds2-transition-colors"
394
- >
395
- <input
396
- type="radio"
397
- name="ekaProfile"
398
- value={profile.oid}
399
- checked={isSelected}
400
- onChange={() => handleSelectProfile({ profile })}
401
- className="pds2-self-start pds2-mt-4 pds2-w-14 pds2-h-14"
402
- />
403
- <div className="pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-8 pds2-flex-1">
404
- <div className="TitlesSubheadline pds2-text-text-primary">{profile.fln}</div>
405
- <span className="pds2-ml-auto pds2-text-text-brand pds2-text-14 pds2-font-600">
406
- Link
407
- </span>
408
- </div>
409
- </label>
410
- );
411
- })}
412
- </div>
413
-
414
- {/* Create new family member option - Now properly at the end of all profiles */}
415
- <TextSeparator title="or" />
416
- <Pds2CustomButton
417
- title="Create new Family Member"
418
- prefixIcon={<PlusRegularIcon />}
419
- className="pds2-justify-center pds2-text-text-brand pds2-border-bg-fab-bg-brand-04 Body1Semibold"
420
- onClick={handleCreateFamilyClick}
421
- />
422
- </div>
423
- </div>
424
-
425
- {/* Sticky bottom button */}
426
- <div className="pds2-sticky pds2-bottom-0 pds2-left-0 pds2-right-0 pds2-bg-bg-white pds2-shadow-lg pds2-p-16">
427
- {error && <div className="pds2-text-text-error pds2-text-center pds2-mb-8">{error}</div>}
428
- <Pds2Button
429
- title="Continue"
430
- state={selectedProfileOid === null || isLoading === LOADING_STATE.LOADING ? 'disabled' : 'enabled'}
431
- isLoading={isLoading === LOADING_STATE.LOADING}
432
- className="pds2-w-full"
433
- onClick={handleContinueClick}
434
- />
435
- </div>
436
- </div>
437
-
438
- <AbhaErrorBottomSheet onSubmitClick={handleErrorBottomsheetButtonClick} />
439
- <ExitPopup open={isExitPopupOpen} setOpen={setIsExitPopupOpen} />
440
- </div>
441
- );
442
- };
443
-
444
- export default SelectEkaProfileScreen;
@@ -1,41 +0,0 @@
1
- import { handleSendEvent } from '@elixir/utils';
2
- import { GET_EXTRA_HEADERS } from 'apis/src/constants/env';
3
- import useAuthAbhaStore from '../../stores/auth-abha-store';
4
-
5
- type TrackAbhaEventParams = {
6
- name: string;
7
- data?: Record<string, any>;
8
- };
9
-
10
- export const useTrackAbhaEvent = () => {
11
- const isNewLoginOrCreateFlow = useAuthAbhaStore((state) => state.isNewLoginOrCreateFlow);
12
- const isEkaAppLogin = useAuthAbhaStore((state) => state.isEkaAppLogin);
13
- const clientId = useAuthAbhaStore((state) => state.clientId);
14
-
15
- return ({ name, data = {} }: TrackAbhaEventParams) => {
16
- const extraHeaders: Record<string, string> | null = GET_EXTRA_HEADERS();
17
-
18
- const authToken = extraHeaders?.['auth'] || '';
19
- const xId = extraHeaders?.['X-User-ID'] || '';
20
-
21
- const baseProps = {
22
- auth: authToken || 'missing authToken',
23
- x_id: xId || 'missing xId',
24
- login_platform: clientId,
25
- is_eka_app_login: isEkaAppLogin ? 'true' : 'false',
26
- is_new_login_or_create_flow: isNewLoginOrCreateFlow ? 'true' : 'false',
27
- };
28
-
29
- const eventData = {
30
- ...baseProps,
31
- ...data,
32
- };
33
-
34
- // Analytics calls
35
- window.curio?.pushToMixpanel?.(name, eventData);
36
- handleSendEvent?.({
37
- eventName: name,
38
- eventData,
39
- });
40
- };
41
- };
@@ -1,138 +0,0 @@
1
- import { ABHA_AUTH_FLOW_METHOD } from '@elixir/types';
2
- import { create } from 'zustand';
3
- import { SCREEN_NAMES, TAbhaAuthStore, TAbhaAuthStoreInitValues } from './types';
4
-
5
- const storeInitState: TAbhaAuthStoreInitValues = {
6
- screen: [SCREEN_NAMES.LOGIN_WITH_ABHA],
7
- authTxnId: null,
8
- txnId: null,
9
- aadhaarOtpSentToHint: null,
10
- mobileOtpSentToHint: null,
11
- aadhaarVerificationSkipStateStatus: null,
12
- ekaSmallToken: null,
13
- bottomsheetErrorInfo: null,
14
- abhaAddressList: null,
15
- loginIdentifierValue: null,
16
- abhaAuthFlowMethod: null,
17
- selectedAbhaAddress: null,
18
- ekaProfileInfo: null,
19
- registrationType: null,
20
- initAbhaAppMethod: 'login_or_create_abha',
21
- initAbhaAppMobileNumber: null,
22
- isEkaAppLogin: false,
23
- isDocAppRequest: false,
24
- // this is when user has try login then we no abha error, then show bottomsheet and redirect to create with aadhaar screen,
25
- isLoggedInFromRedirect: false,
26
- clientId: '',
27
- oid: '',
28
- isApiTriggered: false,
29
- isNewLoginOrCreateFlow: false,
30
- selectedAbhaFlow: '',
31
- isInitApiTriggered: false,
32
- identityValue : '',
33
- };
34
-
35
- const useAuthAbhaStore = create<TAbhaAuthStore>((set, get) => ({
36
- screen: [SCREEN_NAMES.LOGIN_WITH_ABHA],
37
- setScreen: (screen) => set((state) => ({ screen: [...state.screen, screen] })),
38
- goBackScreen: () => {
39
- const { screen } = get();
40
- if (screen.length === 0) return null;
41
- set({ screen: screen.slice(0, -1) });
42
- return;
43
- },
44
-
45
- goBackLoginScreen: () => {
46
- const { isNewLoginOrCreateFlow } = get();
47
- const targetScreen = isNewLoginOrCreateFlow
48
- ? SCREEN_NAMES.LOGIN_OR_CREATE_ABHA
49
- : SCREEN_NAMES.LOGIN_WITH_ABHA;
50
-
51
- set({ screen: [targetScreen] });
52
- },
53
-
54
- setUrlParams: (urlParams) => set({ urlParams }),
55
-
56
- authTxnId: null,
57
-
58
- txnId: null,
59
- setTxnId: (txnId) => set({ txnId }),
60
-
61
- aadhaarOtpSentToHint: null,
62
-
63
- setAadhaarInitResponse: (params) => set(params),
64
-
65
- mobileOtpSentToHint: null,
66
-
67
- setMobileInitResponse: (params) => set(params),
68
-
69
- registrationType: null,
70
- setRegistrationType: (val) => set({ registrationType: val }),
71
-
72
- aadhaarVerificationSkipStateStatus: null,
73
- setAadhaarVerificationSkipStateStatus: (status) =>
74
- set({ aadhaarVerificationSkipStateStatus: status }),
75
-
76
- bottomsheetErrorInfo: null,
77
- setBottomsheetErrorInfo: (info) => set({ bottomsheetErrorInfo: info }),
78
-
79
- ekaSmallToken: null,
80
- setEkaSmallToken: (token) => set({ ekaSmallToken: token }),
81
-
82
- abhaAddressList: null,
83
- setAbhaAddressList: (info) => set({ abhaAddressList: info }),
84
-
85
- loginIdentifierValue: null,
86
- setLoginIdentifierValue: (val) => set({ loginIdentifierValue: val }),
87
-
88
- abhaAuthFlowMethod: ABHA_AUTH_FLOW_METHOD.ABHA_NUMBER,
89
- setAbhaAuthFlowMethod: (val) => set({ abhaAuthFlowMethod: val }),
90
-
91
- selectedAbhaAddress: null,
92
- setSelectedAbhaAddress: (val) => set({ selectedAbhaAddress: val }),
93
-
94
- ekaProfileInfo: null,
95
- setEkaProfileInfo: (info) => set({ ekaProfileInfo: info }),
96
-
97
- initAbhaAppMethod: 'login_or_create_abha',
98
- setInitAbhaAppMethod: (method) => set({ initAbhaAppMethod: method }),
99
-
100
- initAbhaAppMobileNumber: null,
101
- setInitAbhaAppMobileNumber: (val) => set({ initAbhaAppMobileNumber: val }),
102
-
103
- isEkaAppLogin: false,
104
- setIsEkaAppLogin: (val) => set({ isEkaAppLogin: val }),
105
-
106
- isDocAppRequest: false,
107
- setIsDocAppRequest: (val) => set({ isDocAppRequest: val }),
108
-
109
- setInitState: (initState) => set(initState),
110
-
111
- isLoggedInFromRedirect: false,
112
- setIsLoggedInFromRedirect: (val) => set({ isLoggedInFromRedirect: val }),
113
-
114
- clientId: '',
115
- setClientId: (val) => set({ clientId: val }),
116
-
117
- isApiTriggered: false,
118
- setIsApiTriggered: (val) => set({ isApiTriggered: val }),
119
-
120
- oid: '',
121
- setOid: (val) => set({ oid: val }),
122
-
123
- isNewLoginOrCreateFlow: false,
124
- setIsNewLoginOrCreateFlow: (val) => set({ isNewLoginOrCreateFlow: val }),
125
-
126
- selectedAbhaFlow: '',
127
- setSelectedAbhaFlow: (val) => set({ selectedAbhaFlow: val }),
128
-
129
- isInitApiTriggered: false,
130
- setIsInitApiTriggered: (val) => set({ isInitApiTriggered: val }),
131
-
132
- identityValue : '',
133
- setIdentityValue: (val) => set({ identityValue: val }),
134
-
135
- clearAbhaAuthStore: () => set(storeInitState),
136
- }));
137
-
138
- export default useAuthAbhaStore;