@eka-care/abha-stg 0.1.0 → 0.1.2

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 (119) 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/.eslintignore +0 -3
  6. package/.eslintrc +0 -29
  7. package/.prettierrc +0 -7
  8. package/.turbo/daemon/da13e0828a6aedf8-turbo.log.2025-10-30 +0 -0
  9. package/package/styles/pds2/border.ts +0 -69
  10. package/package/styles/pds2/colors.ts +0 -70
  11. package/package/styles/pds2/spacing.ts +0 -1007
  12. package/package/tailwind/tailwind.config.ts +0 -124
  13. package/postcss.config.js +0 -6
  14. package/scripts/build-purged-css.cjs +0 -70
  15. package/src/App.css +0 -0
  16. package/src/App.tsx +0 -43
  17. package/src/api-queries/aorta-go/v3/get-profile-patient.ts +0 -32
  18. package/src/api-queries/aorta-go/v3/get-profiles-phr-user.ts +0 -26
  19. package/src/api-queries/aorta-go/v3/post-auth-init-v2.ts +0 -34
  20. package/src/api-queries/aorta-go/v3/post-auth-logout-v2.ts +0 -32
  21. package/src/api-queries/aorta-go/v3/post-auth-verify-v2.ts +0 -38
  22. package/src/api-queries/aorta-go/v3/post-profile-switch.ts +0 -39
  23. package/src/api-queries/ndhm/get-abdm-register-suggest.ts +0 -37
  24. package/src/api-queries/ndhm/get-pincode-details.ts +0 -28
  25. package/src/api-queries/ndhm/post-abdm-login-init.ts +0 -37
  26. package/src/api-queries/ndhm/post-abdm-login-phr.ts +0 -37
  27. package/src/api-queries/ndhm/post-abdm-login-verify.ts +0 -37
  28. package/src/api-queries/ndhm/post-abdm-profile-eka-link-phr.ts +0 -40
  29. package/src/api-queries/ndhm/post-abdm-profile-eka.ts +0 -66
  30. package/src/api-queries/ndhm/post-abdm-register-abha-number-create-phr.ts +0 -37
  31. package/src/api-queries/ndhm/post-abdm-register-mobile-create-phr.ts +0 -66
  32. package/src/api-queries/ndhm/post-abdm-register-mobile-resend-otp.ts +0 -32
  33. package/src/api-queries/ndhm/post-abdm-register-mobile-verify.ts +0 -38
  34. package/src/api-queries/ndhm/post-abdm-register-phr-check.ts +0 -34
  35. package/src/api-queries/ndhm/post-register-aadhaar-create-phr.ts +0 -37
  36. package/src/api-queries/ndhm/post-register-aadhaar-init.ts +0 -34
  37. package/src/api-queries/ndhm/post-register-aadhaar-mobile-resend-otp.ts +0 -34
  38. package/src/api-queries/ndhm/post-register-aadhaar-mobile-verify.ts +0 -37
  39. package/src/api-queries/ndhm/post-register-aadhaar-resend-otp.ts +0 -34
  40. package/src/api-queries/ndhm/post-register-aadhaar-verify.ts +0 -40
  41. package/src/api-queries/ndhm/post-register-mobile-init.ts +0 -34
  42. package/src/api-queries/use-get-profiles-patient.ts +0 -12
  43. package/src/api-queries/use-get-profiles-phr-user.ts +0 -28
  44. package/src/api-queries/use-post-abdm-login-verify-v1.ts +0 -26
  45. package/src/api-queries/use-post-auth-verify-v2.ts +0 -50
  46. package/src/api-queries/use-post-profile-switch.ts +0 -58
  47. package/src/api-queries/use-post-register-mobile-create-phr.ts +0 -39
  48. package/src/api-queries/user-post-abdm-profile-login-phr.ts +0 -26
  49. package/src/assets/Success.json +0 -1
  50. package/src/assets/react.svg +0 -1
  51. package/src/atoms/button/custom-button.tsx +0 -32
  52. package/src/atoms/button/index.tsx +0 -40
  53. package/src/atoms/button/types.d.ts +0 -31
  54. package/src/atoms/header.tsx +0 -25
  55. package/src/atoms/input-field/index.tsx +0 -63
  56. package/src/atoms/input-field/patient-input-field.tsx +0 -16
  57. package/src/atoms/input-field/types.ts +0 -24
  58. package/src/atoms/pds2-otp-input/index.tsx +0 -35
  59. package/src/atoms/pds2-otp-input/types.d.ts +0 -3
  60. package/src/atoms/single-input-chip/index.tsx +0 -32
  61. package/src/atoms/single-input-chip/types.ts +0 -6
  62. package/src/atoms/spinner.tsx +0 -33
  63. package/src/atoms/text-separator.tsx +0 -11
  64. package/src/atoms/ui/spinner.tsx +0 -75
  65. package/src/constants/constants.ts +0 -376
  66. package/src/fetch-client/index.ts +0 -164
  67. package/src/index.css +0 -152
  68. package/src/main.tsx +0 -374
  69. package/src/molecules/abha/bottom-sheet/bottom-sheet-wrapper.tsx +0 -40
  70. package/src/molecules/abha/bottom-sheet/index.tsx +0 -66
  71. package/src/molecules/abha/spaced-input-component.tsx +0 -168
  72. package/src/molecules/copyright-year.tsx +0 -16
  73. package/src/molecules/exit-popup/index.tsx +0 -101
  74. package/src/molecules/pds2-otp-component/index.tsx +0 -147
  75. package/src/organisms/abha/abha-header.tsx +0 -25
  76. package/src/organisms/abha/abha-stepper.tsx +0 -83
  77. package/src/organisms/abha/error-bottom-sheet.tsx +0 -27
  78. package/src/organisms/abha/otp-card.tsx +0 -99
  79. package/src/organisms/abha/verification-status.tsx +0 -30
  80. package/src/organisms/choose-language/choose-language.tsx +0 -53
  81. package/src/organisms/choose-language/types.ts +0 -10
  82. package/src/organisms/screen-switcher/screen-switcher.tsx +0 -80
  83. package/src/routes/abha-aadhaar-verification-status-screen.tsx +0 -246
  84. package/src/routes/abha-created-screen.tsx +0 -45
  85. package/src/routes/abha-login-otp-verify-screen.tsx +0 -519
  86. package/src/routes/abha-mobile-linking-status-screen.tsx +0 -267
  87. package/src/routes/abha-otp-and-mobile-screen.tsx +0 -435
  88. package/src/routes/abha-phone-number-verification-screen.tsx +0 -388
  89. package/src/routes/create-abha-address-screen.tsx +0 -928
  90. package/src/routes/create-abha-with-aadhaar-screen.tsx +0 -986
  91. package/src/routes/create-eka-profile-screen.tsx +0 -831
  92. package/src/routes/get-all-profiles-screen.tsx +0 -161
  93. package/src/routes/login-or-create-abha-address-screen.tsx +0 -1056
  94. package/src/routes/login-with-abha-screen.tsx +0 -454
  95. package/src/routes/select-abha-from-list-screen.tsx +0 -792
  96. package/src/routes/select-eka-profile-screen.tsx +0 -446
  97. package/src/routes/utils/trackAbhaEvent.ts +0 -41
  98. package/src/stores/auth-abha-store/index.ts +0 -152
  99. package/src/stores/auth-abha-store/types.ts +0 -217
  100. package/src/utils/mock-auth-response.ts +0 -29
  101. package/src/utils/send-event-utils.ts +0 -76
  102. package/src/utils/validations.ts +0 -89
  103. package/src/vite-env.d.ts +0 -1
  104. package/tailwind.config.ts +0 -9
  105. package/tsconfig.json +0 -25
  106. package/tsconfig.node.json +0 -10
  107. package/tsconfig.node.tsbuildinfo +0 -1
  108. package/tsconfig.tsbuildinfo +0 -1
  109. package/vite.config.d.ts +0 -2
  110. package/vite.config.js +0 -45
  111. package/vite.config.ts +0 -50
  112. /package/{public → dist}/images/adhaar.webp +0 -0
  113. /package/{public → dist}/images/at-the-rate.webp +0 -0
  114. /package/{public → dist}/images/avatar.webp +0 -0
  115. /package/{public → dist}/images/ayushman-bharat.webp +0 -0
  116. /package/{public → dist}/images/circle-checkmark.webp +0 -0
  117. /package/{public → dist}/images/link-abha.webp +0 -0
  118. /package/{public → dist}/images/national-authority.webp +0 -0
  119. /package/{public → dist}/images/three-dots.webp +0 -0
@@ -1,388 +0,0 @@
1
- import { GET_EXTRA_HEADERS, LOADING_STATE } from '../constants/constants';
2
- import { useState } from 'react';
3
- import Pds2Button from '../atoms/button';
4
- import AbhaHeader from '../organisms/abha/abha-header';
5
- import AbhaErrorBottomSheet from '../organisms/abha/error-bottom-sheet';
6
- import AbhaOtpCard from '../organisms/abha/otp-card';
7
- import useAuthAbhaStore from '../stores/auth-abha-store';
8
- import { SCREEN_NAMES } from '../stores/auth-abha-store/types';
9
-
10
- import { useEffect } from 'react';
11
- import { ArrowLeftRegularIcon, CircleInfoSolidIcon } from '@eka-care/icons';
12
- import AbhaStepper from '../organisms/abha/abha-stepper';
13
- import ExitPopup from '../molecules/exit-popup';
14
- import handleSendEvent from '../utils/send-event-utils';
15
- import postAbdmRegisterMobileResendOtp from '../api-queries/ndhm/post-abdm-register-mobile-resend-otp';
16
- import postRegisterAadhaarMobileResendOtp from '../api-queries/ndhm/post-register-aadhaar-mobile-resend-otp';
17
- import postAbdmRegisterMobileVerify from '../api-queries/ndhm/post-abdm-register-mobile-verify';
18
- import postRegisterAadhaarMobileVerify from '../api-queries/ndhm/post-register-aadhaar-mobile-verify';
19
-
20
- const AbhaPhoneNumberVerificationScreen = () => {
21
- const txnId = useAuthAbhaStore((state) => state.txnId);
22
- const clearAbhaAuthStore = useAuthAbhaStore((state) => state.clearAbhaAuthStore);
23
- const setBottomsheetErrorInfo = useAuthAbhaStore((state) => state.setBottomsheetErrorInfo);
24
- const setEkaSmallToken = useAuthAbhaStore((state) => state.setEkaSmallToken);
25
- const setOid = useAuthAbhaStore((state) => state.setOid);
26
- const setAadhaarVerificationSkipStateStatus = useAuthAbhaStore(
27
- (state) => state.setAadhaarVerificationSkipStateStatus
28
- );
29
- const setSelectedAbhaAddress = useAuthAbhaStore((state) => state.setSelectedAbhaAddress);
30
-
31
- const setAbhaAddressList = useAuthAbhaStore((state) => state.setAbhaAddressList);
32
- const setScreen = useAuthAbhaStore((state) => state.setScreen);
33
- const selectedMethod = useAuthAbhaStore((state) => state.abhaAuthFlowMethod);
34
-
35
- const [otp, setOtp] = useState('');
36
- const [isOtpValid, setIsOtpValid] = useState(false);
37
- const [error, setError] = useState<string | null>('');
38
-
39
- const [aadhaarMobileVerifyApiStatus, setAadhaarMobileVerifyApiStatus] = useState<LOADING_STATE>(
40
- LOADING_STATE.IDLE
41
- );
42
- const setTxnId = useAuthAbhaStore((state) => state.setTxnId);
43
-
44
- const setEkaProfileInfo = useAuthAbhaStore((state) => state.setEkaProfileInfo);
45
- const clientId = useAuthAbhaStore((state) => state.clientId);
46
- const selectedAbhaFlow = useAuthAbhaStore((state) => state.selectedAbhaFlow);
47
- const isNewLoginOrCreateFlow = useAuthAbhaStore((state) => state.isNewLoginOrCreateFlow);
48
- const isEkaAppLogin = useAuthAbhaStore((state) => state.isEkaAppLogin);
49
- const extra_headers = GET_EXTRA_HEADERS();
50
- const [isExitPopupOpen, setIsExitPopupOpen] = useState<boolean>(false);
51
-
52
- console.log('selectedAbhaFlow is : ', selectedAbhaFlow);
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
- flow: selectedMethod ?? ""
64
- };
65
-
66
- const eventData = {
67
- ...baseProps,
68
- ...data,
69
- };
70
-
71
- handleSendEvent({
72
- eventName: name,
73
- eventData,
74
- });
75
-
76
- window.curio?.pushToMixpanel?.(name, eventData);
77
- };
78
-
79
- useEffect(() => {
80
- trackAbhaEvent({
81
- name: 'page_view',
82
- data: {
83
- page_view: 'abha_mobile_otp_verify',
84
- platform: clientId,
85
- },
86
- });
87
- }, []);
88
-
89
- const handleOtpCompletion = ({ otp: newOtp }: { otp: string }) => {
90
- setOtp(newOtp);
91
- trackAbhaEvent({
92
- name: 'abha_mobile_otp_completion',
93
- data: {
94
- platform: clientId,
95
- type: 'verify',
96
- otp_entered: true,
97
- },
98
- });
99
- handleVerifyClick(newOtp);
100
- };
101
-
102
- const handleResendOtpClick = async () => {
103
- if (!txnId) {
104
- trackAbhaEvent({
105
- name: 'abha_mobile_otp_resend_clicked_no_txnId',
106
- data: {
107
- type: 'resend',
108
- platform: clientId,
109
- txn_id: 'missing_txnId',
110
- txn_id_exists: false,
111
- },
112
- });
113
- return;
114
- }
115
-
116
- trackAbhaEvent({
117
- name: 'abha_mobile_otp_verify_clicks',
118
- data: {
119
- type: 'resend',
120
- platform: clientId,
121
- },
122
- });
123
-
124
- console.log('selectedMethod', selectedMethod);
125
- let response;
126
- if (selectedAbhaFlow === 'mobile') {
127
- trackAbhaEvent({
128
- name: 'abha_mobile_otp_resend_initiated',
129
- data: {
130
- platform: clientId,
131
- type: 'verify',
132
- flow_type: selectedAbhaFlow,
133
- },
134
- });
135
- console.log('selectedFlow is mobile, so triggering mobile resend otp api', selectedAbhaFlow);
136
- response = await postAbdmRegisterMobileResendOtp({
137
- txn_id: txnId,
138
- });
139
- } else {
140
- trackAbhaEvent({
141
- name: 'aadhaar_mobile_otp_resend_initiated',
142
- data: {
143
- platform: clientId,
144
- type: 'verify',
145
- flow_type: selectedAbhaFlow,
146
- },
147
- });
148
- console.log(
149
- 'selectedFlow is aadhaar, so triggering aadhaar resend otp api',
150
- selectedAbhaFlow
151
- );
152
- response = await postRegisterAadhaarMobileResendOtp({
153
- txn_id: txnId,
154
- });
155
- }
156
-
157
- const { txn_id, error: resendOtpError, action: errorAction } = response;
158
-
159
- if (!txn_id) {
160
- trackAbhaEvent({
161
- name: 'abha_mobile_otp_resend_failed',
162
- data: {
163
- platform: clientId,
164
- reason: resendOtpError || 'no_txn_id',
165
- reason_exists: !!resendOtpError,
166
- },
167
- });
168
- setError(resendOtpError || 'Something went wrong, please try again');
169
- if (errorAction) {
170
- setBottomsheetErrorInfo(errorAction);
171
- }
172
- return;
173
- }
174
-
175
- if (txn_id) {
176
- setTxnId(txn_id);
177
- }
178
-
179
- trackAbhaEvent({
180
- name: 'abha_mobile_otp_resend_success',
181
- data: {
182
- platform: clientId,
183
- txn_id: txn_id,
184
- },
185
- });
186
- };
187
-
188
- const handleVerifyClick = async (otpToSubmit: string) => {
189
- if (!txnId) {
190
- trackAbhaEvent({
191
- name: 'abha_mobile_verify_no_txnId',
192
- data: {
193
- type: 'verify',
194
- platform: clientId,
195
- txn_id: 'missing_txnId',
196
- txn_id_exists: false,
197
- },
198
- });
199
- return;
200
- }
201
-
202
- trackAbhaEvent({
203
- name: 'abha_mobile_otp_submitted',
204
- data: {
205
- type: 'verify',
206
- platform: clientId,
207
- txn_id: txnId,
208
- },
209
- });
210
-
211
- setAadhaarMobileVerifyApiStatus(LOADING_STATE.LOADING);
212
-
213
- try {
214
- let response;
215
- if (selectedAbhaFlow === 'mobile') {
216
- trackAbhaEvent({
217
- name: 'abha_mobile_otp_verification_started',
218
- data: {
219
- platform: clientId,
220
- flow_type: selectedAbhaFlow,
221
- },
222
- });
223
- response = await postAbdmRegisterMobileVerify({
224
- otp: otpToSubmit,
225
- txn_id: txnId,
226
- });
227
- } else {
228
- trackAbhaEvent({
229
- name: 'aadhaar_otp_verification_started',
230
- data: {
231
- platform: clientId,
232
- flow_type: selectedAbhaFlow,
233
- },
234
- });
235
-
236
- response = await postRegisterAadhaarMobileVerify({
237
- otp: otpToSubmit,
238
- txn_id: txnId,
239
- });
240
- }
241
-
242
- const {
243
- txn_id,
244
- skip_state,
245
- eka,
246
- profile,
247
- error: verifyError,
248
- action: errorAction,
249
- abha_profiles,
250
- } = response;
251
-
252
- if (!txn_id || !skip_state) {
253
- trackAbhaEvent({
254
- name: 'abha_mobile_otp_verification_failed',
255
- data: {
256
- platform: clientId,
257
- reason: verifyError || 'missing_txn_id_or_skip_state',
258
- txn_id_exists: !!txn_id,
259
- skip_state_exists: !!skip_state,
260
- },
261
- });
262
- setAadhaarMobileVerifyApiStatus(LOADING_STATE.REJECTED);
263
- setError(verifyError || 'Something went wrong, please try again');
264
- if (errorAction) {
265
- setBottomsheetErrorInfo(errorAction);
266
- }
267
- return;
268
- }
269
- setAadhaarMobileVerifyApiStatus(LOADING_STATE.RESOLVED);
270
- setAadhaarVerificationSkipStateStatus(skip_state);
271
- if (eka?.min_token) {
272
- setEkaSmallToken(eka.min_token);
273
- }
274
- if (eka?.oid) {
275
- setOid(eka.oid);
276
- }
277
-
278
- if (profile && profile.abha_address) {
279
- setSelectedAbhaAddress(profile.abha_address);
280
- }
281
-
282
- if (profile) {
283
- setEkaProfileInfo({
284
- // date_of_birth: `${profile.day_of_birth}-${profile.month_of_birth}-${profile.year_of_birth}` as string,
285
- date_of_birth: `${profile.year_of_birth}-${String(profile.month_of_birth).padStart(2, '0')}-${String(profile.day_of_birth).padStart(2, '0')}`,
286
- firstname: profile.first_name as string,
287
- lastname: profile.last_name as string,
288
- pincode: profile.pincode,
289
- gender: profile.gender as string,
290
- oid: eka?.oid,
291
- abha_address: profile?.abha_address,
292
- abha_number: profile?.abha_number,
293
- middlename: profile?.middle_name,
294
- });
295
- }
296
-
297
- // abha -> create abha with mobile
298
- // HMIS -> when we are creating a new patient profile, we wont have oid in the headers.
299
- // so server will send oid in the eka object.
300
- // set the oid in the headers and redirect to abha mobile linking status screen
301
-
302
- console.log('remove oid from set indvidual env')
303
-
304
- trackAbhaEvent({
305
- name: 'abha_mobile_otp_verification_success',
306
- data: {
307
- platform: clientId,
308
- skip_state,
309
- },
310
- });
311
- if (abha_profiles?.length) {
312
- setAbhaAddressList(abha_profiles);
313
- setScreen(SCREEN_NAMES.SELECT_ABHA_FROM_LIST);
314
- return;
315
- }
316
- setScreen(SCREEN_NAMES.ABHA_MOBILE_LINKING_STATUS);
317
- } catch (error) {
318
- trackAbhaEvent({
319
- name: 'abha_mobile_otp_verification_exception',
320
- data: {
321
- platform: clientId,
322
- reason: 'exception_thrown',
323
- },
324
- });
325
-
326
- setAadhaarMobileVerifyApiStatus(LOADING_STATE.REJECTED);
327
- setError('Something went wrong, please try again');
328
- }
329
- };
330
-
331
- const handleErrorBottomsheetButtonClick = () => {
332
- setScreen(SCREEN_NAMES.CREATE_ABHA_WITH_AADHAAR);
333
- const isAppLogin = useAuthAbhaStore.getState().isEkaAppLogin;
334
- clearAbhaAuthStore();
335
- useAuthAbhaStore.setState({ isEkaAppLogin: isAppLogin });
336
- };
337
-
338
- return (
339
- <div className="pds2-flex pds2-flex-col pds2-w-full pds2-h-full pds2-bg-bg-white">
340
- <AbhaHeader
341
- prefixIcon={
342
- <button
343
- className="pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple"
344
- onClick={() => setIsExitPopupOpen(true)}
345
- >
346
- <ArrowLeftRegularIcon className="" />
347
- </button>
348
- }
349
- title="Phone Number Verification"
350
- className="pds2-border-b-1 pds2-border-bg-seperator-dark"
351
- />
352
-
353
- <AbhaStepper/>
354
- <div className="pds2-p-16 pds2-space-y-16 pds2-overflow-y-auto pds2-flex-1 pds2-bg-bg-01">
355
- <AbhaOtpCard
356
- otpSentToText="Enter OTP received through ABDM to verify mobile number"
357
- onOtpCompletion={handleOtpCompletion}
358
- onResendOtpClick={handleResendOtpClick}
359
- error={error}
360
- setIsValid={(val) => {
361
- error && setError(null);
362
- setIsOtpValid(val);
363
- }}
364
- prefixIcon={
365
- <img
366
- src="https://cdn.eka.care/vagus/cm6hreldp000b0tfwf0nj156l.webp"
367
- alt="abha"
368
- className="pds2-w-48"
369
- />
370
- }
371
- />
372
- </div>
373
- <div className="pds2-p-16 pds2-sticky pds2-bottom-0 pds2-bg-bg-white pds2-w-full pds2-border pds2-border-border-brand-02">
374
- <Pds2Button
375
- title="Verify"
376
- state={(!isOtpValid || aadhaarMobileVerifyApiStatus === LOADING_STATE.LOADING )? 'disabled' : 'enabled'}
377
- className="pds2-w-full"
378
- onClick={() => handleVerifyClick(otp)}
379
- isLoading={aadhaarMobileVerifyApiStatus === LOADING_STATE.LOADING}
380
- />
381
- </div>
382
- <AbhaErrorBottomSheet onSubmitClick={handleErrorBottomsheetButtonClick} />
383
- <ExitPopup open={isExitPopupOpen} setOpen={setIsExitPopupOpen} />
384
- </div>
385
- );
386
- };
387
-
388
- export default AbhaPhoneNumberVerificationScreen;