-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
361 lines (292 loc) · 14.4 KB
/
Copy pathApp.js
File metadata and controls
361 lines (292 loc) · 14.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
/*
Main file that is run very first apfet application launched
Created By - Mukul agarwal
Created on - 24th Feb 2023
*/
import React, { useState, useEffect, useRef, createRef } from "react";
// import { useIsFocused } from '@react-navigation/native';
import { StyleSheet, Text, View, SafeAreaView, LogBox } from 'react-native';
// Imports for using Redux
import { Provider } from "react-redux";
import { Store } from './Src/Redux/Store';
import { MenuProvider } from 'react-native-popup-menu';
// imports for new date picker as on 22nd Jan 2024
import { LocalizationProvider } from '@mui/x-date-pickers'; //added on 22th Jan 2024 by Mukul
// import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment' //added on 22th Jan 2024 by Mukul
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs' //added on 22th Jan 2024 by Mukul
LogBox.ignoreLogs([
"Require cycle:",
'VirtualizedLists should never be nested',
'Warning: Cannot update during an existing state transition',
'Each child in a list should have a unique "key" prop.', // This warning should be control properly by code
]);
import { StatusBar } from 'expo-status-bar';
import NetInfo from "@react-native-community/netinfo";
// import LogInScreen from './Src/Screens/Login';
import * as myEnums from "./Src/Utils/CommonEnum";
import AppNavigator from './Src/Navigation/AppNavigator';
import SingletonClass from './Src/Utils/SingletonClass';
import { CommonVarCls } from "./Src/Utils";
import SessionUtil from './Src/Utils/SessionUtil';
import MyLoader from './Src/Modules/MyLoader';
import CustomAlert from './Src/Modules/CustomAlert';
import CustomConfirmation from './Src/Modules/CustomConfirmation';
// Resident registration dialogs
import AddPatientNHSDialogGlobal from "./Src/Modules/AddPatientNHSDialogGlobal";
import PDSDetailsDialogGlobal from "./Src/Modules/PDSDetailsDialogGlobal";
import ReviewPatientInformationDialogGlobal from "./Src/Modules/ReviewPatientInformationDialogGlobal";
// import StaffSaveUpdateDialog from "./Src/Modules/Staff/StaffSaveUpdateDialog"; // Dialog used to search new staff id for register and save/update new staff
import StaffSaveUpdateDialogWrapper from "./Src/Modules/Staff/StaffSaveUpdateDialog"; // added by harsh on 30/july/2024
import WardSaveUpdateDialog from "./Src/Modules/Ward/WardSaveUpdateDialog"; // Dialog used to add/update ward
import WardFormSelectionDialog from "./Src/Modules/Ward/WardFormSelectionDialog"; // Dialog used to add Patient and Clinical forms in Ward save/update dialog
import VideoCallingDialog from './Src/Modules/VideoMeeting/VideoCallingDialog'; // Dialog used for showing the video for video calling
import EmailDialog from "./Src/Modules/EmailDialog";
import PendingTaskDialog from "./Src/Modules/PendingTaskDialog";
import ChooseInputForm from "./Src/Modules/QuestionBuilder/ChooseInputForm";
import ImageCropperDialog from "./Src/Components/ImageCropper/ImageCropperDialog";
import CareTeamSaveUpdateDialog from "./Src/Modules/CareTeamSaveUpdateDialog";
import ChangeUserCredentialsDialogGlobal from "./Src/Modules/ChangeUserCredentialsDialogGlobal";
import StaffProfileViewDialog from "./Src/Modules/StaffProfileViewDialog"; //Dialog to show Users Profile in View Mode
import CareTeamSaveUpdateDialogWrapper from "./Src/Modules/CareTeamSaveUpdateDialog";
import PatientAssessmentDialog from "./Src/Modules/PatientAssessmentDialog";
import AppHeaderNotificationMenu from "./Src/Components/AppHeaderNotificationMenu";
import PatientReviewDialog from "./Src/Modules/PatientReview/PatientReviewDialog";
import ChatScreenDialog from "./Src/Screens/ChatScreenDialog";
import AsyncStorage from "@react-native-async-storage/async-storage";
import 'react-native-url-polyfill/auto';
// Add a global reference object in application for session component
let globalDialogRefCount = 1;
global.global_session_ref = globalDialogRefCount++;
global.global_loader_ref = globalDialogRefCount++;
global.globalAlertRef = globalDialogRefCount++;
global.globalConfirmationRef = globalDialogRefCount++;
global.globalPendingDialogRef = globalDialogRefCount++;
global.globalEmailDialogRef = globalDialogRefCount++;
global.globalReadMoreDialogRef = globalDialogRefCount++;
global.globalAddPatientNHSDialogGlobalRef = globalDialogRefCount++;
global.globalPDSDetailsDialogGlobalRef = globalDialogRefCount++;
global.globalReviewPatientInformationDialogGlobalRef = globalDialogRefCount++;
global.globalChooseInputFormDialogGlobalRef = globalDialogRefCount++;
global.ImageCropperRef = globalDialogRefCount++;
global.globalWardSaveUpdateDialogRef = globalDialogRefCount++;
global.globalWardFormSelectionDialogRef = globalDialogRefCount++;
global.globalChangeUserCredentialsDialogGlobalRef = globalDialogRefCount++;
global.globalStaffProfileViewDialogRef = globalDialogRefCount++;
// Init the global variable
export const initGlobalVariables = () => {
global.isFirstTimeCareHomeSetup = null;
// Escalation Pathway control from Soft Signs
global.escalatedNewsFromSoftSign = null;
global.escalatedSBARDFromSoftSign = null;
// Escalation Pathway control from NEWS
global.escalatedSBARDFromNEWS = null;
// Escalation Pathway control from Pava Scale
global.escalatedNewsFromPavaScale = null;
global.escalatedSBARDFromPavaScale = null;
// global.escalatedNewsFromEmergency = null;
global.userProfileFromUserList = false;
global.sosResidentsList = null; // to be check
global.reloadResidentProfile = false;
global.allCommonTerms = null;
global.residentLatestProfileReced = false;
global.notificationMessage = null;
global.showAlertOverSession = false;
global.isEdited = null;
}
// console.log = function () { } // Hide this line to see consoles. Uncomment this line when publish production or beta
//import Constants from 'expo-constants';//added by arfin on 10-Oct-2024 for env check
//const EXPO_PUBLIC_API_URL = Constants.manifest.extra.EXPO_PUBLIC_API_URL; //added by arfin on 10-Oct-2024 for env check
const App = () => {
//console.log(EXPO_PUBLIC_API_URL);//added by arfin on 10-Oct-2024 for env check
//start added by arfin ali on 10-oct-2024
/* This is used if user open developer tools this will pause the the execution by ittirating same function */
// (function () {
// let devtoolsOpen = false;
// const detectDevTools = () => {
// const start = performance.now();
// debugger; // This will pause execution if devtools are open
// const end = performance.now();
// const timeTaken = end - start;
// if (timeTaken > 100) { // Arbitrary threshold for debugger detection
// if (!devtoolsOpen) {
// devtoolsOpen = true;
// //alert("Warning: Developer tools are open! Please close them to continue using the application.");
// // Add custom logic here if needed, like logging or redirecting
// }
// } else {
// if (devtoolsOpen) {
// devtoolsOpen = false;
// console.log("Developer tools are closed");
// }
// }
// };
// setInterval(detectDevTools, 1000); // Check every second
// })();
//End
//added by arfin ali on 10-Oct-2024
/* This function cleared the console in every 10 sec if the developer tools is open*/
// (function () {
// // Overriding console functions
// const emptyFunction = () => {};
// console.log = emptyFunction;
// console.warn = emptyFunction;
// console.error = emptyFunction;
// console.info = emptyFunction;
// console.debug = emptyFunction;
// // Clear the console every time someone tries to type something
// const clearConsoleInput = () => {
// if (typeof console.clear === "function") {
// console.clear(); // Clears the console
// }
// };
// // Clear the console at regular intervals
// setInterval(clearConsoleInput, 1000); // Clear every second
// // Detect if someone tries to type in the console and clear
// window.addEventListener('keydown', function (e) {
// if (e.key === 'F12' || (e.ctrlKey && e.shiftKey && e.key === 'I')) {
// setTimeout(clearConsoleInput, 100); // Clear after opening devtools
// }
// });
// })();
// const Focused = useIsFocused()
let networkConnHandler;
// const dropZoneRef = useRef(null);
// global.globalWardSaveUpdateDialogRef = useRef(null);
// useEffect(() => {
// // You can now access the ref to the DropZoneEmptyComponent
// // console.log('dropZoneRef ref', dropZoneRef.current);
// console.log('Dialog ref', globalWardSaveUpdateDialogRef.current);
// }, [dropZoneRef.current, globalWardSaveUpdateDialogRef.current]);
initGlobalVariables();
useEffect(() => {
// Subscribe
networkConnHandler = NetInfo.addEventListener(state => {
// console.log('Subscribing net info')
handleFirstConnectivityChange(state)
});
return () => {
// componentwillunmount in functional component.
// console.log('App.js useEffect componentwillunmount')
// backHandler.remove();
}
}, [])
// useEffect(() => {
// initializeFCM();
// }, [])
const handleFirstConnectivityChange = (networkState) => {
SingletonClass.instance.setNetworkState(networkState)
return true;
};
// Register the service worker
const registerServiceWorker = async () => {
if ('serviceWorker' in navigator) {
try {
const registration = await navigator.serviceWorker.register('./firebase-messaging-sw.js');
console.log('Service Worker registered with scope:', registration.scope);
return true;
} catch (error) {
console.error('Service Worker registration failed:', error);
return false;
}
}
return false;
};
// Request notification permission
const requestNotificationPermission = async () => {
try {
const permission = await Notification.requestPermission();
if (permission === 'granted') {
console.log('Notification permission granted.');
const token = await getToken(messaging, { vapidKey: vapidKey });
console.log('FCM Token:', token);
// Send the token to your server to save it
} else {
console.log('Unable to get permission to notify.');
}
} catch (error) {
console.error('Error getting permission', error);
}
};
const initializeFCM = async () => {
const swRegistered = await registerServiceWorker();
if (swRegistered) {
await requestNotificationPermission();
// Handle incoming messages
onMessage(messaging, (payload) => {
console.log('Message received. ', payload);
// Customize notification here
const notificationTitle = payload.notification.title;
const notificationOptions = {
body: payload.notification.body,
icon: payload.notification.icon,
};
new Notification(notificationTitle, notificationOptions);
});
} else {
console.log('Service Worker registration failed. Notifications may not work as expected.');
}
};
const find_dimesions = (layout) => {
const { x, y, width, height } = layout;
global.screenWidth = width;
global.screenHeight = height;
// console.log("App.js window width = " + global.screenWidth)
// console.log("App.js window height = " + global.screenHeight)
}
return (
// LocalizationProvider added on 22th nov 2023 by sani to render MUI date pickers
<Provider store={Store}>
<LocalizationProvider dateAdapter={AdapterDayjs}>
<SafeAreaView
style={styles.container}
onLayout={(event) => { find_dimesions(event.nativeEvent.layout) }}
>
{/* <MenuProvider> added by Mukul on 26th Dec 2023 to show the Context menu lib menu popup over the full screen, see the best example in AppHeaderBar.js */}
<MenuProvider>
<SessionUtil ref={(ref) => (global_session_ref = ref)} />
<MyLoader ref={(ref) => (global_loader_ref = ref)} />
<CustomAlert ref={(ref) => (globalAlertRef = ref)} />
<CustomConfirmation ref={(ref) => (globalConfirmationRef = ref)} />
<VideoCallingDialog ref={CommonVarCls.globalVideoCallingDialogRef} />
<ChatScreenDialog ref={CommonVarCls.globalChatScreenDialogRef} />
{/* NHS Dialog */}
<AddPatientNHSDialogGlobal ref={(ref) => (globalAddPatientNHSDialogGlobalRef = ref)} />
<PDSDetailsDialogGlobal ref={(ref) => (globalPDSDetailsDialogGlobalRef = ref)} />
<ReviewPatientInformationDialogGlobal ref={(ref) => (globalReviewPatientInformationDialogGlobalRef = ref)} />
<StaffSaveUpdateDialogWrapper ref={CommonVarCls.globalStaffSaveUpdateDialogRef} />
{/* <StaffSaveUpdateDialog ref={(ref) => (globalStaffSaveUpdateDialogRef = ref)} /> */}
{/* globalStaffSaveUpdateDialogRef.showDialogCallback(() => { }, () => { }) */}
<WardSaveUpdateDialog
ref={(ref) => (globalWardSaveUpdateDialogRef = ref)}
// ref={global.globalWardSaveUpdateDialogRef}
// ref={globalWardSaveUpdateDialogRef}
// ref={dropZoneRef}
/>
<EmailDialog ref={(ref) => (globalEmailDialogRef = ref)} />
<WardFormSelectionDialog ref={(ref) => (globalWardFormSelectionDialogRef = ref)} />
{/* Form builder */}
<ChooseInputForm ref={(ref) => (globalChooseInputFormDialogGlobalRef = ref)} />
<ImageCropperDialog ref={(ref) => (ImageCropperRef = ref)} />
<CareTeamSaveUpdateDialogWrapper ref={CommonVarCls.globalCareTeamSaveUpdateDialogRef} />
<PatientAssessmentDialog ref={CommonVarCls.globalPatientAssessmentDialogRef} />
{/* Global Dialogs added by Shubham */}
<ChangeUserCredentialsDialogGlobal ref={(ref) => (globalChangeUserCredentialsDialogGlobalRef = ref)} />
<StaffProfileViewDialog ref={(ref) => (globalStaffProfileViewDialogRef = ref)} />
<AppHeaderNotificationMenu ref={CommonVarCls.globalAlertNotificationDialogRef} />
<PatientReviewDialog ref={CommonVarCls.globalPatientReviewDialogRef} />
{/* <LogInScreen /> */}
<AppNavigator />
</MenuProvider>
</SafeAreaView>
</LocalizationProvider>
</Provider>
)
}
export default App
const styles = StyleSheet.create({
container: {
flex: 1,
// backgroundColor: '#ddd',
// justifyContent: 'center',
},
});