react-native-mytatva-rn-sdk 1.0.0 → 1.1.0
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.
- package/android/app/build.gradle +5 -0
- package/android/build.gradle +5 -5
- package/android/gradle.properties +13 -5
- package/android/settings.gradle +9 -0
- package/android/src/main/AndroidManifest.xml +22 -1
- package/android/src/main/AndroidManifestNew.xml +59 -1
- package/android/src/main/java/com/{visitrnsdk/VisitRnSdkPackage.kt → mytatvarnsdk/MyTatvaRnSdkPackage.kt} +2 -2
- package/android/src/main/java/com/{visitrnsdk/VisitRnSdkViewManager.kt → mytatvarnsdk/MyTatvaRnSdkViewManager.kt} +1 -1
- package/lib/commonjs/BcaDeviceListSheet.js +286 -0
- package/lib/commonjs/BcaDeviceListSheet.js.map +1 -0
- package/lib/commonjs/MainWebView.js +68 -0
- package/lib/commonjs/MainWebView.js.map +1 -0
- package/lib/commonjs/ProgressWebView.js +547 -0
- package/lib/commonjs/ProgressWebView.js.map +1 -0
- package/lib/commonjs/Services.js +27 -1
- package/lib/commonjs/Services.js.map +1 -1
- package/lib/commonjs/Sheets.js +7 -0
- package/lib/commonjs/Sheets.js.map +1 -0
- package/lib/commonjs/api/auth.js +167 -0
- package/lib/commonjs/api/auth.js.map +1 -0
- package/lib/commonjs/api/base.js +224 -0
- package/lib/commonjs/api/base.js.map +1 -0
- package/lib/commonjs/api/index.js +12 -0
- package/lib/commonjs/api/index.js.map +1 -0
- package/lib/commonjs/assets/icons/achieve.svg +3 -0
- package/lib/commonjs/assets/icons/heart.svg +3 -0
- package/lib/commonjs/assets/icons/smartWatch.svg +3 -0
- package/lib/commonjs/constants/asyncstorage.js +29 -0
- package/lib/commonjs/constants/asyncstorage.js.map +1 -0
- package/lib/commonjs/constants/constants.js +1373 -0
- package/lib/commonjs/constants/constants.js.map +1 -0
- package/lib/commonjs/constants.js +12 -2
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/helpers/Matrics.js +49 -0
- package/lib/commonjs/helpers/Matrics.js.map +1 -0
- package/lib/commonjs/helpers/bluetoothPermissionHelper.js +114 -0
- package/lib/commonjs/helpers/bluetoothPermissionHelper.js.map +1 -0
- package/lib/commonjs/helpers/colors.js +304 -0
- package/lib/commonjs/helpers/colors.js.map +1 -0
- package/lib/commonjs/helpers/common.js +46 -0
- package/lib/commonjs/helpers/common.js.map +1 -0
- package/lib/commonjs/helpers/fonts.js +33 -0
- package/lib/commonjs/helpers/fonts.js.map +1 -0
- package/lib/commonjs/helpers/globalStyles.js +188 -0
- package/lib/commonjs/helpers/globalStyles.js.map +1 -0
- package/lib/commonjs/helpers/icons.js +16 -0
- package/lib/commonjs/helpers/icons.js.map +1 -0
- package/lib/commonjs/index.android.js +163 -414
- package/lib/commonjs/index.android.js.map +1 -1
- package/lib/commonjs/index.ios.js +138 -187
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/redux/Store.js +42 -0
- package/lib/commonjs/redux/Store.js.map +1 -0
- package/lib/commonjs/redux/hooks.js +8 -0
- package/lib/commonjs/redux/hooks.js.map +1 -0
- package/lib/commonjs/redux/sagas/AuthSaga.js +44 -0
- package/lib/commonjs/redux/sagas/AuthSaga.js.map +1 -0
- package/lib/commonjs/redux/sagas/index.js +15 -0
- package/lib/commonjs/redux/sagas/index.js.map +1 -0
- package/lib/commonjs/redux/slices/authSlice.js +80 -0
- package/lib/commonjs/redux/slices/authSlice.js.map +1 -0
- package/lib/commonjs/redux/slices/index.js +44 -0
- package/lib/commonjs/redux/slices/index.js.map +1 -0
- package/lib/commonjs/types/auth.js +2 -0
- package/lib/commonjs/types/auth.js.map +1 -0
- package/lib/commonjs/types/common.js +2 -0
- package/lib/commonjs/types/common.js.map +1 -0
- package/lib/commonjs/types/index.js +13 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/module/BcaDeviceListSheet.js +277 -0
- package/lib/module/BcaDeviceListSheet.js.map +1 -0
- package/lib/module/MainWebView.js +61 -0
- package/lib/module/MainWebView.js.map +1 -0
- package/lib/module/ProgressWebView.js +536 -0
- package/lib/module/ProgressWebView.js.map +1 -0
- package/lib/module/Services.js +24 -0
- package/lib/module/Services.js.map +1 -1
- package/lib/module/Sheets.js +4 -0
- package/lib/module/Sheets.js.map +1 -0
- package/lib/module/api/auth.js +160 -0
- package/lib/module/api/auth.js.map +1 -0
- package/lib/module/api/base.js +212 -0
- package/lib/module/api/base.js.map +1 -0
- package/lib/module/api/index.js +5 -0
- package/lib/module/api/index.js.map +1 -0
- package/lib/module/assets/icons/achieve.svg +3 -0
- package/lib/module/assets/icons/heart.svg +3 -0
- package/lib/module/assets/icons/smartWatch.svg +3 -0
- package/lib/module/constants/asyncstorage.js +23 -0
- package/lib/module/constants/asyncstorage.js.map +1 -0
- package/lib/module/constants/constants.js +1367 -0
- package/lib/module/constants/constants.js.map +1 -0
- package/lib/module/constants.js +12 -2
- package/lib/module/constants.js.map +1 -1
- package/lib/module/helpers/Matrics.js +44 -0
- package/lib/module/helpers/Matrics.js.map +1 -0
- package/lib/module/helpers/bluetoothPermissionHelper.js +103 -0
- package/lib/module/helpers/bluetoothPermissionHelper.js.map +1 -0
- package/lib/module/helpers/colors.js +298 -0
- package/lib/module/helpers/colors.js.map +1 -0
- package/lib/module/helpers/common.js +34 -0
- package/lib/module/helpers/common.js.map +1 -0
- package/lib/module/helpers/fonts.js +27 -0
- package/lib/module/helpers/fonts.js.map +1 -0
- package/lib/module/helpers/globalStyles.js +181 -0
- package/lib/module/helpers/globalStyles.js.map +1 -0
- package/lib/module/helpers/icons.js +9 -0
- package/lib/module/helpers/icons.js.map +1 -0
- package/lib/module/index.android.js +165 -413
- package/lib/module/index.android.js.map +1 -1
- package/lib/module/index.ios.js +138 -187
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/redux/Store.js +34 -0
- package/lib/module/redux/Store.js.map +1 -0
- package/lib/module/redux/hooks.js +7 -0
- package/lib/module/redux/hooks.js.map +1 -0
- package/lib/module/redux/sagas/AuthSaga.js +34 -0
- package/lib/module/redux/sagas/AuthSaga.js.map +1 -0
- package/lib/module/redux/sagas/index.js +8 -0
- package/lib/module/redux/sagas/index.js.map +1 -0
- package/lib/module/redux/slices/authSlice.js +68 -0
- package/lib/module/redux/slices/authSlice.js.map +1 -0
- package/lib/module/redux/slices/index.js +24 -0
- package/lib/module/redux/slices/index.js.map +1 -0
- package/lib/module/types/auth.js +2 -0
- package/lib/module/types/auth.js.map +1 -0
- package/lib/module/types/common.js +2 -0
- package/lib/module/types/common.js.map +1 -0
- package/lib/module/types/index.js +4 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/typescript/BcaDeviceListSheet.d.ts +7 -0
- package/lib/typescript/BcaDeviceListSheet.d.ts.map +1 -0
- package/lib/typescript/MainWebView.d.ts +4 -0
- package/lib/typescript/MainWebView.d.ts.map +1 -0
- package/lib/typescript/ProgressWebView.d.ts +4 -0
- package/lib/typescript/ProgressWebView.d.ts.map +1 -0
- package/lib/typescript/Services.d.ts +5 -0
- package/lib/typescript/Services.d.ts.map +1 -0
- package/lib/typescript/Sheets.d.ts +2 -0
- package/lib/typescript/Sheets.d.ts.map +1 -0
- package/lib/typescript/api/auth.d.ts +33 -0
- package/lib/typescript/api/auth.d.ts.map +1 -0
- package/lib/typescript/api/base.d.ts +20 -0
- package/lib/typescript/api/base.d.ts.map +1 -0
- package/lib/typescript/api/index.d.ts +35 -0
- package/lib/typescript/api/index.d.ts.map +1 -0
- package/lib/typescript/constants/asyncstorage.d.ts +23 -0
- package/lib/typescript/constants/asyncstorage.d.ts.map +1 -0
- package/lib/typescript/constants/constants.d.ts +1081 -0
- package/lib/typescript/constants/constants.d.ts.map +1 -0
- package/lib/typescript/constants.d.ts +16 -0
- package/lib/typescript/constants.d.ts.map +1 -0
- package/lib/typescript/helpers/Matrics.d.ts +14 -0
- package/lib/typescript/helpers/Matrics.d.ts.map +1 -0
- package/lib/typescript/helpers/bluetoothPermissionHelper.d.ts +18 -0
- package/lib/typescript/helpers/bluetoothPermissionHelper.d.ts.map +1 -0
- package/lib/typescript/helpers/colors.d.ts +297 -0
- package/lib/typescript/helpers/colors.d.ts.map +1 -0
- package/lib/typescript/helpers/common.d.ts +8 -0
- package/lib/typescript/helpers/common.d.ts.map +1 -0
- package/lib/typescript/helpers/fonts.d.ts +23 -0
- package/lib/typescript/helpers/fonts.d.ts.map +1 -0
- package/lib/typescript/helpers/globalStyles.d.ts +176 -0
- package/lib/typescript/helpers/globalStyles.d.ts.map +1 -0
- package/lib/typescript/helpers/icons.d.ts +6 -0
- package/lib/typescript/helpers/icons.d.ts.map +1 -0
- package/lib/typescript/index.android.d.ts +30 -0
- package/lib/typescript/index.android.d.ts.map +1 -0
- package/lib/typescript/index.ios.d.ts +28 -0
- package/lib/typescript/index.ios.d.ts.map +1 -0
- package/lib/typescript/redux/Store.d.ts +13 -0
- package/lib/typescript/redux/Store.d.ts.map +1 -0
- package/lib/typescript/redux/hooks.d.ts +1 -0
- package/lib/typescript/redux/hooks.d.ts.map +1 -0
- package/lib/typescript/redux/sagas/AuthSaga.d.ts +3 -0
- package/lib/typescript/redux/sagas/AuthSaga.d.ts.map +1 -0
- package/lib/typescript/redux/sagas/index.d.ts +3 -0
- package/lib/typescript/redux/sagas/index.d.ts.map +1 -0
- package/lib/typescript/redux/slices/authSlice.d.ts +5 -0
- package/lib/typescript/redux/slices/authSlice.d.ts.map +1 -0
- package/lib/typescript/redux/slices/index.d.ts +6 -0
- package/lib/typescript/redux/slices/index.d.ts.map +1 -0
- package/lib/typescript/types/auth.d.ts +485 -0
- package/lib/typescript/types/auth.d.ts.map +1 -0
- package/lib/typescript/types/common.d.ts +19 -0
- package/lib/typescript/types/common.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +4 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/package.json +39 -8
- package/src/BcaDeviceListSheet.tsx +331 -0
- package/src/MainWebView.tsx +67 -0
- package/src/ProgressWebView.tsx +602 -0
- package/src/Services.js +40 -0
- package/src/Sheets.js +4 -0
- package/src/api/auth.ts +156 -0
- package/src/api/base.ts +247 -0
- package/src/api/index.ts +5 -0
- package/src/assets/icons/achieve.svg +3 -0
- package/src/assets/icons/heart.svg +3 -0
- package/src/assets/icons/smartWatch.svg +3 -0
- package/src/constants/asyncstorage.ts +23 -0
- package/src/constants/constants.ts +1204 -0
- package/src/constants.ts +14 -0
- package/src/helpers/Matrics.ts +48 -0
- package/src/helpers/bluetoothPermissionHelper.ts +198 -0
- package/src/helpers/colors.ts +320 -0
- package/src/helpers/common.ts +46 -0
- package/src/helpers/fonts.ts +28 -0
- package/src/helpers/globalStyles.ts +179 -0
- package/src/helpers/icons.ts +11 -0
- package/src/index.android.js +164 -577
- package/src/index.ios.js +147 -215
- package/src/redux/Store.ts +36 -0
- package/src/redux/hooks.ts +6 -0
- package/src/redux/sagas/AuthSaga.ts +49 -0
- package/src/redux/sagas/index.ts +9 -0
- package/src/redux/slices/authSlice.ts +81 -0
- package/src/redux/slices/index.ts +29 -0
- package/src/types/auth.ts +533 -0
- package/src/types/common.ts +19 -0
- package/src/types/index.ts +8 -0
- package/lib/typescript/index.test.d.ts +0 -1
- package/lib/typescript/index.test.d.ts.map +0 -1
- package/src/constants.js +0 -4
- /package/ios/{VisitRnSdk.xcodeproj → MyTatvaRnSdk.xcodeproj}/project.pbxproj +0 -0
- /package/ios/{VisitRnSdkViewManager.h → MyTatvaRnSdkViewManager.h} +0 -0
- /package/ios/{VisitRnSdkViewManager.m → MyTatvaRnSdkViewManager.m} +0 -0
- /package/{react-native-visit-rn-sdk.podspec → react-native-mytatva-rn-sdk.podspec} +0 -0
package/src/index.ios.js
CHANGED
|
@@ -17,9 +17,20 @@ import {
|
|
|
17
17
|
} from 'react-native';
|
|
18
18
|
import { EventRegister } from 'react-native-event-listeners';
|
|
19
19
|
import { WebView } from 'react-native-webview';
|
|
20
|
-
import DeviceInfo from 'react-native-device-info';
|
|
21
|
-
import { getWebViewLink, httpClient } from './Services';
|
|
22
20
|
import constants from './constants';
|
|
21
|
+
import axios from 'axios';
|
|
22
|
+
import {getEncryptedText, getDecryptedData} from './Services';
|
|
23
|
+
|
|
24
|
+
import MainWebView from './MainWebView';
|
|
25
|
+
import ProgressWebView from './ProgressWebView';
|
|
26
|
+
import { SheetManager, SheetProvider } from 'react-native-actions-sheet';
|
|
27
|
+
|
|
28
|
+
import '../src/Sheets';
|
|
29
|
+
import { Provider } from 'react-redux';
|
|
30
|
+
import { configureStore } from '@reduxjs/toolkit';
|
|
31
|
+
import createSagaMiddleware from '@redux-saga/core';
|
|
32
|
+
import rootReducer from './redux/slices';
|
|
33
|
+
import rootSaga from './redux/sagas';
|
|
23
34
|
|
|
24
35
|
const LINKING_ERROR =
|
|
25
36
|
`The package 'react-native-mytatva-rn-sdk' doesn't seem to be linked. Make sure: \n\n` +
|
|
@@ -52,111 +63,40 @@ const unescapeHTML = (str) =>
|
|
|
52
63
|
}
|
|
53
64
|
});
|
|
54
65
|
|
|
55
|
-
const
|
|
66
|
+
const mytatvaEvent = 'mytatva-event';
|
|
67
|
+
|
|
68
|
+
const sagaMiddleware = createSagaMiddleware();
|
|
69
|
+
const store = configureStore({
|
|
70
|
+
reducer: rootReducer,
|
|
71
|
+
middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(sagaMiddleware)
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
sagaMiddleware.run(rootSaga);
|
|
56
75
|
|
|
57
76
|
const MyTatvaRnSdkView = ({
|
|
58
|
-
|
|
77
|
+
mobileNumber,
|
|
78
|
+
uuid,
|
|
59
79
|
baseUrl,
|
|
60
80
|
errorBaseUrl,
|
|
61
81
|
token,
|
|
62
|
-
moduleName,
|
|
63
82
|
environment,
|
|
64
|
-
|
|
65
|
-
|
|
83
|
+
userMetaInfo,
|
|
84
|
+
clientSource,
|
|
85
|
+
moduleName,
|
|
86
|
+
navigation
|
|
66
87
|
}) => {
|
|
67
88
|
const [source, setSource] = useState('');
|
|
68
|
-
const [loading, setLoading] = useState(
|
|
69
|
-
|
|
70
|
-
if (magicLink?.trim()?.length) {
|
|
71
|
-
setSource(magicLink);
|
|
72
|
-
setLoading(false);
|
|
73
|
-
} else {
|
|
74
|
-
const systemVersion = DeviceInfo.getSystemVersion();
|
|
75
|
-
const version = DeviceInfo.getVersion();
|
|
76
|
-
DeviceInfo.getUniqueId()
|
|
77
|
-
.then((uniqueId) =>
|
|
78
|
-
getWebViewLink(
|
|
79
|
-
baseUrl,
|
|
80
|
-
token,
|
|
81
|
-
cpsid,
|
|
82
|
-
'iPhone',
|
|
83
|
-
uniqueId,
|
|
84
|
-
version,
|
|
85
|
-
systemVersion,
|
|
86
|
-
environment
|
|
87
|
-
)
|
|
88
|
-
)
|
|
89
|
-
.then((res) => {
|
|
90
|
-
if (res.data?.errorMessage) {
|
|
91
|
-
const { errorMessage } = res.data;
|
|
92
|
-
const errorUrl = `${errorBaseUrl}/star-health?error=${errorMessage}`;
|
|
93
|
-
setSource(errorUrl);
|
|
94
|
-
if (res.data?.errorMessage === 'Please login again') {
|
|
95
|
-
EventRegister.emitEvent(visitEvent, {
|
|
96
|
-
message: 'unauthorized-wellness-access',
|
|
97
|
-
errorMessage: errorMessage,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
if (res.data?.errorMessage.includes('External Server Error')) {
|
|
101
|
-
EventRegister.emitEvent('visit-event', {
|
|
102
|
-
message: 'external-server-error',
|
|
103
|
-
errorMessage: errorMessage,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
} else if (res.data.message === 'success') {
|
|
107
|
-
const magicCode = res.data?.magicCode;
|
|
108
|
-
const responseReferenceId = res.data?.responseReferenceId;
|
|
109
|
-
let finalBaseUrl = '';
|
|
110
|
-
if (magicCode) {
|
|
111
|
-
if (environment.toUpperCase() === 'PROD') {
|
|
112
|
-
finalBaseUrl = constants.PROD_BASE_URL;
|
|
113
|
-
} else {
|
|
114
|
-
finalBaseUrl = constants.STAGE_BASE_URL;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (finalBaseUrl && magicCode) {
|
|
118
|
-
let finalUrl = `${finalBaseUrl}=${magicCode}`;
|
|
119
|
-
if (moduleName?.trim()) {
|
|
120
|
-
finalUrl += `&tab=${moduleName}`;
|
|
121
|
-
}
|
|
89
|
+
const [loading, setLoading] = useState(false);
|
|
90
|
+
const [isError, setError] = useState(false);
|
|
122
91
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
92
|
+
// useEffect(() => {
|
|
93
|
+
// if ((baseUrl?.trim()?.length || 0) > 0) {
|
|
94
|
+
// setSource(baseUrl);
|
|
95
|
+
// }
|
|
96
|
+
// }, [
|
|
97
|
+
// baseUrl,
|
|
129
98
|
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
} else {
|
|
133
|
-
EventRegister.emitEvent('visit-event', {
|
|
134
|
-
message: 'generate-magic-link-failed',
|
|
135
|
-
errorMessage: `${res.data}`,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
.catch((err) => {
|
|
140
|
-
console.log('getWebViewLink err', { err });
|
|
141
|
-
EventRegister.emitEvent('visit-event', {
|
|
142
|
-
message: 'generate-magic-link-failed',
|
|
143
|
-
errorMessage: `${err}`,
|
|
144
|
-
});
|
|
145
|
-
})
|
|
146
|
-
.finally(() => {
|
|
147
|
-
setLoading(false);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}, [
|
|
151
|
-
cpsid,
|
|
152
|
-
token,
|
|
153
|
-
baseUrl,
|
|
154
|
-
errorBaseUrl,
|
|
155
|
-
moduleName,
|
|
156
|
-
environment,
|
|
157
|
-
magicLink,
|
|
158
|
-
isLoggingEnabled,
|
|
159
|
-
]);
|
|
99
|
+
// ]);
|
|
160
100
|
|
|
161
101
|
const MyTatvaRnSdkViewManager = useMemo(
|
|
162
102
|
() =>
|
|
@@ -173,134 +113,108 @@ const MyTatvaRnSdkView = ({
|
|
|
173
113
|
[]
|
|
174
114
|
);
|
|
175
115
|
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (!uuid && !mobileNumber) {
|
|
118
|
+
setTimeout(() => {
|
|
119
|
+
EventRegister.emitEvent('mytatva-event', {
|
|
120
|
+
message: 'unique-identifier',
|
|
121
|
+
errorMessage: 'contact number or patientId is required',
|
|
122
|
+
});
|
|
123
|
+
}, 1000)
|
|
124
|
+
setError(true)
|
|
125
|
+
} else {
|
|
126
|
+
authenticateSDK()
|
|
127
|
+
setError(false)
|
|
128
|
+
}
|
|
129
|
+
}, [uuid, mobileNumber])
|
|
130
|
+
|
|
176
131
|
const webviewRef = useRef(null);
|
|
177
|
-
const [apiBaseUrl, setApiBaseUrl] = useState('');
|
|
178
|
-
const [authToken, setAuthToken] = useState('');
|
|
179
|
-
const [hasLoadedOnce, setHasLoadedOnce] = useState(false);
|
|
180
132
|
|
|
181
|
-
const
|
|
182
|
-
(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
133
|
+
const authenticateSDK = () => {
|
|
134
|
+
setLoading(true)
|
|
135
|
+
let baseUrl = environment.toUpperCase() === 'PROD' ? constants.PROD_BASE_URL : constants.STAGE_BASE_URL
|
|
136
|
+
const finalUrl = baseUrl + '/helper/authenticateClient';
|
|
137
|
+
const data = {
|
|
138
|
+
source : clientSource,
|
|
139
|
+
sourceKey : token
|
|
140
|
+
}
|
|
141
|
+
axios({
|
|
142
|
+
method: 'post',
|
|
143
|
+
url: finalUrl,
|
|
144
|
+
headers: {
|
|
145
|
+
'api-key': environment.toUpperCase() === 'PROD' ? constants.PROD_API_KEY : constants.STAGE_API_KEY,
|
|
146
|
+
'Content-Type': 'text/plain',
|
|
147
|
+
},
|
|
148
|
+
data: getEncryptedText(data, environment),
|
|
149
|
+
})
|
|
150
|
+
.then(async response => {
|
|
151
|
+
const parsedResponse = await JSON.parse(getDecryptedData(response?.data, environment));
|
|
152
|
+
if (parsedResponse?.data == 0) {
|
|
153
|
+
setError(true);
|
|
154
|
+
EventRegister.emitEvent('mytatva-event', {
|
|
155
|
+
message: 'unauthorized-client',
|
|
156
|
+
errorMessage: 'Unauthorized Access',
|
|
157
|
+
});
|
|
158
|
+
} else {
|
|
159
|
+
getSourceUrl();
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
.catch((error) => {
|
|
163
|
+
console.log("error", error)
|
|
164
|
+
}).finally(() => {
|
|
165
|
+
setLoading(false);
|
|
166
|
+
})
|
|
167
|
+
}
|
|
193
168
|
|
|
194
|
-
const callEmbellishApi = useCallback(
|
|
195
|
-
(data) =>
|
|
196
|
-
httpClient
|
|
197
|
-
.post(`${apiBaseUrl}/users/embellish-sync`, data, {
|
|
198
|
-
headers: {
|
|
199
|
-
Authorization: authToken,
|
|
200
|
-
},
|
|
201
|
-
})
|
|
202
|
-
.then((res) => console.log('callEmbellishApi response,', res))
|
|
203
|
-
.catch((err) => console.log('callEmbellishApi err,', { err })),
|
|
204
|
-
[apiBaseUrl, authToken]
|
|
205
|
-
);
|
|
206
169
|
|
|
207
170
|
useEffect(() => {
|
|
208
171
|
const apiManagerEmitter = new NativeEventEmitter(MyTatvaRnSdkViewManager);
|
|
209
172
|
const subscription = apiManagerEmitter.addListener(
|
|
210
173
|
'EventReminder',
|
|
211
174
|
(reminder) => {
|
|
212
|
-
|
|
213
|
-
callSyncApi(reminder?.callSyncData[0]);
|
|
214
|
-
}
|
|
215
|
-
if (reminder?.callEmbellishApi && reminder?.callEmbellishApi?.length) {
|
|
216
|
-
callEmbellishApi(reminder?.callEmbellishApi[0]);
|
|
217
|
-
}
|
|
175
|
+
|
|
218
176
|
}
|
|
219
177
|
);
|
|
220
178
|
return () => {
|
|
221
179
|
subscription.remove();
|
|
222
180
|
};
|
|
223
|
-
}, [MyTatvaRnSdkViewManager
|
|
181
|
+
}, [MyTatvaRnSdkViewManager]);
|
|
182
|
+
|
|
183
|
+
const getSourceUrl = () => {
|
|
184
|
+
let finalUrl = ''
|
|
185
|
+
const params = {
|
|
186
|
+
uuid,
|
|
187
|
+
mobileNumber,
|
|
188
|
+
clientSource,
|
|
189
|
+
moduleName,
|
|
190
|
+
environment,
|
|
191
|
+
...userMetaInfo
|
|
192
|
+
}
|
|
193
|
+
let baseUrl = environment.toUpperCase() === 'PROD' ? constants.PROD_BASE_URL : constants.STAGE_BASE_URL
|
|
194
|
+
if(baseUrl) {
|
|
195
|
+
finalUrl = baseUrl + '?data=' + encodeURIComponent(JSON.stringify(params));
|
|
196
|
+
setSource(finalUrl);
|
|
197
|
+
} else {
|
|
198
|
+
console.log("No baseUrl")
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
}
|
|
224
202
|
|
|
225
203
|
const handleMessage = async (event) => {
|
|
226
204
|
const data = JSON.parse(unescapeHTML(event.nativeEvent.data));
|
|
227
205
|
const {
|
|
228
206
|
method,
|
|
229
|
-
type,
|
|
230
|
-
frequency,
|
|
231
|
-
timestamp,
|
|
232
|
-
// eslint-disable-next-line no-shadow
|
|
233
|
-
apiBaseUrl,
|
|
234
|
-
authtoken,
|
|
235
|
-
googleFitLastSync,
|
|
236
|
-
gfHourlyLastSync,
|
|
237
207
|
url,
|
|
238
208
|
} = data;
|
|
239
|
-
console.log('handleMessage data is', data);
|
|
240
|
-
console.log(unescapeHTML(event.nativeEvent.data));
|
|
241
209
|
switch (method) {
|
|
242
210
|
case 'UPDATE_PLATFORM':
|
|
243
211
|
webviewRef.current?.injectJavaScript('window.setSdkPlatform("IOS")');
|
|
244
212
|
break;
|
|
245
|
-
case 'CONNECT_TO_GOOGLE_FIT':
|
|
246
|
-
if (DeviceInfo.getModel() === 'iPad') {
|
|
247
|
-
console.log('unsupportedHealthKitDevice triggered');
|
|
248
|
-
webviewRef.current?.injectJavaScript(
|
|
249
|
-
'window.unsupportedHealthKitDevice(true)'
|
|
250
|
-
);
|
|
251
|
-
} else {
|
|
252
|
-
MyTatvaRnSdkViewManager?.connectToAppleHealth((res) => {
|
|
253
|
-
if (res?.sleepTime || res?.numberOfSteps) {
|
|
254
|
-
webviewRef.current?.injectJavaScript(
|
|
255
|
-
`window.updateFitnessPermissions(true,${res?.numberOfSteps},${res?.sleepTime})`
|
|
256
|
-
);
|
|
257
|
-
} else {
|
|
258
|
-
webviewRef.current?.injectJavaScript(
|
|
259
|
-
'window.updateFitnessPermissions(true,0,0)'
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
break;
|
|
265
|
-
case 'GET_DATA_TO_GENERATE_GRAPH':
|
|
266
|
-
MyTatvaRnSdkViewManager?.renderGraph(
|
|
267
|
-
{ type, frequency, timestamp },
|
|
268
|
-
(err, results) => {
|
|
269
|
-
if (err) {
|
|
270
|
-
console.log('error initializing Healthkit: ', err);
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
if (results[0]) {
|
|
274
|
-
console.log('results initializing Healthkit: ', results[0]);
|
|
275
|
-
webviewRef.current?.injectJavaScript(`window.${results[0]}`);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
);
|
|
279
|
-
break;
|
|
280
|
-
case 'UPDATE_API_BASE_URL':
|
|
281
|
-
if (!hasLoadedOnce) {
|
|
282
|
-
console.log('apiBaseUrl is,', apiBaseUrl);
|
|
283
|
-
setApiBaseUrl(apiBaseUrl);
|
|
284
|
-
setAuthToken(authtoken);
|
|
285
|
-
MyTatvaRnSdkViewManager?.updateApiUrl({
|
|
286
|
-
googleFitLastSync,
|
|
287
|
-
gfHourlyLastSync,
|
|
288
|
-
});
|
|
289
|
-
setHasLoadedOnce(true);
|
|
290
|
-
}
|
|
291
|
-
break;
|
|
292
|
-
|
|
293
213
|
case 'OPEN_PDF':
|
|
294
214
|
Linking.openURL(url);
|
|
295
215
|
break;
|
|
296
216
|
case 'CLOSE_VIEW':
|
|
297
217
|
break;
|
|
298
|
-
case 'GET_LOCATION_PERMISSIONS':
|
|
299
|
-
webviewRef.current?.injectJavaScript(
|
|
300
|
-
'window.checkTheGpsPermission(true)'
|
|
301
|
-
);
|
|
302
|
-
break;
|
|
303
|
-
|
|
304
218
|
default:
|
|
305
219
|
break;
|
|
306
220
|
}
|
|
@@ -309,27 +223,41 @@ const MyTatvaRnSdkView = ({
|
|
|
309
223
|
const { height, width } = Dimensions.get('screen');
|
|
310
224
|
return (
|
|
311
225
|
// eslint-disable-next-line react-native/no-inline-styles
|
|
312
|
-
<SafeAreaView style={{ flex: 1, backgroundColor: 'white'
|
|
313
|
-
{
|
|
314
|
-
|
|
226
|
+
<SafeAreaView style={{ flex: 1, backgroundColor: 'white' }}>
|
|
227
|
+
<Provider store={store}>
|
|
228
|
+
<SheetProvider>
|
|
229
|
+
{moduleName === 'progress' ? (
|
|
230
|
+
<ProgressWebView
|
|
231
|
+
token={token}
|
|
232
|
+
environment={environment}
|
|
233
|
+
source={source}
|
|
234
|
+
loading={loading}
|
|
235
|
+
isError={isError}
|
|
236
|
+
webviewRef={webviewRef}
|
|
237
|
+
runBeforeFirst={runBeforeFirst}
|
|
238
|
+
setCanGoBack={setCanGoBack}
|
|
239
|
+
mobileNumber={mobileNumber}
|
|
240
|
+
moduleName={moduleName}
|
|
241
|
+
uuid={uuid}
|
|
242
|
+
clientSource={clientSource}
|
|
243
|
+
/>
|
|
315
244
|
) : (
|
|
316
|
-
<
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
console.warn('Webview error: ', errorMessage);
|
|
329
|
-
}
|
|
330
|
-
}}
|
|
245
|
+
<MainWebView
|
|
246
|
+
token={token}
|
|
247
|
+
environment={environment}
|
|
248
|
+
source={source}
|
|
249
|
+
loading={loading}
|
|
250
|
+
isError={isError}
|
|
251
|
+
webviewRef={webviewRef}
|
|
252
|
+
handleMessage={handleMessage}
|
|
253
|
+
runBeforeFirst={runBeforeFirst}
|
|
254
|
+
setCanGoBack={setCanGoBack}
|
|
255
|
+
clientSource={clientSource}
|
|
256
|
+
moduleName={moduleName}
|
|
331
257
|
/>
|
|
332
258
|
)}
|
|
259
|
+
</SheetProvider>
|
|
260
|
+
</Provider>
|
|
333
261
|
</SafeAreaView>
|
|
334
262
|
);
|
|
335
263
|
};
|
|
@@ -345,11 +273,15 @@ const styles = StyleSheet.create({
|
|
|
345
273
|
});
|
|
346
274
|
|
|
347
275
|
MyTatvaRnSdkView.defaultProps = {
|
|
348
|
-
|
|
276
|
+
mobileNumber: '',
|
|
277
|
+
uuid: '',
|
|
349
278
|
token: '',
|
|
350
279
|
baseUrl: '',
|
|
351
280
|
errorBaseUrl: '',
|
|
352
|
-
|
|
281
|
+
environment: '',
|
|
282
|
+
metaInfo: {},
|
|
283
|
+
clientSource: '',
|
|
284
|
+
moduleName: ''
|
|
353
285
|
};
|
|
354
286
|
|
|
355
287
|
export default MyTatvaRnSdkView;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// // --------------- LIBRARIES ---------------
|
|
2
|
+
import {configureStore} from '@reduxjs/toolkit';
|
|
3
|
+
import createSagaMiddleware from '@redux-saga/core';
|
|
4
|
+
import logger from 'redux-logger';
|
|
5
|
+
|
|
6
|
+
// // --------------- ASSETS ---------------
|
|
7
|
+
import rootReducer from './slices';
|
|
8
|
+
import rootSaga from './sagas';
|
|
9
|
+
import {TypedUseSelectorHook, useDispatch, useSelector} from 'react-redux';
|
|
10
|
+
|
|
11
|
+
// Middlewares setup
|
|
12
|
+
const sagaMiddleware = createSagaMiddleware();
|
|
13
|
+
const middlewares = [];
|
|
14
|
+
|
|
15
|
+
// if (__DEV__) {
|
|
16
|
+
// middlewares.push(sagaMiddleware);
|
|
17
|
+
// // middlewares.push(sagaMiddleware, logger); // With logger
|
|
18
|
+
// } else {
|
|
19
|
+
middlewares.push(sagaMiddleware); // without logger
|
|
20
|
+
// }
|
|
21
|
+
|
|
22
|
+
export const Store = configureStore({
|
|
23
|
+
reducer: rootReducer,
|
|
24
|
+
middleware: middlewares
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Infer the `RootState` and `AppDispatch` types from the store itself
|
|
28
|
+
export type RootState = ReturnType<typeof Store.getState>;
|
|
29
|
+
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
|
|
30
|
+
export type AppDispatch = typeof Store.dispatch;
|
|
31
|
+
|
|
32
|
+
export const useAppDispatch: () => AppDispatch = useDispatch;
|
|
33
|
+
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
|
|
34
|
+
// // PersistStore contains all the data from store ----->>>>>
|
|
35
|
+
// export const Persistor = persistStore(Store);
|
|
36
|
+
sagaMiddleware.run(rootSaga); // Run Saga
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux';
|
|
2
|
+
// // import type { RootState, AppDispatch } from '../store/index';
|
|
3
|
+
// // import
|
|
4
|
+
|
|
5
|
+
// export const useAppDispatch = () => useDispatch<AppDispatch>();
|
|
6
|
+
// export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// --------------- LIBRARIES ---------------
|
|
2
|
+
import {put, call, takeEvery, all} from 'redux-saga/effects';
|
|
3
|
+
import {auth, common} from '../../types';
|
|
4
|
+
import * as actions from '../slices';
|
|
5
|
+
import api from '../../api';
|
|
6
|
+
import constants from '../../constants/constants';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const AuthenticateUserRequest = function* AuthenticateUserRequest({
|
|
10
|
+
payload: { resolve, reject, payload, environment },
|
|
11
|
+
}: {
|
|
12
|
+
payload: any;
|
|
13
|
+
environment: string;
|
|
14
|
+
}) {
|
|
15
|
+
try {
|
|
16
|
+
const response: common.ResponseGenerator = yield call(
|
|
17
|
+
api.auth.authenticateUser,
|
|
18
|
+
{
|
|
19
|
+
payload,
|
|
20
|
+
environment
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
if (Number(response.code) === -1) {
|
|
24
|
+
throw new Error("Session Expire");
|
|
25
|
+
} else if (Number(response.code) === 0) {
|
|
26
|
+
throw new Error(response.message);
|
|
27
|
+
}
|
|
28
|
+
yield put(actions.authenticateUserSuccess(response));
|
|
29
|
+
resolve(response);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
yield put(
|
|
32
|
+
actions.authenticateUserError(
|
|
33
|
+
error instanceof Error
|
|
34
|
+
? error?.message
|
|
35
|
+
: "Something went wrong"
|
|
36
|
+
)
|
|
37
|
+
);
|
|
38
|
+
reject(error);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
function* authSaga() {
|
|
43
|
+
yield all([
|
|
44
|
+
takeEvery(actions.authenticateUserRequest, AuthenticateUserRequest),
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default authSaga;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// src/store/slices/authSlice.ts
|
|
2
|
+
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
3
|
+
import { auth } from "../../types";
|
|
4
|
+
|
|
5
|
+
// Initial state for the auth slice
|
|
6
|
+
const initialState: auth.UsersStateType = {
|
|
7
|
+
clientSource: "default",
|
|
8
|
+
mode: "",
|
|
9
|
+
user: {
|
|
10
|
+
data: {} as auth.UserType,
|
|
11
|
+
isLoading: false,
|
|
12
|
+
errors: "",
|
|
13
|
+
platform: "ios",
|
|
14
|
+
},
|
|
15
|
+
isUserLoggedIn: false,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// Define the auth slice
|
|
19
|
+
const authSlice = createSlice({
|
|
20
|
+
name: "auth",
|
|
21
|
+
initialState,
|
|
22
|
+
reducers: {
|
|
23
|
+
authenticateUserRequest: (
|
|
24
|
+
state: auth.UsersStateType,
|
|
25
|
+
action: PayloadAction<any>
|
|
26
|
+
) => {
|
|
27
|
+
state.user.isLoading = true;
|
|
28
|
+
state.user.errors = "";
|
|
29
|
+
},
|
|
30
|
+
authenticateUserSuccess: (
|
|
31
|
+
state: auth.UsersStateType,
|
|
32
|
+
action: PayloadAction<any>
|
|
33
|
+
) => {
|
|
34
|
+
state.user.isLoading = false;
|
|
35
|
+
state.user.data = action.payload.data;
|
|
36
|
+
// setUserAttributes(action.payload.data);
|
|
37
|
+
// localStorage.setItem(
|
|
38
|
+
// LOCAL_STORAGE.AUTH_TOKEN,
|
|
39
|
+
// action.payload.data?.token
|
|
40
|
+
// );
|
|
41
|
+
// localStorage.setItem(
|
|
42
|
+
// LOCAL_STORAGE.USER_INFO,
|
|
43
|
+
// JSON.stringify(action.payload.data)
|
|
44
|
+
// );
|
|
45
|
+
state.isUserLoggedIn = true;
|
|
46
|
+
},
|
|
47
|
+
authenticateUserError: (
|
|
48
|
+
state: auth.UsersStateType,
|
|
49
|
+
{ payload: error }: PayloadAction<string>
|
|
50
|
+
) => {
|
|
51
|
+
state.user.isLoading = false;
|
|
52
|
+
state.user.errors = error;
|
|
53
|
+
},
|
|
54
|
+
setClientSource: (
|
|
55
|
+
state: auth.UsersStateType,
|
|
56
|
+
action: PayloadAction<any>
|
|
57
|
+
) => {
|
|
58
|
+
let clientSource =
|
|
59
|
+
action.payload ||
|
|
60
|
+
// localStorage.getItem(LOCAL_STORAGE.CLIENT_SOURCE) ||
|
|
61
|
+
"default";
|
|
62
|
+
state.clientSource = clientSource;
|
|
63
|
+
},
|
|
64
|
+
setMode: (state: auth.UsersStateType, action: PayloadAction<any>) => {
|
|
65
|
+
// let mode =
|
|
66
|
+
// action.payload || localStorage.getItem(LOCAL_STORAGE.MODE) || "";
|
|
67
|
+
// state.mode = mode;
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Export actions and reducer
|
|
73
|
+
export const {
|
|
74
|
+
authenticateUserRequest,
|
|
75
|
+
authenticateUserSuccess,
|
|
76
|
+
authenticateUserError,
|
|
77
|
+
setClientSource,
|
|
78
|
+
setMode,
|
|
79
|
+
} = authSlice.actions;
|
|
80
|
+
|
|
81
|
+
export default authSlice.reducer;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {combineReducers} from 'redux';
|
|
2
|
+
|
|
3
|
+
import authSlice from './authSlice';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
let appReducer = combineReducers({
|
|
7
|
+
Auth: authSlice,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// export all action
|
|
11
|
+
export * from './authSlice';
|
|
12
|
+
|
|
13
|
+
const rootReducer = (state: any, action: any) => {
|
|
14
|
+
if (action?.type === 'drawer/logoutUserSuccess') {
|
|
15
|
+
state = {
|
|
16
|
+
Auth: {
|
|
17
|
+
user: {
|
|
18
|
+
data: undefined,
|
|
19
|
+
isLoading: false,
|
|
20
|
+
errors: '',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return appReducer(state, action);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default rootReducer;
|