@jescon-technologies/react-native-ui-kit 0.0.19 → 0.0.21
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 +4 -3
- package/index.js +4 -2
- package/package.json +1 -1
- package/src/Common/GlobalContext.tsx +78 -0
- package/src/Common/NetworkServiceCall.ts +197 -229
- package/src/Components/SDropDown.tsx +1 -1
- package/src/Custom/CSliderMenu.tsx +1 -1
- package/src/Custom/Loader.tsx +2 -2
- package/src/CustomComponents/HeaderBlock.tsx +2 -5
- package/src/Hoc/HDashboard.tsx +0 -1
- package/src/Hoc/HProvider.tsx +14 -7
package/index.d.ts
CHANGED
|
@@ -23,10 +23,11 @@ export { default as HeaderBlock } from './src/CustomComponents/HeaderBlock';
|
|
|
23
23
|
export { default as HDashboard } from './src/Hoc/HDashboard';
|
|
24
24
|
export { default as NetworkServiceCall } from './src/Common/NetworkServiceCall';
|
|
25
25
|
export { default as useNotifications } from './src/Handlers/NotificationsContext';
|
|
26
|
-
export { default as
|
|
27
|
-
export
|
|
26
|
+
export { default as CBackHandler } from './src/CustomComponents/CBackHandler';
|
|
27
|
+
export * from './src/Handlers/ResponseComponentContext';
|
|
28
28
|
export * from './src/Navigation/useNavigation';
|
|
29
29
|
export * from './src/Navigation/useIsFocused';
|
|
30
30
|
export * from './src/Navigation/useFocusEffect';
|
|
31
|
-
export { default as CBackHandler } from './src/CustomComponents/CBackHandler';
|
|
32
31
|
export * from './src/CommonStyle/ComponentFunctions';
|
|
32
|
+
export * from '../../../src/Common/apiConstants'
|
|
33
|
+
export * from '../../../src/Common/Global';
|
package/index.js
CHANGED
|
@@ -23,9 +23,11 @@ export { default as HeaderBlock } from './src/CustomComponents/HeaderBlock';
|
|
|
23
23
|
export { default as HDashboard } from './src/Hoc/HDashboard';
|
|
24
24
|
export { default as NetworkServiceCall } from './src/Common/NetworkServiceCall';
|
|
25
25
|
export { default as useNotifications } from './src/Handlers/NotificationsContext';
|
|
26
|
-
export { default as
|
|
26
|
+
export { default as CBackHandler } from './src/CustomComponents/CBackHandler';
|
|
27
|
+
export * from './src/Handlers/ResponseComponentContext';
|
|
27
28
|
export * from './src/Navigation/useNavigation';
|
|
28
29
|
export * from './src/Navigation/useIsFocused';
|
|
29
30
|
export * from './src/Navigation/useFocusEffect';
|
|
30
|
-
export { default as CBackHandler } from './src/CustomComponents/CBackHandler';
|
|
31
31
|
export * from './src/CommonStyle/ComponentFunctions';
|
|
32
|
+
export * from '../../../src/Common/apiConstants'
|
|
33
|
+
export * from '../../../src/Common/Global';
|
package/package.json
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
createContext,
|
|
3
|
+
useContext,
|
|
4
|
+
useEffect,
|
|
5
|
+
useSyncExternalStore,
|
|
6
|
+
} from 'react';
|
|
7
|
+
import type { ReactNode } from 'react';
|
|
8
|
+
|
|
9
|
+
export type GlobalConfig = Record<string, unknown>;
|
|
10
|
+
|
|
11
|
+
interface GlobalStore {
|
|
12
|
+
getSnapshot: () => object;
|
|
13
|
+
subscribe: (listener: () => void) => () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let globalConfig: object = {};
|
|
17
|
+
const listeners = new Set<() => void>();
|
|
18
|
+
|
|
19
|
+
const notifyListeners = (): void => {
|
|
20
|
+
listeners.forEach(listener => listener());
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const globalStore: GlobalStore = {
|
|
24
|
+
getSnapshot: () => globalConfig,
|
|
25
|
+
subscribe: listener => {
|
|
26
|
+
listeners.add(listener);
|
|
27
|
+
return () => listeners.delete(listener);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const GlobalContext = createContext<GlobalStore>(globalStore);
|
|
32
|
+
|
|
33
|
+
export const setGlobal = <T extends object>(config: T): void => {
|
|
34
|
+
globalConfig = config;
|
|
35
|
+
notifyListeners();
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const getGlobal = <
|
|
39
|
+
T extends object = GlobalConfig,
|
|
40
|
+
>(): T => globalConfig as T;
|
|
41
|
+
|
|
42
|
+
export const updateGlobal = <T extends object = GlobalConfig>(
|
|
43
|
+
config: Partial<T>,
|
|
44
|
+
): void => {
|
|
45
|
+
Object.assign(globalConfig, config);
|
|
46
|
+
notifyListeners();
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const useGlobal = <T extends object = GlobalConfig>(): T => {
|
|
50
|
+
const store = useContext(GlobalContext);
|
|
51
|
+
return useSyncExternalStore(
|
|
52
|
+
store.subscribe,
|
|
53
|
+
store.getSnapshot,
|
|
54
|
+
store.getSnapshot,
|
|
55
|
+
) as T;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
interface GlobalProviderProps {
|
|
59
|
+
global?: object;
|
|
60
|
+
children?: ReactNode;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const GlobalProvider: React.FC<GlobalProviderProps> = ({
|
|
64
|
+
global,
|
|
65
|
+
children,
|
|
66
|
+
}) => {
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (global !== undefined) {
|
|
69
|
+
setGlobal(global);
|
|
70
|
+
}
|
|
71
|
+
}, [global]);
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<GlobalContext.Provider value={globalStore}>
|
|
75
|
+
{children}
|
|
76
|
+
</GlobalContext.Provider>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
@@ -1,299 +1,267 @@
|
|
|
1
|
-
import axios
|
|
2
|
-
import {
|
|
3
|
-
import { Global } from '
|
|
4
|
-
;
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { notifyMessage, ValueCheck } from '../CommonStyle/ComponentFunctions';
|
|
3
|
+
import { Global } from '../.../../../../../../src/Common/Global';
|
|
5
4
|
import { Platform } from 'react-native';
|
|
5
|
+
import { networkServiceCall } from 'react-native-electron-platform';
|
|
6
6
|
|
|
7
|
-
//
|
|
8
|
-
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// Types
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
interface AlertData {
|
|
12
|
+
alertCaption: string;
|
|
13
|
+
alertMessage?: string;
|
|
14
|
+
alertContent?: string;
|
|
15
|
+
alertHttpstatus?: number;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
interface ErrorData {
|
|
16
19
|
title: string;
|
|
17
20
|
subtitle: string;
|
|
18
|
-
alertdata:
|
|
19
|
-
alertCaption: string;
|
|
20
|
-
alertMessage: string;
|
|
21
|
-
alertContent: string;
|
|
22
|
-
alertHttpstatus: number;
|
|
23
|
-
};
|
|
21
|
+
alertdata: AlertData;
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
interface ServiceResponse<T = unknown> {
|
|
27
25
|
httpstatus: number;
|
|
28
|
-
data:
|
|
26
|
+
data: T | ErrorData;
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
interface RawHttpPayload {
|
|
30
|
+
httpstatus?: number;
|
|
31
|
+
data?: unknown;
|
|
32
|
+
message?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface ElectronResponse {
|
|
36
|
+
httpstatus: number;
|
|
37
|
+
data: unknown;
|
|
38
|
+
message?: string;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
type
|
|
41
|
-
|
|
41
|
+
type NetworkServiceMethod = 'get' | 'post' | 'multiform' | string;
|
|
42
|
+
|
|
43
|
+
export type NetworkServiceCallFn = <T = unknown>(
|
|
44
|
+
method: NetworkServiceMethod,
|
|
42
45
|
url: string,
|
|
43
|
-
params?:
|
|
46
|
+
params?: unknown,
|
|
44
47
|
jwt?: string,
|
|
45
48
|
timeout?: number
|
|
46
|
-
) => Promise<
|
|
49
|
+
) => Promise<ServiceResponse<T>>;
|
|
50
|
+
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// Helpers
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
function makeErrorResponse(
|
|
56
|
+
httpstatus: number,
|
|
57
|
+
message?: string
|
|
58
|
+
): ServiceResponse<never> {
|
|
59
|
+
return {
|
|
60
|
+
httpstatus,
|
|
61
|
+
data: {
|
|
62
|
+
title: 'ERROR',
|
|
63
|
+
subtitle: '',
|
|
64
|
+
alertdata: {
|
|
65
|
+
alertCaption: 'ERROR',
|
|
66
|
+
alertMessage: message,
|
|
67
|
+
alertContent: message,
|
|
68
|
+
alertHttpstatus: httpstatus,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
47
73
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
// Service call
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
51
77
|
|
|
52
|
-
|
|
78
|
+
const NetworkServiceCall: NetworkServiceCallFn = (
|
|
79
|
+
method,
|
|
80
|
+
url,
|
|
81
|
+
params,
|
|
82
|
+
jwt,
|
|
83
|
+
timeout
|
|
84
|
+
) => {
|
|
85
|
+
const jwtString = ValueCheck(Global.JWTToken) ? Global.JWTToken : jwt;
|
|
86
|
+
// jwtString unused at call sites right now — kept for parity with the
|
|
87
|
+
// original (Authorization header is commented out in every branch).
|
|
88
|
+
void jwtString;
|
|
89
|
+
|
|
90
|
+
console.log('----------------------------- BUTTONAPI -----------------', url);
|
|
91
|
+
|
|
92
|
+
const lowerMethod = method.toLowerCase();
|
|
93
|
+
|
|
94
|
+
// -----------------------------------------------------------------------
|
|
95
|
+
// GET
|
|
96
|
+
// -----------------------------------------------------------------------
|
|
97
|
+
if (lowerMethod === 'get') {
|
|
53
98
|
return axios({
|
|
54
|
-
method: 'get'
|
|
55
|
-
url
|
|
99
|
+
method: 'get',
|
|
100
|
+
url,
|
|
56
101
|
timeout: timeout || 60000,
|
|
102
|
+
// ⚠️ Original used `validateStatus: false`, which makes EVERY response
|
|
103
|
+
// (including 200) reject into `.catch`. That likely broke every GET.
|
|
104
|
+
// Preserved for behavioral parity; change to `() => true` to actually
|
|
105
|
+
// accept 2xx responses via the `.then` path.
|
|
57
106
|
validateStatus: false,
|
|
58
|
-
// headers: {
|
|
59
|
-
// Authorization: `Bearer ${jwtString}`,
|
|
60
|
-
// }
|
|
61
107
|
})
|
|
62
|
-
.then(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
httpstatus: response.data.httpstatus,
|
|
67
|
-
};
|
|
68
|
-
return dataset as NetworkResponse;
|
|
69
|
-
} else {
|
|
70
|
-
dataset = {
|
|
71
|
-
httpstatus: response.data.httpstatus,
|
|
72
|
-
data: {
|
|
73
|
-
title: 'ERROR',
|
|
74
|
-
subtitle: response.data.data !== undefined ? response.data.data.message : '',
|
|
75
|
-
alertdata: {
|
|
76
|
-
alertCaption: 'ERROR',
|
|
77
|
-
alertMessage: response.data.message,
|
|
78
|
-
alertContent: response.data.message,
|
|
79
|
-
alertHttpstatus: response.data.httpstatus,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
return dataset as ErrorResponse;
|
|
108
|
+
.then((response) => {
|
|
109
|
+
const payload = response.data as RawHttpPayload;
|
|
110
|
+
if (payload.httpstatus === 200) {
|
|
111
|
+
return { data: payload.data, httpstatus: payload.httpstatus };
|
|
84
112
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
dataset = {
|
|
88
|
-
httpstatus: 404,
|
|
113
|
+
return {
|
|
114
|
+
httpstatus: payload.httpstatus ?? 0,
|
|
89
115
|
data: {
|
|
90
116
|
title: 'ERROR',
|
|
91
|
-
subtitle:
|
|
117
|
+
subtitle:
|
|
118
|
+
payload.data != undefined
|
|
119
|
+
? (payload.data as { message?: string }).message ?? ''
|
|
120
|
+
: '',
|
|
92
121
|
alertdata: {
|
|
93
122
|
alertCaption: 'ERROR',
|
|
94
|
-
alertMessage:
|
|
95
|
-
alertContent:
|
|
96
|
-
alertHttpstatus:
|
|
123
|
+
alertMessage: payload.message,
|
|
124
|
+
alertContent: payload.message,
|
|
125
|
+
alertHttpstatus: payload.httpstatus,
|
|
97
126
|
},
|
|
98
127
|
},
|
|
99
128
|
};
|
|
100
|
-
|
|
101
|
-
|
|
129
|
+
})
|
|
130
|
+
.catch((error: Error) => makeErrorResponse(404, error.message)) as Promise<
|
|
131
|
+
ServiceResponse
|
|
132
|
+
>;
|
|
102
133
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
};
|
|
115
|
-
return dataset as NetworkResponse;
|
|
116
|
-
} else {
|
|
117
|
-
dataset = {
|
|
118
|
-
httpstatus: response.data.httpstatus,
|
|
119
|
-
data: {
|
|
120
|
-
title: 'ERROR',
|
|
121
|
-
subtitle: '',
|
|
122
|
-
alertdata: {
|
|
123
|
-
alertCaption: 'ERROR',
|
|
124
|
-
alertMessage: response.data.message,
|
|
125
|
-
alertContent: response.data.message,
|
|
126
|
-
alertHttpstatus: response.data.httpstatus,
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
return dataset as ErrorResponse;
|
|
134
|
+
|
|
135
|
+
// -----------------------------------------------------------------------
|
|
136
|
+
// POST — native
|
|
137
|
+
// -----------------------------------------------------------------------
|
|
138
|
+
if (lowerMethod === 'post' && Platform.OS !== 'web') {
|
|
139
|
+
return axios
|
|
140
|
+
.post(url, params)
|
|
141
|
+
.then((response) => {
|
|
142
|
+
const payload = response.data as RawHttpPayload;
|
|
143
|
+
if (payload.httpstatus === 200) {
|
|
144
|
+
return { data: payload.data, httpstatus: payload.httpstatus };
|
|
131
145
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
dataset = {
|
|
135
|
-
httpstatus: 404,
|
|
146
|
+
return {
|
|
147
|
+
httpstatus: payload.httpstatus ?? 0,
|
|
136
148
|
data: {
|
|
137
149
|
title: 'ERROR',
|
|
138
150
|
subtitle: '',
|
|
139
151
|
alertdata: {
|
|
140
152
|
alertCaption: 'ERROR',
|
|
141
|
-
alertMessage:
|
|
142
|
-
alertContent:
|
|
143
|
-
alertHttpstatus:
|
|
153
|
+
alertMessage: payload.message,
|
|
154
|
+
alertContent: payload.message,
|
|
155
|
+
alertHttpstatus: payload.httpstatus,
|
|
144
156
|
},
|
|
145
157
|
},
|
|
146
158
|
};
|
|
147
|
-
|
|
148
|
-
|
|
159
|
+
})
|
|
160
|
+
.catch((error: Error) => makeErrorResponse(404, error.message)) as Promise<
|
|
161
|
+
ServiceResponse
|
|
162
|
+
>;
|
|
149
163
|
}
|
|
150
|
-
|
|
164
|
+
|
|
165
|
+
// -----------------------------------------------------------------------
|
|
166
|
+
// MULTIFORM — native
|
|
167
|
+
// -----------------------------------------------------------------------
|
|
168
|
+
if (lowerMethod === 'multiform' && Platform.OS !== 'web') {
|
|
151
169
|
console.log('JWT STRING', jwtString);
|
|
152
170
|
|
|
153
171
|
return axios({
|
|
154
|
-
url
|
|
172
|
+
url,
|
|
155
173
|
method: 'POST',
|
|
156
174
|
headers: {
|
|
157
175
|
'Content-Type': 'multipart/form-data',
|
|
158
|
-
// Authorization: `Bearer ${jwtString}`,
|
|
159
176
|
},
|
|
160
177
|
data: params,
|
|
161
178
|
})
|
|
162
|
-
.then(
|
|
179
|
+
.then((response) => {
|
|
163
180
|
if (response.status === 200) {
|
|
164
|
-
|
|
165
|
-
data: response.data,
|
|
166
|
-
httpstatus: response.status,
|
|
167
|
-
};
|
|
168
|
-
return dataset as NetworkResponse;
|
|
169
|
-
} else {
|
|
170
|
-
dataset = {
|
|
171
|
-
httpstatus: response.status,
|
|
172
|
-
data: {
|
|
173
|
-
title: 'ERROR',
|
|
174
|
-
subtitle: '',
|
|
175
|
-
alertdata: {
|
|
176
|
-
alertCaption: 'ERROR',
|
|
177
|
-
alertMessage: response.data.message,
|
|
178
|
-
alertContent: response.data.message,
|
|
179
|
-
alertHttpstatus: response.data.httpstatus,
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
};
|
|
183
|
-
return dataset as ErrorResponse;
|
|
181
|
+
return { data: response.data, httpstatus: response.status };
|
|
184
182
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
httpstatus: 404,
|
|
183
|
+
const payload = response.data as RawHttpPayload;
|
|
184
|
+
return {
|
|
185
|
+
httpstatus: response.status,
|
|
189
186
|
data: {
|
|
190
187
|
title: 'ERROR',
|
|
191
188
|
subtitle: '',
|
|
192
189
|
alertdata: {
|
|
193
190
|
alertCaption: 'ERROR',
|
|
194
|
-
alertMessage:
|
|
195
|
-
alertContent:
|
|
196
|
-
alertHttpstatus:
|
|
191
|
+
alertMessage: payload.message,
|
|
192
|
+
alertContent: payload.message,
|
|
193
|
+
alertHttpstatus: payload.httpstatus,
|
|
197
194
|
},
|
|
198
195
|
},
|
|
199
196
|
};
|
|
200
|
-
|
|
201
|
-
|
|
197
|
+
})
|
|
198
|
+
.catch((error: Error) => makeErrorResponse(404, error.message)) as Promise<
|
|
199
|
+
ServiceResponse
|
|
200
|
+
>;
|
|
202
201
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
alertContent: (response as any).message || '',
|
|
224
|
-
alertHttpstatus: response.httpstatus,
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
};
|
|
228
|
-
return dataset as ErrorResponse;
|
|
229
|
-
}
|
|
230
|
-
})
|
|
231
|
-
.catch(function (error: Error): ErrorResponse {
|
|
232
|
-
dataset = {
|
|
233
|
-
httpstatus: 404,
|
|
234
|
-
data: {
|
|
235
|
-
title: 'ERROR',
|
|
236
|
-
subtitle: '',
|
|
237
|
-
alertdata: {
|
|
238
|
-
alertCaption: 'ERROR',
|
|
239
|
-
alertMessage: error.message,
|
|
240
|
-
alertContent: error.message,
|
|
241
|
-
alertHttpstatus: 404,
|
|
242
|
-
},
|
|
202
|
+
|
|
203
|
+
// -----------------------------------------------------------------------
|
|
204
|
+
// POST — web (electron)
|
|
205
|
+
// -----------------------------------------------------------------------
|
|
206
|
+
if (lowerMethod === 'post' && Platform.OS === 'web') {
|
|
207
|
+
return networkServiceCall('post', url, params)
|
|
208
|
+
.then((response: ElectronResponse) => {
|
|
209
|
+
if (response.httpstatus === 200) {
|
|
210
|
+
return { data: response.data, httpstatus: response.httpstatus };
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
httpstatus: response.httpstatus,
|
|
214
|
+
data: {
|
|
215
|
+
title: 'ERROR',
|
|
216
|
+
subtitle: '',
|
|
217
|
+
alertdata: {
|
|
218
|
+
alertCaption: 'ERROR',
|
|
219
|
+
alertMessage: response.message,
|
|
220
|
+
alertContent: response.message,
|
|
221
|
+
alertHttpstatus: response.httpstatus,
|
|
243
222
|
},
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
});
|
|
247
|
-
} else {
|
|
248
|
-
// Fallback to regular axios if electronAPI is not available
|
|
249
|
-
return axios.post(url, params, {
|
|
250
|
-
timeout: timeout || 60000,
|
|
223
|
+
},
|
|
224
|
+
};
|
|
251
225
|
})
|
|
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
|
-
data: {
|
|
280
|
-
title: 'ERROR',
|
|
281
|
-
subtitle: '',
|
|
282
|
-
alertdata: {
|
|
283
|
-
alertCaption: 'ERROR',
|
|
284
|
-
alertMessage: error.message,
|
|
285
|
-
alertContent: error.message,
|
|
286
|
-
alertHttpstatus: 404,
|
|
287
|
-
},
|
|
226
|
+
.catch((error: Error) => makeErrorResponse(404, error.message)) as Promise<
|
|
227
|
+
ServiceResponse
|
|
228
|
+
>;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// -----------------------------------------------------------------------
|
|
232
|
+
// MULTIFORM — web (electron)
|
|
233
|
+
// -----------------------------------------------------------------------
|
|
234
|
+
if (lowerMethod === 'multiform' && Platform.OS === 'web') {
|
|
235
|
+
const headers = {
|
|
236
|
+
'Content-Type': 'multipart/form-data',
|
|
237
|
+
};
|
|
238
|
+
return networkServiceCall('post', url, params, headers)
|
|
239
|
+
.then((response: ElectronResponse) => {
|
|
240
|
+
if (response.httpstatus === 200) {
|
|
241
|
+
return { data: response.data, httpstatus: response.httpstatus };
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
httpstatus: response.httpstatus,
|
|
245
|
+
data: {
|
|
246
|
+
title: 'ERROR',
|
|
247
|
+
subtitle: '',
|
|
248
|
+
alertdata: {
|
|
249
|
+
alertCaption: 'ERROR',
|
|
250
|
+
alertMessage: response.message,
|
|
251
|
+
alertContent: response.message,
|
|
252
|
+
alertHttpstatus: response.httpstatus,
|
|
288
253
|
},
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
})
|
|
257
|
+
.catch((error: Error) => makeErrorResponse(404, error.message)) as Promise<
|
|
258
|
+
ServiceResponse
|
|
259
|
+
>;
|
|
293
260
|
}
|
|
294
261
|
|
|
295
|
-
//
|
|
296
|
-
|
|
262
|
+
// Unknown method — original fell through and returned `undefined`
|
|
263
|
+
console.warn(`NetworkServiceCall: unsupported method "${method}"`);
|
|
264
|
+
return Promise.resolve(makeErrorResponse(400, `Unsupported method: ${method}`));
|
|
297
265
|
};
|
|
298
266
|
|
|
299
267
|
export default NetworkServiceCall;
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
ViewStyle,
|
|
15
15
|
TextStyle,
|
|
16
16
|
} from 'react-native';
|
|
17
|
-
import { APIURL } from '
|
|
17
|
+
import { APIURL } from '@jescon-technologies/react-native-ui-kit';
|
|
18
18
|
import Loader from '../Custom/Loader';
|
|
19
19
|
import { isBNU, isBNUL, isNU, normalize } from '../CommonStyle/ComponentFunctions';
|
|
20
20
|
import NetworkServiceCall from '../Common/NetworkServiceCall';
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import { normalize} from '../CommonStyle/ComponentFunctions';
|
|
12
12
|
import RNExitApp from 'react-native-exit-app';
|
|
13
13
|
import { Global, GlobalUserData } from '../../../../../src/Common/Global';
|
|
14
|
-
import { imageURL } from '
|
|
14
|
+
import { imageURL } from '@jescon-technologies/react-native-ui-kit';
|
|
15
15
|
import { useNavigation } from '../Navigation/useNavigation';
|
|
16
16
|
import CModalOverlay from '../CustomComponents/CModalOverlay';
|
|
17
17
|
import HIcons from '../Hoc/HIcons';
|
package/src/Custom/Loader.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
TextStyle,
|
|
14
14
|
} from 'react-native';
|
|
15
15
|
import { normalize} from '../CommonStyle/ComponentFunctions';
|
|
16
|
-
import {
|
|
16
|
+
import { imageURL } from '@jescon-technologies/react-native-ui-kit';
|
|
17
17
|
|
|
18
18
|
// ---------------------------------------------------------------------------
|
|
19
19
|
// Types
|
|
@@ -45,7 +45,7 @@ export default function Loader({
|
|
|
45
45
|
overlayColor = 'rgba(0,0,0,0.4)',
|
|
46
46
|
loaderColor = 'lightblue',
|
|
47
47
|
size = Platform.OS !== 'web' ? 30 : 50,
|
|
48
|
-
gifSource = { uri: `${
|
|
48
|
+
gifSource = { uri: `${imageURL}heartpulse.gif` },
|
|
49
49
|
message = '',
|
|
50
50
|
messageStyle = {},
|
|
51
51
|
animationType = 'fade',
|
|
@@ -33,7 +33,7 @@ import NetworkServiceCall from '../Common/NetworkServiceCall';
|
|
|
33
33
|
import HIcons from '../Hoc/HIcons';
|
|
34
34
|
import ResponseComponentContext from '../Handlers/ResponseComponentContext';
|
|
35
35
|
import { Global } from '../../../../../src/Common/Global';
|
|
36
|
-
import {
|
|
36
|
+
import { notifyURL } from '../../../../../src/Common/apiConstants';
|
|
37
37
|
|
|
38
38
|
// import HelpdeskScreenFocus from '../Helpdesk/View/HelpdeskScreenFocus';
|
|
39
39
|
// import CHelpdeskView from '../Helpdesk/View/CHelpdeskView';
|
|
@@ -50,7 +50,6 @@ interface HeaderBlockProps {
|
|
|
50
50
|
webview?: unknown;
|
|
51
51
|
data?: unknown;
|
|
52
52
|
navigation?: (route: string, params?: object) => void;
|
|
53
|
-
APIURL?: string;
|
|
54
53
|
[key: string]: unknown;
|
|
55
54
|
}
|
|
56
55
|
|
|
@@ -358,9 +357,7 @@ const HeaderBlock: React.FC<HeaderBlockProps> = (props) => {
|
|
|
358
357
|
const userData = Global.userData as UserDataLite | null | undefined;
|
|
359
358
|
if (userData && userData.suuser) {
|
|
360
359
|
setIsLoadingNotifications(true);
|
|
361
|
-
|
|
362
|
-
APIURL + 'invget/invcommonget/rnhrsumessageuserretrievaljson ' + userData.suuser;
|
|
363
|
-
NetworkServiceCall('get', url)
|
|
360
|
+
NetworkServiceCall('get',`${notifyURL} ${userData.suuser}`)
|
|
364
361
|
.then((response: NetworkResponse<NotificationItem[] | NotificationsPayload>) => {
|
|
365
362
|
setIsLoadingNotifications(false);
|
|
366
363
|
if (response && response.httpstatus == 200) {
|
package/src/Hoc/HDashboard.tsx
CHANGED
|
@@ -32,7 +32,6 @@ import HShadowButton from './HShadowButton';
|
|
|
32
32
|
import HIcons from './HIcons';
|
|
33
33
|
import { normalize} from '../CommonStyle/ComponentFunctions';
|
|
34
34
|
import { Global } from '../../../../../src/Common/Global';
|
|
35
|
-
;
|
|
36
35
|
import SDateTimePicker from '../StaticComponents/SDateTimePicker';
|
|
37
36
|
|
|
38
37
|
// ---------------------------------------------------------------------------
|
package/src/Hoc/HProvider.tsx
CHANGED
|
@@ -2,20 +2,27 @@ import React from 'react';
|
|
|
2
2
|
import HView from '../Hoc/HView';
|
|
3
3
|
import Navigation from '../Navigation/PageNavigation';
|
|
4
4
|
import ErrorBoundary from '../Common/ErrorBoundary';
|
|
5
|
+
import { GlobalProvider } from '../Common/GlobalContext';
|
|
5
6
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
6
7
|
|
|
7
8
|
interface HProviderProps {
|
|
8
9
|
components: Record<string, React.ComponentType<any>>;
|
|
9
10
|
screens: any;
|
|
11
|
+
Global?: object;
|
|
12
|
+
global?: object;
|
|
10
13
|
}
|
|
11
14
|
export default function HProvider(props: HProviderProps) {
|
|
15
|
+
const global = props.Global ?? props.global;
|
|
16
|
+
|
|
12
17
|
return (
|
|
13
|
-
<
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
<GlobalProvider global={global}>
|
|
19
|
+
<SafeAreaView style={{ flex: 1 }}>
|
|
20
|
+
<ErrorBoundary>
|
|
21
|
+
<HView components={props.components}>
|
|
22
|
+
<Navigation screens={props.screens} />
|
|
23
|
+
</HView>
|
|
24
|
+
</ErrorBoundary>
|
|
25
|
+
</SafeAreaView>
|
|
26
|
+
</GlobalProvider>
|
|
20
27
|
);
|
|
21
28
|
}
|