@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,373 +0,0 @@
1
- import { LOADING_STATE } from '@elixir/types';
2
- import {
3
- postRegisterAadhaarMobileVerify,
4
- postAbdmRegisterMobileVerify,
5
- postAbdmRegisterMobileResendOtp,
6
- postRegisterAadhaarMobileResendOtp,
7
- setIndividualEnv,
8
- } from 'apis';
9
- import { useState } from 'react';
10
- import Pds2Button from '../atoms/button';
11
- import AbhaHeader from '../organisms/abha/abha-header';
12
- import AbhaErrorBottomSheet from '../organisms/abha/error-bottom-sheet';
13
- import AbhaOtpCard from '../organisms/abha/otp-card';
14
- import useAuthAbhaStore from '../stores/auth-abha-store';
15
- import { SCREEN_NAMES } from '../stores/auth-abha-store/types';
16
- import { handleSendEvent } from '@elixir/utils';
17
- import { useEffect } from 'react';
18
- import { CircleInfoSolidIcon } from '@elixir/icons';
19
- import { GET_EXTRA_HEADERS } from 'apis';
20
-
21
- const AbhaPhoneNumberVerificationScreen = () => {
22
- const txnId = useAuthAbhaStore((state) => state.txnId);
23
- const clearAbhaAuthStore = useAuthAbhaStore((state) => state.clearAbhaAuthStore);
24
- const setBottomsheetErrorInfo = useAuthAbhaStore((state) => state.setBottomsheetErrorInfo);
25
- const setEkaSmallToken = useAuthAbhaStore((state) => state.setEkaSmallToken);
26
- const setOid = useAuthAbhaStore((state) => state.setOid);
27
- const setAadhaarVerificationSkipStateStatus = useAuthAbhaStore(
28
- (state) => state.setAadhaarVerificationSkipStateStatus
29
- );
30
- const setSelectedAbhaAddress = useAuthAbhaStore((state) => state.setSelectedAbhaAddress);
31
-
32
- const setAbhaAddressList = useAuthAbhaStore((state) => state.setAbhaAddressList);
33
- const setScreen = useAuthAbhaStore((state) => state.setScreen);
34
- const selectedMethod = useAuthAbhaStore((state) => state.abhaAuthFlowMethod);
35
-
36
- const [otp, setOtp] = useState('');
37
- const [isOtpValid, setIsOtpValid] = useState(false);
38
- const [error, setError] = useState<string | null>('');
39
-
40
- const [aadhaarMobileVerifyApiStatus, setAadhaarMobileVerifyApiStatus] = useState<LOADING_STATE>(
41
- LOADING_STATE.IDLE
42
- );
43
- const setTxnId = useAuthAbhaStore((state) => state.setTxnId);
44
-
45
- const setEkaProfileInfo = useAuthAbhaStore((state) => state.setEkaProfileInfo);
46
- const clientId = useAuthAbhaStore((state) => state.clientId);
47
- const selectedAbhaFlow = useAuthAbhaStore((state) => state.selectedAbhaFlow);
48
- const isNewLoginOrCreateFlow = useAuthAbhaStore((state) => state.isNewLoginOrCreateFlow);
49
- const isEkaAppLogin = useAuthAbhaStore((state) => state.isEkaAppLogin);
50
- const extra_headers = GET_EXTRA_HEADERS();
51
- console.log('selectedAbhaFlow is : ', selectedAbhaFlow);
52
-
53
- // Analytics event tracker
54
- const trackAbhaEvent = ({ name, data = {} }: { name: string; data?: Record<string, any> }) => {
55
- const baseProps = {
56
- login_platform: clientId,
57
- is_eka_app_login: isEkaAppLogin ? 'true' : 'false',
58
- is_new_login_or_create_flow: isNewLoginOrCreateFlow ? 'true' : 'false',
59
- txn_id: txnId || 'missing txnId',
60
- oid: extra_headers?.['X-User-ID'] ? 'true' : 'false',
61
- access_token: extra_headers?.['auth'] ? 'true' : 'false',
62
- flow: selectedMethod ?? ""
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_mobile_otp_verify',
83
- platform: clientId,
84
- },
85
- });
86
- }, []);
87
-
88
- const handleOtpCompletion = ({ otp: newOtp }: { otp: string }) => {
89
- setOtp(newOtp);
90
- trackAbhaEvent({
91
- name: 'abha_mobile_otp_completion',
92
- data: {
93
- platform: clientId,
94
- type: 'verify',
95
- otp_entered: true,
96
- },
97
- });
98
- handleVerifyClick(newOtp);
99
- };
100
-
101
- const handleResendOtpClick = async () => {
102
- if (!txnId) {
103
- trackAbhaEvent({
104
- name: 'abha_mobile_otp_resend_clicked_no_txnId',
105
- data: {
106
- type: 'resend',
107
- platform: clientId,
108
- txn_id: 'missing_txnId',
109
- txn_id_exists: false,
110
- },
111
- });
112
- return;
113
- }
114
-
115
- trackAbhaEvent({
116
- name: 'abha_mobile_otp_verify_clicks',
117
- data: {
118
- type: 'resend',
119
- platform: clientId,
120
- },
121
- });
122
-
123
- console.log('selectedMethod', selectedMethod);
124
- let response;
125
- if (selectedAbhaFlow === 'mobile') {
126
- trackAbhaEvent({
127
- name: 'abha_mobile_otp_resend_initiated',
128
- data: {
129
- platform: clientId,
130
- type: 'verify',
131
- flow_type: selectedAbhaFlow,
132
- },
133
- });
134
- console.log('selectedFlow is mobile, so triggering mobile resend otp api', selectedAbhaFlow);
135
- response = await postAbdmRegisterMobileResendOtp({
136
- txn_id: txnId,
137
- });
138
- } else {
139
- trackAbhaEvent({
140
- name: 'aadhaar_mobile_otp_resend_initiated',
141
- data: {
142
- platform: clientId,
143
- type: 'verify',
144
- flow_type: selectedAbhaFlow,
145
- },
146
- });
147
- console.log(
148
- 'selectedFlow is aadhaar, so triggering aadhaar resend otp api',
149
- selectedAbhaFlow
150
- );
151
- response = await postRegisterAadhaarMobileResendOtp({
152
- txn_id: txnId,
153
- });
154
- }
155
-
156
- const { txn_id, error: resendOtpError, action: errorAction } = response;
157
-
158
- if (!txn_id) {
159
- trackAbhaEvent({
160
- name: 'abha_mobile_otp_resend_failed',
161
- data: {
162
- platform: clientId,
163
- reason: resendOtpError || 'no_txn_id',
164
- reason_exists: !!resendOtpError,
165
- },
166
- });
167
- setError(resendOtpError || 'Something went wrong, please try again');
168
- if (errorAction) {
169
- setBottomsheetErrorInfo(errorAction);
170
- }
171
- return;
172
- }
173
-
174
- if (txn_id) {
175
- setTxnId(txn_id);
176
- }
177
-
178
- trackAbhaEvent({
179
- name: 'abha_mobile_otp_resend_success',
180
- data: {
181
- platform: clientId,
182
- txn_id: txn_id,
183
- },
184
- });
185
- };
186
-
187
- const handleVerifyClick = async (otpToSubmit: string) => {
188
- if (!txnId) {
189
- trackAbhaEvent({
190
- name: 'abha_mobile_verify_no_txnId',
191
- data: {
192
- type: 'verify',
193
- platform: clientId,
194
- txn_id: 'missing_txnId',
195
- txn_id_exists: false,
196
- },
197
- });
198
- return;
199
- }
200
-
201
- trackAbhaEvent({
202
- name: 'abha_mobile_otp_submitted',
203
- data: {
204
- type: 'verify',
205
- platform: clientId,
206
- txn_id: txnId,
207
- },
208
- });
209
-
210
- setAadhaarMobileVerifyApiStatus(LOADING_STATE.LOADING);
211
-
212
- try {
213
- let response;
214
- if (selectedAbhaFlow === 'mobile') {
215
- trackAbhaEvent({
216
- name: 'abha_mobile_otp_verification_started',
217
- data: {
218
- platform: clientId,
219
- flow_type: selectedAbhaFlow,
220
- },
221
- });
222
- response = await postAbdmRegisterMobileVerify({
223
- otp: otpToSubmit,
224
- txn_id: txnId,
225
- });
226
- } else {
227
- trackAbhaEvent({
228
- name: 'aadhaar_otp_verification_started',
229
- data: {
230
- platform: clientId,
231
- flow_type: selectedAbhaFlow,
232
- },
233
- });
234
-
235
- response = await postRegisterAadhaarMobileVerify({
236
- otp: otpToSubmit,
237
- txn_id: txnId,
238
- });
239
- }
240
-
241
- const {
242
- txn_id,
243
- skip_state,
244
- eka,
245
- profile,
246
- error: verifyError,
247
- action: errorAction,
248
- abha_profiles,
249
- } = response;
250
-
251
- if (!txn_id || !skip_state) {
252
- trackAbhaEvent({
253
- name: 'abha_mobile_otp_verification_failed',
254
- data: {
255
- platform: clientId,
256
- reason: verifyError || 'missing_txn_id_or_skip_state',
257
- txn_id_exists: !!txn_id,
258
- skip_state_exists: !!skip_state,
259
- },
260
- });
261
- setAadhaarMobileVerifyApiStatus(LOADING_STATE.REJECTED);
262
- setError(verifyError || 'Something went wrong, please try again');
263
- if (errorAction) {
264
- setBottomsheetErrorInfo(errorAction);
265
- }
266
- return;
267
- }
268
- setAadhaarMobileVerifyApiStatus(LOADING_STATE.RESOLVED);
269
- setAadhaarVerificationSkipStateStatus(skip_state);
270
- if (eka?.min_token) {
271
- setEkaSmallToken(eka.min_token);
272
- }
273
- if (eka?.oid) {
274
- setOid(eka.oid);
275
- }
276
-
277
- if (profile && profile.abha_address) {
278
- setSelectedAbhaAddress(profile.abha_address);
279
- }
280
-
281
- if (profile) {
282
- setEkaProfileInfo({
283
- // date_of_birth: `${profile.day_of_birth}-${profile.month_of_birth}-${profile.year_of_birth}` as string,
284
- date_of_birth: `${profile.year_of_birth}-${String(profile.month_of_birth).padStart(2, '0')}-${String(profile.day_of_birth).padStart(2, '0')}`,
285
- firstname: profile.first_name as string,
286
- lastname: profile.last_name as string,
287
- pincode: profile.pincode,
288
- gender: profile.gender as string,
289
- oid: eka?.oid,
290
- abha_address: profile?.abha_address,
291
- abha_number: profile?.abha_number,
292
- middlename: profile?.middle_name,
293
- });
294
- }
295
-
296
- // abha -> create abha with mobile
297
- // HMIS -> when we are creating a new patient profile, we wont have oid in the headers.
298
- // so server will send oid in the eka object.
299
- // set the oid in the headers and redirect to abha mobile linking status screen
300
-
301
- console.log('remove oid from set indvidual env')
302
-
303
- trackAbhaEvent({
304
- name: 'abha_mobile_otp_verification_success',
305
- data: {
306
- platform: clientId,
307
- skip_state,
308
- },
309
- });
310
-
311
- setScreen(SCREEN_NAMES.ABHA_MOBILE_LINKING_STATUS);
312
- } catch (error) {
313
- trackAbhaEvent({
314
- name: 'abha_mobile_otp_verification_exception',
315
- data: {
316
- platform: clientId,
317
- reason: 'exception_thrown',
318
- },
319
- });
320
-
321
- setAadhaarMobileVerifyApiStatus(LOADING_STATE.REJECTED);
322
- setError('Something went wrong, please try again');
323
- }
324
- };
325
-
326
- const handleErrorBottomsheetButtonClick = () => {
327
- setScreen(SCREEN_NAMES.CREATE_ABHA_WITH_AADHAAR);
328
- const isAppLogin = useAuthAbhaStore.getState().isEkaAppLogin;
329
- clearAbhaAuthStore();
330
- useAuthAbhaStore.setState({ isEkaAppLogin: isAppLogin });
331
- };
332
-
333
- return (
334
- <div className="pds2-flex pds2-flex-col pds2-w-full pds2-h-screen pds2-bg-bg-white">
335
- <AbhaHeader
336
- title="Phone Number Verification"
337
- className="pds2-border-b-1 pds2-border-bg-seperator-dark"
338
- />
339
-
340
- <div className="pds2-p-16 pds2-space-y-16 pds2-overflow-y-scroll pds2-flex-1">
341
- <AbhaOtpCard
342
- otpSentToText="Enter OTP received through ABDM to verify mobile number"
343
- onOtpCompletion={handleOtpCompletion}
344
- onResendOtpClick={handleResendOtpClick}
345
- error={error}
346
- setIsValid={(val) => {
347
- error && setError(null);
348
- setIsOtpValid(val);
349
- }}
350
- prefixIcon={
351
- <img
352
- src="https://cdn.eka.care/vagus/cm6hreldp000b0tfwf0nj156l.webp"
353
- alt="abha"
354
- className="pds2-w-48"
355
- />
356
- }
357
- />
358
- </div>
359
- <div className="pds2-p-16 pds2-sticky pds2-bottom-0 pds2-bg-bg-white pds2-w-full pds2-border pds2-border-border-brand-02">
360
- <Pds2Button
361
- title="Verify"
362
- state={(!isOtpValid || aadhaarMobileVerifyApiStatus === LOADING_STATE.LOADING )? 'disabled' : 'enabled'}
363
- className="pds2-w-full"
364
- onClick={() => handleVerifyClick(otp)}
365
- isLoading={aadhaarMobileVerifyApiStatus === LOADING_STATE.LOADING}
366
- />
367
- </div>
368
- <AbhaErrorBottomSheet onSubmitClick={handleErrorBottomsheetButtonClick} />
369
- </div>
370
- );
371
- };
372
-
373
- export default AbhaPhoneNumberVerificationScreen;