@jescon-technologies/react-native-ui-kit 0.0.14 → 0.0.15
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/index.d.ts +9 -6
- package/index.js +9 -6
- package/package.json +1 -1
- package/src/Common/Global.ts +10 -0
- package/src/Common/NetworkServiceCall.ts +1 -1
- package/src/CommonStyle/ComponentFunctions.tsx +1 -23
- package/src/Custom/CSliderMenu.tsx +10 -0
- package/src/Custom/OUserView.tsx +10 -0
- package/src/CustomComponents/CBackHandler.tsx +1 -1
- package/src/CustomComponents/CContainerView.tsx +38 -0
- package/src/CustomComponents/CDetailView.tsx +235 -0
- package/src/CustomComponents/CFooterView.tsx +86 -0
- package/src/CustomComponents/CNetworkStatus.tsx +172 -0
- package/src/CustomComponents/COverlay.tsx +110 -0
- package/src/CustomComponents/HeaderBlock.tsx +772 -0
- package/src/Handlers/NotificationsContext.tsx +7 -0
- package/src/Handlers/ResponseComponentContext.tsx +56 -0
- package/src/Hoc/HDashboard.tsx +1064 -0
- package/src/Hoc/HIcons.tsx +48 -56
- package/src/Hoc/HShadowButton.tsx +101 -0
- package/src/StaticComponents/SDateTimePicker.tsx +503 -0
- package/src/StaticComponents/SSearchBar.tsx +118 -0
- package/src/Custom/Loader.js +0 -182
- package/src/Layout/LoginLayout.tsx +0 -711
- package/src/Screens/ForgotPassword.tsx +0 -342
- package/src/Screens/Login.tsx +0 -331
- package/src/Screens/Splash.tsx +0 -782
|
@@ -0,0 +1,772 @@
|
|
|
1
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
StyleSheet,
|
|
4
|
+
Text,
|
|
5
|
+
View,
|
|
6
|
+
StatusBar,
|
|
7
|
+
Image,
|
|
8
|
+
TouchableOpacity,
|
|
9
|
+
Modal,
|
|
10
|
+
Dimensions,
|
|
11
|
+
ScrollView,
|
|
12
|
+
Platform,
|
|
13
|
+
DeviceEventEmitter,
|
|
14
|
+
ActivityIndicator,
|
|
15
|
+
FlatList,
|
|
16
|
+
StyleProp,
|
|
17
|
+
ViewStyle,
|
|
18
|
+
DimensionValue,
|
|
19
|
+
} from 'react-native';
|
|
20
|
+
import { Global } from '../Common/Global';
|
|
21
|
+
import CSliderMenu from '../Custom/CSliderMenu';
|
|
22
|
+
import { normalize } from '../CommonStyle/componentStyle';
|
|
23
|
+
import { NotificationContext } from '@jescon-technologies/react-native-ui-kit/src/Handlers/NotificationsContext';
|
|
24
|
+
import moment from 'moment';
|
|
25
|
+
import { ValueCheck } from '../CommonStyle/ComponentFunctions';
|
|
26
|
+
import ABlink from '../Alerts/ABlink';
|
|
27
|
+
import COverlay from '../CustomComponents/COverlay';
|
|
28
|
+
import OUserView from '../Custom/OUserView';
|
|
29
|
+
import CBackHandler from '../CustomComponents/CBackHandler';
|
|
30
|
+
import CNetworkStatus from '../CustomComponents/CNetworkStatus';
|
|
31
|
+
import CModalOverlay from '../CustomComponents/CModalOverlay';
|
|
32
|
+
import { useNavigation } from '../Navigation/useNavigation';
|
|
33
|
+
import NetworkServiceCall from '../Common/NetworkServiceCall';
|
|
34
|
+
import HIcons from '../Hoc/HIcons';
|
|
35
|
+
import ResponseComponentContext from '../Handlers/ResponseComponentContext';
|
|
36
|
+
|
|
37
|
+
// import HelpdeskScreenFocus from '../Helpdesk/View/HelpdeskScreenFocus';
|
|
38
|
+
// import CHelpdeskView from '../Helpdesk/View/CHelpdeskView';
|
|
39
|
+
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Types
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
interface HeaderBlockProps {
|
|
45
|
+
style?: StyleProp<ViewStyle>;
|
|
46
|
+
backhandler?: unknown;
|
|
47
|
+
consultation?: unknown;
|
|
48
|
+
callback?: (goBack: boolean) => void;
|
|
49
|
+
webview?: unknown;
|
|
50
|
+
data?: unknown;
|
|
51
|
+
navigation?: (route: string, params?: object) => void;
|
|
52
|
+
APIURL?: string;
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface NotificationItem {
|
|
57
|
+
status?: boolean;
|
|
58
|
+
heading?: string;
|
|
59
|
+
content?: string;
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface ResponseContextValue {
|
|
64
|
+
responseJSON: unknown;
|
|
65
|
+
setResponseJSON: (value: unknown) => void;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface NetworkResponse<T = unknown> {
|
|
69
|
+
httpstatus: number;
|
|
70
|
+
data: T;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface NotificationsPayload {
|
|
74
|
+
data?: NotificationItem[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface UserDataLite {
|
|
78
|
+
suuser?: number;
|
|
79
|
+
username?: string;
|
|
80
|
+
department?: string;
|
|
81
|
+
[key: string]: unknown;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// `COverlay(OUserView)` shape — typed manually
|
|
85
|
+
type OverlayComponent = React.ComponentType<{
|
|
86
|
+
visibility: (val?: boolean) => void;
|
|
87
|
+
}>;
|
|
88
|
+
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// Styles
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
|
|
93
|
+
const styles = StyleSheet.create({
|
|
94
|
+
container: {
|
|
95
|
+
// `Platform.OS != 'web' && '7%'` yields `false` on web — invalid
|
|
96
|
+
// DimensionValue. Applied at usage site via conditional spread.
|
|
97
|
+
backgroundColor: Global.AppTheme.primary_color,
|
|
98
|
+
justifyContent: 'center',
|
|
99
|
+
paddingLeft: normalize(3),
|
|
100
|
+
marginTop: StatusBar.currentHeight,
|
|
101
|
+
zIndex: 9999,
|
|
102
|
+
},
|
|
103
|
+
headerContent: {
|
|
104
|
+
flexDirection: 'row',
|
|
105
|
+
alignItems: 'center',
|
|
106
|
+
marginBottom: normalize(6),
|
|
107
|
+
paddingBottom: normalize(0),
|
|
108
|
+
},
|
|
109
|
+
backButton: {
|
|
110
|
+
flexDirection: 'row',
|
|
111
|
+
alignItems: 'center',
|
|
112
|
+
borderWidth: 0,
|
|
113
|
+
},
|
|
114
|
+
logoContainer: {
|
|
115
|
+
width: normalize(100),
|
|
116
|
+
height: normalize(40),
|
|
117
|
+
},
|
|
118
|
+
betaContainer: {
|
|
119
|
+
position: 'absolute',
|
|
120
|
+
bottom: normalize(-4),
|
|
121
|
+
right: normalize(-70),
|
|
122
|
+
},
|
|
123
|
+
betaText: {
|
|
124
|
+
color: '#ffffff',
|
|
125
|
+
fontSize: normalize(20),
|
|
126
|
+
letterSpacing: 5,
|
|
127
|
+
fontWeight: 'bold',
|
|
128
|
+
textShadowColor: '#000000',
|
|
129
|
+
textShadowOffset: { width: 0.5, height: 0.5 },
|
|
130
|
+
textShadowRadius: 0.5,
|
|
131
|
+
},
|
|
132
|
+
versionText: {
|
|
133
|
+
color: 'white',
|
|
134
|
+
fontSize: normalize(8),
|
|
135
|
+
},
|
|
136
|
+
userInfoButton: {
|
|
137
|
+
flexDirection: 'row',
|
|
138
|
+
borderWidth: 0,
|
|
139
|
+
flex: 1,
|
|
140
|
+
justifyContent: 'flex-start',
|
|
141
|
+
},
|
|
142
|
+
userInfoContainer: {
|
|
143
|
+
borderWidth: 0,
|
|
144
|
+
},
|
|
145
|
+
userNameText: {
|
|
146
|
+
fontWeight: 'bold',
|
|
147
|
+
fontSize: normalize(13),
|
|
148
|
+
marginLeft: 5,
|
|
149
|
+
color: 'white',
|
|
150
|
+
},
|
|
151
|
+
departmentText: {
|
|
152
|
+
fontFamily: Global.fontNormal,
|
|
153
|
+
fontSize: normalize(11),
|
|
154
|
+
marginLeft: 5,
|
|
155
|
+
color: 'white',
|
|
156
|
+
},
|
|
157
|
+
rightIconsContainer: {
|
|
158
|
+
flexDirection: 'row',
|
|
159
|
+
alignItems: 'center',
|
|
160
|
+
justifyContent: 'flex-end',
|
|
161
|
+
borderWidth: 0,
|
|
162
|
+
},
|
|
163
|
+
notificationButton: {
|
|
164
|
+
margin: normalize(10),
|
|
165
|
+
},
|
|
166
|
+
notificationBadge: {
|
|
167
|
+
position: 'absolute',
|
|
168
|
+
right: normalize(-2),
|
|
169
|
+
top: normalize(-2),
|
|
170
|
+
backgroundColor: 'white',
|
|
171
|
+
alignItems: 'center',
|
|
172
|
+
borderRadius: 20,
|
|
173
|
+
width: normalize(15),
|
|
174
|
+
},
|
|
175
|
+
notificationCount: {
|
|
176
|
+
fontSize: normalize(7),
|
|
177
|
+
fontWeight: 'bold',
|
|
178
|
+
},
|
|
179
|
+
menuButton: {
|
|
180
|
+
alignItems: 'center',
|
|
181
|
+
justifyContent: 'center',
|
|
182
|
+
},
|
|
183
|
+
loginTimeText: {
|
|
184
|
+
fontSize: normalize(9),
|
|
185
|
+
marginLeft: 0,
|
|
186
|
+
color: 'white',
|
|
187
|
+
},
|
|
188
|
+
jsonModalContainer: {
|
|
189
|
+
backgroundColor: 'white',
|
|
190
|
+
borderWidth: 1,
|
|
191
|
+
height: Dimensions.get('screen').height * 0.9,
|
|
192
|
+
alignSelf: 'center',
|
|
193
|
+
width: Dimensions.get('screen').width * 0.9,
|
|
194
|
+
},
|
|
195
|
+
closeButton: {
|
|
196
|
+
textAlign: 'right',
|
|
197
|
+
fontWeight: 'bold',
|
|
198
|
+
color: 'black',
|
|
199
|
+
},
|
|
200
|
+
jsonText: {
|
|
201
|
+
fontSize: normalize(10),
|
|
202
|
+
color: 'black',
|
|
203
|
+
fontFamily: 'Courier New',
|
|
204
|
+
},
|
|
205
|
+
iconBtn: {
|
|
206
|
+
width: normalize(32),
|
|
207
|
+
height: normalize(32),
|
|
208
|
+
borderRadius: normalize(16),
|
|
209
|
+
backgroundColor: 'rgba(255,255,255,0.12)',
|
|
210
|
+
alignItems: 'center',
|
|
211
|
+
justifyContent: 'center',
|
|
212
|
+
},
|
|
213
|
+
badge: {
|
|
214
|
+
position: 'absolute',
|
|
215
|
+
right: normalize(-1),
|
|
216
|
+
top: normalize(-1),
|
|
217
|
+
backgroundColor: '#FF5252',
|
|
218
|
+
borderRadius: normalize(8),
|
|
219
|
+
minWidth: normalize(15),
|
|
220
|
+
height: normalize(15),
|
|
221
|
+
alignItems: 'center',
|
|
222
|
+
justifyContent: 'center',
|
|
223
|
+
zIndex: 1,
|
|
224
|
+
paddingHorizontal: 3,
|
|
225
|
+
},
|
|
226
|
+
badgeText: {
|
|
227
|
+
color: 'white',
|
|
228
|
+
fontSize: normalize(8),
|
|
229
|
+
fontWeight: 'bold',
|
|
230
|
+
},
|
|
231
|
+
modalContainer: {
|
|
232
|
+
width: Platform.OS === 'web' ? 360 : '90%',
|
|
233
|
+
maxWidth: 400,
|
|
234
|
+
backgroundColor: '#FFFFFF',
|
|
235
|
+
borderRadius: normalize(12),
|
|
236
|
+
overflow: 'hidden',
|
|
237
|
+
shadowColor: '#000',
|
|
238
|
+
shadowOffset: { width: 0, height: 4 },
|
|
239
|
+
shadowOpacity: 0.25,
|
|
240
|
+
shadowRadius: 10,
|
|
241
|
+
elevation: 8,
|
|
242
|
+
},
|
|
243
|
+
modalHeader: {
|
|
244
|
+
flexDirection: 'row',
|
|
245
|
+
alignItems: 'center',
|
|
246
|
+
justifyContent: 'space-between',
|
|
247
|
+
paddingHorizontal: normalize(14),
|
|
248
|
+
paddingVertical: normalize(12),
|
|
249
|
+
borderBottomWidth: 1,
|
|
250
|
+
borderBottomColor: '#F0F0F0',
|
|
251
|
+
backgroundColor: '#FAFBFD',
|
|
252
|
+
},
|
|
253
|
+
modalTitle: {
|
|
254
|
+
fontSize: normalize(14),
|
|
255
|
+
fontWeight: 'bold',
|
|
256
|
+
color: '#094485',
|
|
257
|
+
},
|
|
258
|
+
modalBadge: {
|
|
259
|
+
backgroundColor: '#FF5252',
|
|
260
|
+
borderRadius: normalize(10),
|
|
261
|
+
paddingHorizontal: normalize(6),
|
|
262
|
+
paddingVertical: normalize(1),
|
|
263
|
+
marginLeft: normalize(6),
|
|
264
|
+
},
|
|
265
|
+
modalBadgeText: {
|
|
266
|
+
color: '#FFFFFF',
|
|
267
|
+
fontSize: normalize(10),
|
|
268
|
+
fontWeight: 'bold',
|
|
269
|
+
},
|
|
270
|
+
closeBtn: {
|
|
271
|
+
padding: normalize(4),
|
|
272
|
+
},
|
|
273
|
+
notifCard: {
|
|
274
|
+
flexDirection: 'row',
|
|
275
|
+
padding: normalize(12),
|
|
276
|
+
borderBottomWidth: 1,
|
|
277
|
+
borderBottomColor: '#F4F5F7',
|
|
278
|
+
alignItems: 'flex-start',
|
|
279
|
+
},
|
|
280
|
+
notifIconCircle: {
|
|
281
|
+
width: normalize(30),
|
|
282
|
+
height: normalize(30),
|
|
283
|
+
borderRadius: normalize(15),
|
|
284
|
+
backgroundColor: '#EBF3FB',
|
|
285
|
+
alignItems: 'center',
|
|
286
|
+
justifyContent: 'center',
|
|
287
|
+
marginRight: normalize(10),
|
|
288
|
+
marginTop: normalize(2),
|
|
289
|
+
},
|
|
290
|
+
notifHeading: {
|
|
291
|
+
fontSize: normalize(12),
|
|
292
|
+
fontWeight: 'bold',
|
|
293
|
+
color: '#1A202C',
|
|
294
|
+
marginBottom: normalize(2),
|
|
295
|
+
},
|
|
296
|
+
notifContent: {
|
|
297
|
+
fontSize: normalize(11),
|
|
298
|
+
color: '#4A5568',
|
|
299
|
+
lineHeight: normalize(15),
|
|
300
|
+
},
|
|
301
|
+
notifCodeText: {
|
|
302
|
+
fontSize: normalize(9),
|
|
303
|
+
color: '#A0AEC0',
|
|
304
|
+
marginTop: normalize(3),
|
|
305
|
+
},
|
|
306
|
+
modalFooter: {
|
|
307
|
+
borderTopWidth: 1,
|
|
308
|
+
borderTopColor: '#F0F0F0',
|
|
309
|
+
paddingVertical: normalize(10),
|
|
310
|
+
paddingHorizontal: normalize(14),
|
|
311
|
+
backgroundColor: '#FAFBFD',
|
|
312
|
+
alignItems: 'center',
|
|
313
|
+
},
|
|
314
|
+
viewAllBtn: {
|
|
315
|
+
flexDirection: 'row',
|
|
316
|
+
alignItems: 'center',
|
|
317
|
+
},
|
|
318
|
+
viewAllText: {
|
|
319
|
+
fontSize: normalize(12),
|
|
320
|
+
fontWeight: '600',
|
|
321
|
+
color: '#094485',
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
/** Platform-conditional `height: '7%'` (was the inline-invalid-value bug). */
|
|
326
|
+
const containerPlatformHeight: ViewStyle =
|
|
327
|
+
Platform.OS !== 'web' ? { height: '7%' as DimensionValue } : {};
|
|
328
|
+
|
|
329
|
+
// ---------------------------------------------------------------------------
|
|
330
|
+
// Component
|
|
331
|
+
// ---------------------------------------------------------------------------
|
|
332
|
+
|
|
333
|
+
const HeaderBlock: React.FC<HeaderBlockProps> = (props) => {
|
|
334
|
+
const { responseJSON, setResponseJSON } = useContext(
|
|
335
|
+
ResponseComponentContext
|
|
336
|
+
) as ResponseContextValue;
|
|
337
|
+
|
|
338
|
+
const [isShowSlidermenu, setIsShowSlidermenu] = useState<boolean>(false);
|
|
339
|
+
const [backHandler, setBackHandler] = useState<boolean>(false);
|
|
340
|
+
const [backHandlerLogOut, setBackHandlerLogOut] = useState<boolean>(false);
|
|
341
|
+
const [refresh] = useState<number>(0);
|
|
342
|
+
const [overlay, setOverlay] = useState<boolean>(false);
|
|
343
|
+
const [jsonoverlay, setJsonOverlay] = useState<boolean>(false);
|
|
344
|
+
const navigation = useNavigation();
|
|
345
|
+
const [notificationList, setNotificationList] = useState<NotificationItem[]>([]);
|
|
346
|
+
const [unreadCount, setUnreadCount] = useState<number>(0);
|
|
347
|
+
const [showNotificationModal, setShowNotificationModal] = useState<boolean>(false);
|
|
348
|
+
const [isLoadingNotifications, setIsLoadingNotifications] = useState<boolean>(false);
|
|
349
|
+
|
|
350
|
+
const OverlayHOCComponent = COverlay(OUserView) as unknown as OverlayComponent;
|
|
351
|
+
|
|
352
|
+
const NoticationData = React.useContext(NotificationContext) as NotificationItem[];
|
|
353
|
+
|
|
354
|
+
const result = NoticationData.filter((obj) => obj.status === true);
|
|
355
|
+
|
|
356
|
+
const fetchNotifications = (): void => {
|
|
357
|
+
const userData = Global.userData as UserDataLite | null | undefined;
|
|
358
|
+
if (userData && userData.suuser) {
|
|
359
|
+
setIsLoadingNotifications(true);
|
|
360
|
+
const url =
|
|
361
|
+
APIURL + 'invget/invcommonget/rnhrsumessageuserretrievaljson ' + userData.suuser;
|
|
362
|
+
NetworkServiceCall('get', url)
|
|
363
|
+
.then((response: NetworkResponse<NotificationItem[] | NotificationsPayload>) => {
|
|
364
|
+
setIsLoadingNotifications(false);
|
|
365
|
+
if (response && response.httpstatus == 200) {
|
|
366
|
+
let dataArr: NotificationItem[] = [];
|
|
367
|
+
const data = response.data as NotificationsPayload | NotificationItem[];
|
|
368
|
+
if (
|
|
369
|
+
data &&
|
|
370
|
+
!Array.isArray(data) &&
|
|
371
|
+
Array.isArray((data as NotificationsPayload).data)
|
|
372
|
+
) {
|
|
373
|
+
dataArr = (data as NotificationsPayload).data!;
|
|
374
|
+
} else if (Array.isArray(data)) {
|
|
375
|
+
dataArr = data;
|
|
376
|
+
}
|
|
377
|
+
setNotificationList(dataArr);
|
|
378
|
+
setUnreadCount(dataArr.length);
|
|
379
|
+
} else {
|
|
380
|
+
setNotificationList([]);
|
|
381
|
+
setUnreadCount(0);
|
|
382
|
+
}
|
|
383
|
+
})
|
|
384
|
+
.catch((err: unknown) => {
|
|
385
|
+
setIsLoadingNotifications(false);
|
|
386
|
+
console.log('Error fetching notifications in HeaderBlock:', err);
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
useEffect(() => {
|
|
392
|
+
fetchNotifications();
|
|
393
|
+
const sub = DeviceEventEmitter.addListener('refresh_notifications', fetchNotifications);
|
|
394
|
+
return () => {
|
|
395
|
+
sub?.remove?.();
|
|
396
|
+
};
|
|
397
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
398
|
+
}, []);
|
|
399
|
+
|
|
400
|
+
const goBack = (): void => {
|
|
401
|
+
Global.PatientDetails = null;
|
|
402
|
+
if (ValueCheck(props.backhandler)) {
|
|
403
|
+
if (ValueCheck(props.consultation) && Global.EditStatus == 1) {
|
|
404
|
+
setBackHandler(true);
|
|
405
|
+
} else {
|
|
406
|
+
console.log('props.backhandler', props.backhandler);
|
|
407
|
+
navigation.goBack();
|
|
408
|
+
}
|
|
409
|
+
} else {
|
|
410
|
+
navigation.goBack();
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
const OnPressGoBack = (): void => {
|
|
415
|
+
Global.PatientDetails = null;
|
|
416
|
+
if (props.callback) {
|
|
417
|
+
props.callback(true);
|
|
418
|
+
} else {
|
|
419
|
+
goBack();
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
const renderJsonModal = (): React.ReactElement => (
|
|
424
|
+
<Modal
|
|
425
|
+
onRequestClose={() => setJsonOverlay(false)}
|
|
426
|
+
style={{
|
|
427
|
+
height: Dimensions.get('screen').height,
|
|
428
|
+
width: Dimensions.get('screen').width,
|
|
429
|
+
backgroundColor: 'transparent',
|
|
430
|
+
justifyContent: 'center',
|
|
431
|
+
alignItems: 'center',
|
|
432
|
+
}}
|
|
433
|
+
transparent={true}
|
|
434
|
+
>
|
|
435
|
+
<View style={styles.jsonModalContainer}>
|
|
436
|
+
<TouchableOpacity onPress={() => setJsonOverlay(false)}>
|
|
437
|
+
<Text style={styles.closeButton}>Close</Text>
|
|
438
|
+
</TouchableOpacity>
|
|
439
|
+
<ScrollView>
|
|
440
|
+
<Text selectable={true} style={styles.jsonText}>
|
|
441
|
+
{JSON.stringify(responseJSON, null, 2)}
|
|
442
|
+
</Text>
|
|
443
|
+
</ScrollView>
|
|
444
|
+
</View>
|
|
445
|
+
</Modal>
|
|
446
|
+
);
|
|
447
|
+
|
|
448
|
+
const renderBetaVersion = (): React.ReactElement => (
|
|
449
|
+
<View style={styles.betaContainer}>
|
|
450
|
+
<ABlink duration={500}>
|
|
451
|
+
<View style={{ justifyContent: 'center', alignItems: 'center' }}>
|
|
452
|
+
<Text style={styles.betaText}>BETA TESTING</Text>
|
|
453
|
+
<Text style={styles.versionText}>
|
|
454
|
+
{Global.version ? `V ${Global.version}` : null}
|
|
455
|
+
</Text>
|
|
456
|
+
</View>
|
|
457
|
+
</ABlink>
|
|
458
|
+
</View>
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
const userData = Global.userData as UserDataLite | null | undefined;
|
|
462
|
+
|
|
463
|
+
const renderUserInfo = (): React.ReactElement => (
|
|
464
|
+
<TouchableOpacity
|
|
465
|
+
onPress={() => (props.webview != undefined ? null : setOverlay(true))}
|
|
466
|
+
style={styles.userInfoButton}
|
|
467
|
+
>
|
|
468
|
+
<View style={styles.userInfoContainer}>
|
|
469
|
+
<Text adjustsFontSizeToFit numberOfLines={2} style={styles.userNameText}>
|
|
470
|
+
{props.webview != undefined
|
|
471
|
+
? ''
|
|
472
|
+
: userData && userData.department != undefined && userData.department != ''
|
|
473
|
+
? userData.username
|
|
474
|
+
: ''}
|
|
475
|
+
</Text>
|
|
476
|
+
{userData &&
|
|
477
|
+
userData.department != undefined &&
|
|
478
|
+
userData.department != '' &&
|
|
479
|
+
props.webview == undefined ? (
|
|
480
|
+
<Text adjustsFontSizeToFit style={styles.departmentText}>
|
|
481
|
+
{userData.department}
|
|
482
|
+
</Text>
|
|
483
|
+
) : null}
|
|
484
|
+
</View>
|
|
485
|
+
</TouchableOpacity>
|
|
486
|
+
);
|
|
487
|
+
|
|
488
|
+
const renderRightIcons = (): React.ReactElement => (
|
|
489
|
+
<View style={styles.rightIconsContainer}>
|
|
490
|
+
{Platform.OS === 'web' && (
|
|
491
|
+
<TouchableOpacity
|
|
492
|
+
onPress={() => DeviceEventEmitter.emit('helpdesk.toggle')}
|
|
493
|
+
style={[
|
|
494
|
+
styles.iconBtn,
|
|
495
|
+
{ flexDirection: 'row', width: 'auto', paddingHorizontal: normalize(8) },
|
|
496
|
+
]}
|
|
497
|
+
>
|
|
498
|
+
<HIcons.FontAwesome5
|
|
499
|
+
name="question-circle"
|
|
500
|
+
size={normalize(12)}
|
|
501
|
+
color="white"
|
|
502
|
+
style={{ marginRight: normalize(4) }}
|
|
503
|
+
/>
|
|
504
|
+
<Text
|
|
505
|
+
style={{ color: 'white', fontSize: normalize(10), fontWeight: 'bold' }}
|
|
506
|
+
>
|
|
507
|
+
HELP
|
|
508
|
+
</Text>
|
|
509
|
+
</TouchableOpacity>
|
|
510
|
+
)}
|
|
511
|
+
<CNetworkStatus />
|
|
512
|
+
<TouchableOpacity
|
|
513
|
+
onPress={() => {
|
|
514
|
+
fetchNotifications();
|
|
515
|
+
setShowNotificationModal(true);
|
|
516
|
+
}}
|
|
517
|
+
style={styles.notificationButton}
|
|
518
|
+
>
|
|
519
|
+
<ABlink>
|
|
520
|
+
<View
|
|
521
|
+
style={[
|
|
522
|
+
styles.notificationBadge,
|
|
523
|
+
{ backgroundColor: result.length > 0 ? 'red' : 'white' },
|
|
524
|
+
]}
|
|
525
|
+
>
|
|
526
|
+
<Text
|
|
527
|
+
numberOfLines={1}
|
|
528
|
+
adjustsFontSizeToFit
|
|
529
|
+
style={[
|
|
530
|
+
styles.notificationCount,
|
|
531
|
+
{ color: result.length > 0 ? 'white' : 'black' },
|
|
532
|
+
]}
|
|
533
|
+
>
|
|
534
|
+
{result.length}
|
|
535
|
+
</Text>
|
|
536
|
+
</View>
|
|
537
|
+
</ABlink>
|
|
538
|
+
|
|
539
|
+
<HIcons.Ionicons name="notifications-outline" size={normalize(18)} color="white" />
|
|
540
|
+
{unreadCount > 0 && (
|
|
541
|
+
<View style={styles.badge}>
|
|
542
|
+
<Text style={styles.badgeText}>
|
|
543
|
+
{unreadCount > 99 ? '99+' : unreadCount}
|
|
544
|
+
</Text>
|
|
545
|
+
</View>
|
|
546
|
+
)}
|
|
547
|
+
</TouchableOpacity>
|
|
548
|
+
<View style={{ paddingLeft: normalize(2) }}>
|
|
549
|
+
<TouchableOpacity
|
|
550
|
+
onPress={() => setIsShowSlidermenu(true)}
|
|
551
|
+
style={styles.menuButton}
|
|
552
|
+
>
|
|
553
|
+
<HIcons.Feather name={'menu'} color="white" size={normalize(25)} />
|
|
554
|
+
<View>
|
|
555
|
+
{Global.LoginTime != undefined ? (
|
|
556
|
+
<Text style={styles.loginTimeText}>
|
|
557
|
+
{moment.duration(moment().diff(Global.LoginTime)).asMinutes().toFixed(0) +
|
|
558
|
+
' Min.'}
|
|
559
|
+
</Text>
|
|
560
|
+
) : null}
|
|
561
|
+
</View>
|
|
562
|
+
</TouchableOpacity>
|
|
563
|
+
</View>
|
|
564
|
+
</View>
|
|
565
|
+
);
|
|
566
|
+
|
|
567
|
+
const renderNotificationContent = (): React.ReactElement => (
|
|
568
|
+
<View style={styles.modalContainer}>
|
|
569
|
+
<View style={styles.modalHeader}>
|
|
570
|
+
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
571
|
+
<HIcons.Ionicons
|
|
572
|
+
name="notifications"
|
|
573
|
+
size={normalize(18)}
|
|
574
|
+
color="#094485"
|
|
575
|
+
style={{ marginRight: normalize(6) }}
|
|
576
|
+
/>
|
|
577
|
+
<Text style={styles.modalTitle}>Notifications</Text>
|
|
578
|
+
{unreadCount > 0 && (
|
|
579
|
+
<View style={styles.modalBadge}>
|
|
580
|
+
<Text style={styles.modalBadgeText}>{unreadCount}</Text>
|
|
581
|
+
</View>
|
|
582
|
+
)}
|
|
583
|
+
</View>
|
|
584
|
+
<TouchableOpacity
|
|
585
|
+
onPress={() => setShowNotificationModal(false)}
|
|
586
|
+
style={styles.closeBtn}
|
|
587
|
+
>
|
|
588
|
+
<HIcons.Ionicons name="close" size={normalize(20)} color="#666" />
|
|
589
|
+
</TouchableOpacity>
|
|
590
|
+
</View>
|
|
591
|
+
|
|
592
|
+
{isLoadingNotifications ? (
|
|
593
|
+
<View style={{ padding: normalize(20), alignItems: 'center' }}>
|
|
594
|
+
<ActivityIndicator size="small" color="#094485" />
|
|
595
|
+
<Text
|
|
596
|
+
style={{ marginTop: normalize(8), fontSize: normalize(11), color: '#666' }}
|
|
597
|
+
>
|
|
598
|
+
Loading notifications...
|
|
599
|
+
</Text>
|
|
600
|
+
</View>
|
|
601
|
+
) : notificationList && notificationList.length > 0 ? (
|
|
602
|
+
<FlatList<NotificationItem>
|
|
603
|
+
data={notificationList}
|
|
604
|
+
keyExtractor={(_item, index) => 'notif_' + index}
|
|
605
|
+
style={{ maxHeight: normalize(320) }}
|
|
606
|
+
renderItem={({ item }) => (
|
|
607
|
+
<View style={styles.notifCard}>
|
|
608
|
+
<View style={styles.notifIconCircle}>
|
|
609
|
+
<HIcons.Ionicons
|
|
610
|
+
name="chatbox-ellipses-outline"
|
|
611
|
+
size={normalize(16)}
|
|
612
|
+
color="#094485"
|
|
613
|
+
/>
|
|
614
|
+
</View>
|
|
615
|
+
<View style={{ flex: 1 }}>
|
|
616
|
+
<Text style={styles.notifHeading}>
|
|
617
|
+
{item.heading || 'PUBLIC MESSAGE'}
|
|
618
|
+
</Text>
|
|
619
|
+
<Text style={styles.notifContent}>{item.content || ''}</Text>
|
|
620
|
+
</View>
|
|
621
|
+
</View>
|
|
622
|
+
)}
|
|
623
|
+
/>
|
|
624
|
+
) : (
|
|
625
|
+
<View style={{ padding: normalize(24), alignItems: 'center' }}>
|
|
626
|
+
<HIcons.Ionicons
|
|
627
|
+
name="notifications-off-outline"
|
|
628
|
+
size={normalize(32)}
|
|
629
|
+
color="#ccc"
|
|
630
|
+
/>
|
|
631
|
+
<Text
|
|
632
|
+
style={{ marginTop: normalize(8), fontSize: normalize(12), color: '#888' }}
|
|
633
|
+
>
|
|
634
|
+
No new notifications
|
|
635
|
+
</Text>
|
|
636
|
+
</View>
|
|
637
|
+
)}
|
|
638
|
+
</View>
|
|
639
|
+
);
|
|
640
|
+
|
|
641
|
+
const renderNotificationFooter = (): React.ReactElement => (
|
|
642
|
+
<View style={styles.modalFooter}>
|
|
643
|
+
<TouchableOpacity
|
|
644
|
+
style={styles.viewAllBtn}
|
|
645
|
+
onPress={() => {
|
|
646
|
+
setShowNotificationModal(false);
|
|
647
|
+
navigation.navigate('Notifications');
|
|
648
|
+
}}
|
|
649
|
+
>
|
|
650
|
+
<Text style={styles.viewAllText}>View All Notifications</Text>
|
|
651
|
+
<HIcons.Ionicons
|
|
652
|
+
name="arrow-forward"
|
|
653
|
+
size={normalize(14)}
|
|
654
|
+
color="#094485"
|
|
655
|
+
style={{ marginLeft: normalize(4) }}
|
|
656
|
+
/>
|
|
657
|
+
</TouchableOpacity>
|
|
658
|
+
</View>
|
|
659
|
+
);
|
|
660
|
+
|
|
661
|
+
return (
|
|
662
|
+
<View
|
|
663
|
+
style={[styles.container, containerPlatformHeight, props.style]}
|
|
664
|
+
key={refresh}
|
|
665
|
+
>
|
|
666
|
+
{/* <HelpdeskScreenFocus data={props.data} /> */}
|
|
667
|
+
<StatusBar
|
|
668
|
+
translucent
|
|
669
|
+
backgroundColor={Global.AppTheme.primary_color}
|
|
670
|
+
barStyle="light-content"
|
|
671
|
+
/>
|
|
672
|
+
|
|
673
|
+
{jsonoverlay && renderJsonModal()}
|
|
674
|
+
|
|
675
|
+
<View style={styles.headerContent}>
|
|
676
|
+
<TouchableOpacity
|
|
677
|
+
style={styles.backButton}
|
|
678
|
+
onPress={OnPressGoBack}
|
|
679
|
+
onLongPress={goBack}
|
|
680
|
+
>
|
|
681
|
+
<HIcons.Ionicons name={'chevron-back'} color="white" size={normalize(25)} />
|
|
682
|
+
<View style={styles.logoContainer}>
|
|
683
|
+
{Global.betaversion ? (
|
|
684
|
+
<View style={styles.logoContainer} />
|
|
685
|
+
) : (
|
|
686
|
+
<Image
|
|
687
|
+
style={{
|
|
688
|
+
width: normalize(100),
|
|
689
|
+
height: normalize(40),
|
|
690
|
+
resizeMode: 'contain',
|
|
691
|
+
borderRadius: 8,
|
|
692
|
+
}}
|
|
693
|
+
source={{
|
|
694
|
+
uri:
|
|
695
|
+
Global?.HospitalData?.hospitallogo3
|
|
696
|
+
? Global.HospitalData.hospitallogo3
|
|
697
|
+
: undefined,
|
|
698
|
+
}}
|
|
699
|
+
/>
|
|
700
|
+
)}
|
|
701
|
+
</View>
|
|
702
|
+
{Global.betaversion && renderBetaVersion()}
|
|
703
|
+
</TouchableOpacity>
|
|
704
|
+
|
|
705
|
+
{renderUserInfo()}
|
|
706
|
+
|
|
707
|
+
{props.webview != undefined ? null : renderRightIcons()}
|
|
708
|
+
</View>
|
|
709
|
+
|
|
710
|
+
{overlay && (
|
|
711
|
+
<OverlayHOCComponent
|
|
712
|
+
visibility={(val?: boolean) => (val == undefined ? null : setOverlay(val))}
|
|
713
|
+
/>
|
|
714
|
+
)}
|
|
715
|
+
|
|
716
|
+
<CModalOverlay
|
|
717
|
+
visible={showNotificationModal}
|
|
718
|
+
onClose={() => setShowNotificationModal(false)}
|
|
719
|
+
closeOnTouchOutside={true}
|
|
720
|
+
containerStyle={{
|
|
721
|
+
alignItems: 'flex-end',
|
|
722
|
+
justifyContent: 'flex-start',
|
|
723
|
+
paddingTop: Platform.OS === 'web' ? 60 : 50,
|
|
724
|
+
paddingRight: normalize(10),
|
|
725
|
+
}}
|
|
726
|
+
childrenWrapperStyle={styles.modalContainer}
|
|
727
|
+
contentStyle={{ flexGrow: 0 }}
|
|
728
|
+
footer={renderNotificationFooter()}
|
|
729
|
+
footerStyle={{ padding: 0 }}
|
|
730
|
+
>
|
|
731
|
+
{renderNotificationContent()}
|
|
732
|
+
</CModalOverlay>
|
|
733
|
+
|
|
734
|
+
{isShowSlidermenu && (
|
|
735
|
+
<CSliderMenu
|
|
736
|
+
navigation={navigation}
|
|
737
|
+
isShow={isShowSlidermenu}
|
|
738
|
+
visibility={(val?: boolean) =>
|
|
739
|
+
val == undefined ? null : setIsShowSlidermenu(val)
|
|
740
|
+
}
|
|
741
|
+
/>
|
|
742
|
+
)}
|
|
743
|
+
|
|
744
|
+
{backHandler && (
|
|
745
|
+
<CBackHandler
|
|
746
|
+
type={5}
|
|
747
|
+
callBack={(val?: boolean) =>
|
|
748
|
+
val == undefined ? null : (setBackHandler(val), navigation.goBack())
|
|
749
|
+
}
|
|
750
|
+
close={(val?: boolean) => (val == undefined ? null : setBackHandler(val))}
|
|
751
|
+
/>
|
|
752
|
+
)}
|
|
753
|
+
|
|
754
|
+
{backHandlerLogOut && (
|
|
755
|
+
<CBackHandler
|
|
756
|
+
type={6}
|
|
757
|
+
callBack={(val?: boolean) =>
|
|
758
|
+
val == undefined
|
|
759
|
+
? null
|
|
760
|
+
: (setBackHandlerLogOut(val), navigation.goBack())
|
|
761
|
+
}
|
|
762
|
+
close={(val?: boolean) =>
|
|
763
|
+
val == undefined ? null : setBackHandlerLogOut(val)
|
|
764
|
+
}
|
|
765
|
+
/>
|
|
766
|
+
)}
|
|
767
|
+
{/* <CHelpdeskView defaultModuleCode={Global.module} floating={false} /> */}
|
|
768
|
+
</View>
|
|
769
|
+
);
|
|
770
|
+
};
|
|
771
|
+
|
|
772
|
+
export default HeaderBlock;
|