@eohjsc/react-native-smart-city 0.3.11 → 0.3.12
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.js +2 -0
- package/package.json +1 -1
- package/src/commons/Device/HistoryChart.js +2 -2
- package/src/configs/SCConfig.js +1 -1
- package/src/context/actionType.ts +2 -0
- package/src/context/reducer.ts +10 -0
- package/src/hooks/useReceiveNotifications.js +12 -18
- package/src/screens/Unit/Detail.js +1 -1
- package/src/screens/Unit/Summaries.js +1 -1
package/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import NotificationStack from './src/navigations/NotificationStack';
|
|
|
17
17
|
import MyPinnedSharedUnit from './src/commons/Dashboard/MyPinnedSharedUnit';
|
|
18
18
|
import MyUnit from './src/commons/Dashboard/MyUnit';
|
|
19
19
|
import SharedUnit from './src/commons/Unit/SharedUnit';
|
|
20
|
+
import { Action } from './src/context/actionType';
|
|
20
21
|
|
|
21
22
|
export {
|
|
22
23
|
AddSubUnitStack,
|
|
@@ -40,4 +41,5 @@ export {
|
|
|
40
41
|
SharedUnit,
|
|
41
42
|
MyUnit,
|
|
42
43
|
SCWrapper,
|
|
44
|
+
Action,
|
|
43
45
|
};
|
package/package.json
CHANGED
|
@@ -234,7 +234,7 @@ const HistoryChart = memo(
|
|
|
234
234
|
)}
|
|
235
235
|
<DateTimePickerModal
|
|
236
236
|
isVisible={eventPicker.showModalStart}
|
|
237
|
-
date={eventPicker.startTime
|
|
237
|
+
date={eventPicker.startTime?._d}
|
|
238
238
|
mode={formatType || 'datetime'}
|
|
239
239
|
onConfirm={onConfirmStart}
|
|
240
240
|
onCancel={onCancel}
|
|
@@ -244,7 +244,7 @@ const HistoryChart = memo(
|
|
|
244
244
|
/>
|
|
245
245
|
<DateTimePickerModal
|
|
246
246
|
isVisible={eventPicker.showModalEnd}
|
|
247
|
-
date={eventPicker.endTime
|
|
247
|
+
date={eventPicker.endTime?._d}
|
|
248
248
|
mode={formatType || 'datetime'}
|
|
249
249
|
onConfirm={onConfirmEnd}
|
|
250
250
|
onCancel={onCancel}
|
package/src/configs/SCConfig.js
CHANGED
|
@@ -112,7 +112,7 @@ export class SCConfig {
|
|
|
112
112
|
|
|
113
113
|
export const initSCConfig = (config) => {
|
|
114
114
|
api.setBaseURL(config.apiRoot ?? SCDefaultConfig.apiRoot);
|
|
115
|
-
LocaleConfig.defaultLocale = config.language;
|
|
115
|
+
LocaleConfig.defaultLocale = config.language ?? SCConfig.language;
|
|
116
116
|
SCConfig.language = config.language ?? SCConfig.language;
|
|
117
117
|
SCConfig.apiRoot = config.apiRoot ?? SCDefaultConfig.apiRoot;
|
|
118
118
|
SCConfig.GOOGLE_MAP_API_KEY =
|
|
@@ -21,6 +21,7 @@ export const Action = {
|
|
|
21
21
|
SET_GOOGLE_HOME_CONNECTIONS: 'SET_GOOGLE_HOME_CONNECTIONS',
|
|
22
22
|
CHANGE_GOOGLE_HOME_CONN_STATE: 'CHANGE_GOOGLE_HOME_CONN_STATE',
|
|
23
23
|
UPDATE_VALUE_EVALUATIONS: 'UPDATE_VALUE_EVALUATIONS',
|
|
24
|
+
ON_RECEIVE_NOTIFICATION: 'ON_RECEIVE_NOTIFICATION',
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
export type AuthData = {
|
|
@@ -77,6 +78,7 @@ export type AppType = {
|
|
|
77
78
|
isBluetoothEnabled: boolean;
|
|
78
79
|
isNetworkConnected: boolean;
|
|
79
80
|
camera_opened: any[];
|
|
81
|
+
notificationData: any;
|
|
80
82
|
};
|
|
81
83
|
|
|
82
84
|
export type IoTType = {
|
package/src/context/reducer.ts
CHANGED
|
@@ -59,6 +59,7 @@ export const initialState = {
|
|
|
59
59
|
isBluetoothEnabled: false,
|
|
60
60
|
isNetworkConnected: false,
|
|
61
61
|
camera_opened: [],
|
|
62
|
+
notificationData: null,
|
|
62
63
|
},
|
|
63
64
|
iot: {
|
|
64
65
|
googlehome: {
|
|
@@ -318,6 +319,15 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
318
319
|
),
|
|
319
320
|
};
|
|
320
321
|
|
|
322
|
+
case Action.ON_RECEIVE_NOTIFICATION:
|
|
323
|
+
return {
|
|
324
|
+
...currentState,
|
|
325
|
+
app: {
|
|
326
|
+
...currentState.app,
|
|
327
|
+
notificationData: payload,
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
|
|
321
331
|
default:
|
|
322
332
|
return currentState;
|
|
323
333
|
}
|
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
import { useEffect, useState
|
|
2
|
-
import
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useSCContextSelector } from '../context';
|
|
3
3
|
|
|
4
4
|
const useReceiveNotifications = (callBack) => {
|
|
5
|
-
const [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
setDataNofitication(additionalData);
|
|
10
|
-
}, []);
|
|
5
|
+
const [dataNotification, setDataNotification] = useState(null);
|
|
6
|
+
const notificationData = useSCContextSelector(
|
|
7
|
+
(state) => state.app.notificationData
|
|
8
|
+
);
|
|
11
9
|
|
|
12
10
|
useEffect(() => {
|
|
13
|
-
|
|
14
|
-
(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
callBack && callBack();
|
|
19
|
-
}
|
|
20
|
-
);
|
|
21
|
-
}, [callBack, onReceived]);
|
|
11
|
+
if (notificationData) {
|
|
12
|
+
setDataNotification(notificationData);
|
|
13
|
+
callBack && callBack();
|
|
14
|
+
}
|
|
15
|
+
}, [callBack, notificationData]);
|
|
22
16
|
|
|
23
|
-
return {
|
|
17
|
+
return { dataNotification };
|
|
24
18
|
};
|
|
25
19
|
|
|
26
20
|
export default useReceiveNotifications;
|