@eohjsc/react-native-smart-city 0.3.37 → 0.3.39
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/package.json +1 -1
- package/src/commons/AlertAction/index.js +5 -1
- package/src/commons/Device/ItemDevice.js +21 -34
- package/src/commons/Form/TextInput.js +9 -1
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +6 -3
- package/src/commons/WrapParallaxScrollView/index.js +6 -1
- package/src/configs/API.js +1 -1
- package/src/configs/AccessibilityLabel.js +13 -1
- package/src/configs/Constants.js +9 -12
- package/src/context/actionType.ts +4 -0
- package/src/context/mockStore.ts +3 -0
- package/src/context/reducer.ts +17 -0
- package/src/hooks/Common/index.js +0 -2
- package/src/hooks/Common/useDevicesStatus.js +26 -28
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +3 -0
- package/src/hooks/IoT/index.js +8 -0
- package/src/hooks/IoT/useBluetoothConnection.js +27 -0
- package/src/hooks/IoT/useBluetoothDeviceConnected.js +18 -0
- package/src/hooks/IoT/useEoHBackendDeviceConnected.js +21 -0
- package/src/hooks/{Common → IoT}/useHomeAssistantDeviceConnected.js +0 -0
- package/src/hooks/IoT/useRemoteControl.js +8 -19
- package/src/iot/RemoteControl/Bluetooth.js +5 -12
- package/src/iot/RemoteControl/__test__/Bluetooth.test.js +19 -63
- package/src/navigations/UnitStack.js +11 -1
- package/src/screens/AddCommon/SelectSubUnit.js +3 -0
- package/src/screens/AddLocationMaps/index.js +1 -0
- package/src/screens/AddNewGateway/ConnectingWifiDevice.js +4 -2
- package/src/screens/AddNewGateway/ConnectingWifiGuide.js +5 -4
- package/src/screens/AddNewGateway/RenameNewDevices.js +7 -6
- package/src/screens/AddNewGateway/ScanGatewayQR.js +2 -6
- package/src/screens/AddNewGateway/ScanWifiDeviceQR.js +1 -4
- package/src/screens/AddNewGateway/ShareWifiPassword.js +4 -2
- package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +1 -0
- package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +14 -9
- package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +29 -1
- package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +1 -1
- package/src/screens/AddNewGateway/__test__/ScanWifiDeviceQR.test.js +1 -1
- package/src/screens/ConfirmUnitDeletion/index.js +6 -1
- package/src/screens/Device/__test__/detail.test.js +1 -0
- package/src/screens/Device/detail.js +53 -59
- package/src/screens/Notification/__test__/NotificationItem.test.js +44 -40
- package/src/screens/Notification/components/NotificationItem.js +134 -141
- package/src/screens/SmartAccount/Connecting/index.js +3 -0
- package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +6 -2
- package/src/screens/SmartAccount/ListDevice/index.js +17 -12
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +61 -7
- package/src/screens/SmartAccount/SuccessfullyConnected/index.js +102 -27
- package/src/screens/SmartAccount/SuccessfullyConnected/styles.js +58 -1
- package/src/screens/SmartAccount/__test__/Connecting.test.js +3 -0
- package/src/screens/SubUnit/AddSubUnit.js +5 -1
- package/src/screens/Unit/MoreMenu.js +3 -3
- package/src/screens/Unit/SelectAddress.js +1 -0
- package/src/screens/Unit/components/MyUnitDevice/index.js +1 -1
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +11 -8
- package/src/screens/UnitSummary/__test__/index.test.js +38 -2
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +1 -1
- package/src/screens/UnitSummary/components/RunningDevices/index.js +3 -17
- package/src/screens/UnitSummary/index.js +6 -1
- package/src/utils/Apis/axios.js +1 -0
- package/src/utils/__test__/Utils.test.js +19 -1
- package/src/screens/SmartAccount/SuccessfullyConnected/DeviceItem.js +0 -37
- package/src/screens/SmartAccount/SuccessfullyConnected/DeviceItemStyles.js +0 -49
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/DeviceItem.test.js +0 -65
|
@@ -7,59 +7,57 @@ import React, {
|
|
|
7
7
|
useContext,
|
|
8
8
|
} from 'react';
|
|
9
9
|
import { View, TouchableOpacity, Platform } from 'react-native';
|
|
10
|
-
import {
|
|
11
|
-
import moment from 'moment';
|
|
12
|
-
import { get } from 'lodash';
|
|
10
|
+
import { useNavigation } from '@react-navigation/native';
|
|
13
11
|
import { useSelector } from 'react-redux';
|
|
14
12
|
import { IconFill, IconOutline } from '@ant-design/icons-react-native';
|
|
15
13
|
import { Icon } from '@ant-design/react-native';
|
|
16
|
-
import
|
|
14
|
+
import moment from 'moment';
|
|
15
|
+
import { get } from 'lodash';
|
|
16
|
+
|
|
17
|
+
import { SCContext } from '../../context';
|
|
18
|
+
import { Action } from '../../context/actionType';
|
|
19
|
+
import { useSCContextSelector } from '../../context';
|
|
20
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
17
21
|
import { useCountUp } from './hooks/useCountUp';
|
|
18
|
-
import { getData as getLocalData } from '../../utils/Storage';
|
|
19
|
-
import { API, Colors } from '../../configs';
|
|
20
|
-
import { axiosGet } from '../../utils/Apis/axios';
|
|
21
|
-
import {
|
|
22
|
-
isDeviceConnected,
|
|
23
|
-
scanBluetoothDevices,
|
|
24
|
-
} from '../../iot/RemoteControl/Bluetooth';
|
|
25
|
-
import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
|
|
26
|
-
import { getActionComponent } from '../../commons/ActionGroup';
|
|
27
|
-
import { AlertSendConfirm } from '../../commons/EmergencyButton/AlertSendConfirm';
|
|
28
|
-
import { AlertSent } from '../../commons/EmergencyButton/AlertSent';
|
|
29
22
|
import {
|
|
30
23
|
useAlertResolveEmergency,
|
|
31
24
|
useEmergencyButton,
|
|
32
25
|
} from './hooks/useEmergencyButton';
|
|
33
26
|
import { useFavoriteDevice } from './hooks/useFavoriteDevice';
|
|
34
|
-
import BottomButtonView from '../../commons/BottomButtonView';
|
|
35
|
-
import Text from '../../commons/Text';
|
|
36
|
-
import { AlertAction, ButtonPopup, MenuActionMore } from '../../commons';
|
|
37
|
-
import { DEVICE_TYPE, AccessibilityLabel } from '../../configs/Constants';
|
|
38
|
-
import { SCContext } from '../../context';
|
|
39
|
-
import { Action } from '../../context/actionType';
|
|
40
|
-
|
|
41
27
|
import { usePopover } from '../../hooks/Common';
|
|
42
28
|
import { useConfigGlobalState } from '../../iot/states';
|
|
43
|
-
import {
|
|
44
|
-
import styles from './styles';
|
|
45
|
-
import {
|
|
46
|
-
useIsOwnerOfUnit,
|
|
47
|
-
useBoolean,
|
|
48
|
-
useHomeAssistantDeviceConnected,
|
|
49
|
-
} from '../../hooks/Common';
|
|
29
|
+
import { useIsOwnerOfUnit, useBoolean } from '../../hooks/Common';
|
|
50
30
|
import {
|
|
31
|
+
useBluetoothConnection,
|
|
51
32
|
useHomeAssistantConnection,
|
|
52
33
|
useValueEvaluations,
|
|
34
|
+
useBluetoothDeviceConnected,
|
|
35
|
+
useHomeAssistantDeviceConnected,
|
|
36
|
+
useEoHBackendDeviceConnected,
|
|
53
37
|
} from '../../hooks/IoT';
|
|
54
|
-
import { SensorDisplayItem } from './components/SensorDisplayItem';
|
|
55
|
-
import { useSCContextSelector } from '../../context';
|
|
56
|
-
import { EmergencyCountdown } from './components/EmergencyCountdown';
|
|
57
|
-
import { SensorConnectStatusViewHeader } from './components/SensorConnectStatusViewHeader';
|
|
58
38
|
import { useDisconnectedDevice } from './hooks/useDisconnectedDevice';
|
|
59
39
|
import { useEvaluateValue } from './hooks/useEvaluateValue';
|
|
60
40
|
import { useDeviceWatchConfigControl } from './hooks/useDeviceWatchConfigControl';
|
|
41
|
+
|
|
42
|
+
import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
|
|
43
|
+
import { getActionComponent } from '../../commons/ActionGroup';
|
|
44
|
+
import { AlertSendConfirm } from '../../commons/EmergencyButton/AlertSendConfirm';
|
|
45
|
+
import { AlertSent } from '../../commons/EmergencyButton/AlertSent';
|
|
46
|
+
import BottomButtonView from '../../commons/BottomButtonView';
|
|
47
|
+
import Text from '../../commons/Text';
|
|
48
|
+
import { AlertAction, ButtonPopup, MenuActionMore } from '../../commons';
|
|
49
|
+
import { SensorDisplayItem } from './components/SensorDisplayItem';
|
|
50
|
+
import { EmergencyCountdown } from './components/EmergencyCountdown';
|
|
51
|
+
import { SensorConnectStatusViewHeader } from './components/SensorConnectStatusViewHeader';
|
|
61
52
|
import { Card } from '../../commons/CardShadow';
|
|
62
53
|
import PreventAccess from '../../commons/PreventAccess';
|
|
54
|
+
|
|
55
|
+
import styles from './styles';
|
|
56
|
+
import Routes from '../../utils/Route';
|
|
57
|
+
import { getData as getLocalData } from '../../utils/Storage';
|
|
58
|
+
import { API, Colors } from '../../configs';
|
|
59
|
+
import { DEVICE_TYPE, AccessibilityLabel } from '../../configs/Constants';
|
|
60
|
+
import { axiosGet } from '../../utils/Apis/axios';
|
|
63
61
|
import { notImplemented } from '../../utils/Utils';
|
|
64
62
|
|
|
65
63
|
const DeviceDetail = ({ route }) => {
|
|
@@ -102,20 +100,17 @@ const DeviceDetail = ({ route }) => {
|
|
|
102
100
|
const isNetworkConnected = useSCContextSelector(
|
|
103
101
|
(state) => state.app.isNetworkConnected
|
|
104
102
|
);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
|
|
104
|
+
const { isConnected: isEoHBackendConnected } =
|
|
105
|
+
useEoHBackendDeviceConnected(sensor);
|
|
106
|
+
|
|
108
107
|
const {
|
|
109
108
|
isConnected: isHomeAssistantConnected,
|
|
110
109
|
isConnecting: isHomeAssistantConnecting,
|
|
111
110
|
} = useHomeAssistantDeviceConnected(sensor);
|
|
112
111
|
|
|
113
|
-
const
|
|
114
|
-
()
|
|
115
|
-
isBluetoothEnabled &&
|
|
116
|
-
isDeviceConnected(sensor?.remote_control_options?.bluetooth?.address),
|
|
117
|
-
[sensor, isBluetoothEnabled]
|
|
118
|
-
);
|
|
112
|
+
const { isConnected: isBluetoothConnected } =
|
|
113
|
+
useBluetoothDeviceConnected(sensor);
|
|
119
114
|
|
|
120
115
|
const isDeviceHasBle = useMemo(() => {
|
|
121
116
|
const action = display.items.filter((item) => item.type === 'action');
|
|
@@ -183,6 +178,8 @@ const DeviceDetail = ({ route }) => {
|
|
|
183
178
|
|
|
184
179
|
const { connectHomeAssistant } = useHomeAssistantConnection();
|
|
185
180
|
|
|
181
|
+
const { bluetoothScanDevices } = useBluetoothConnection();
|
|
182
|
+
|
|
186
183
|
useEffect(() => {
|
|
187
184
|
if (
|
|
188
185
|
unit.remote_control_options &&
|
|
@@ -196,6 +193,14 @@ const DeviceDetail = ({ route }) => {
|
|
|
196
193
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
197
194
|
}, [unit, isNetworkConnected]);
|
|
198
195
|
|
|
196
|
+
useEffect(() => {
|
|
197
|
+
if (controlOptions?.bluetooth) {
|
|
198
|
+
const bluetooth = controlOptions.bluetooth;
|
|
199
|
+
bluetoothScanDevices([bluetooth.address]);
|
|
200
|
+
}
|
|
201
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
202
|
+
}, [controlOptions, unit]);
|
|
203
|
+
|
|
199
204
|
const fetchSensorDetail = useCallback(async () => {
|
|
200
205
|
const { success, data, resp_status } = await axiosGet(
|
|
201
206
|
API.DEVICE.SENSOR_DETAIL(sensorId || sensor?.id)
|
|
@@ -424,16 +429,9 @@ const DeviceDetail = ({ route }) => {
|
|
|
424
429
|
|
|
425
430
|
const { countUpStr } = useCountUp(lastEvent.reportedAt);
|
|
426
431
|
|
|
427
|
-
useEffect(() => {
|
|
428
|
-
if (controlOptions?.bluetooth) {
|
|
429
|
-
const bluetooth = controlOptions.bluetooth;
|
|
430
|
-
scanBluetoothDevices([bluetooth.address]);
|
|
431
|
-
}
|
|
432
|
-
}, [controlOptions, unit]);
|
|
433
|
-
|
|
434
432
|
useEffect(() => {
|
|
435
433
|
fetchDataDeviceDetail();
|
|
436
|
-
}, [sensor, fetchDataDeviceDetail]);
|
|
434
|
+
}, [sensor, isNetworkConnected, fetchDataDeviceDetail]);
|
|
437
435
|
|
|
438
436
|
const onRefresh = useCallback(() => {
|
|
439
437
|
fetchSensorDetail();
|
|
@@ -542,6 +540,7 @@ const DeviceDetail = ({ route }) => {
|
|
|
542
540
|
});
|
|
543
541
|
};
|
|
544
542
|
if (
|
|
543
|
+
isNetworkConnected &&
|
|
545
544
|
sensor?.is_managed_by_backend &&
|
|
546
545
|
sensor?.device_type !== DEVICE_TYPE.LG_THINQ
|
|
547
546
|
) {
|
|
@@ -553,7 +552,7 @@ const DeviceDetail = ({ route }) => {
|
|
|
553
552
|
setLoading((preState) => ({ ...preState, isConnected: false }));
|
|
554
553
|
}
|
|
555
554
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
556
|
-
}, [sensor, display]);
|
|
555
|
+
}, [sensor, display, isNetworkConnected]);
|
|
557
556
|
|
|
558
557
|
const isShowEmergencyResolve =
|
|
559
558
|
display.items.filter(
|
|
@@ -573,6 +572,7 @@ const DeviceDetail = ({ route }) => {
|
|
|
573
572
|
params: { unitId: unit?.id, group },
|
|
574
573
|
});
|
|
575
574
|
}, [navigation, unit?.group, unit?.id]);
|
|
575
|
+
|
|
576
576
|
const isHaveColorSliderTemplate = useMemo(() => {
|
|
577
577
|
let isFlag = false;
|
|
578
578
|
display?.items.some((item) => {
|
|
@@ -592,14 +592,8 @@ const DeviceDetail = ({ route }) => {
|
|
|
592
592
|
return (
|
|
593
593
|
<SensorConnectStatusViewHeader
|
|
594
594
|
sensor={sensor}
|
|
595
|
-
connectedViaNetwork={
|
|
596
|
-
|
|
597
|
-
}
|
|
598
|
-
connectedViaBle={
|
|
599
|
-
(!isNetworkConnected ||
|
|
600
|
-
(isNetworkConnected && !displayValuesData.isConnected)) &&
|
|
601
|
-
isDeviceConnectedViaBle
|
|
602
|
-
}
|
|
595
|
+
connectedViaNetwork={isEoHBackendConnected}
|
|
596
|
+
connectedViaBle={isBluetoothConnected}
|
|
603
597
|
connectedViaHomeAssistant={isHomeAssistantConnected}
|
|
604
598
|
isHomeAssistantConnecting={isHomeAssistantConnecting}
|
|
605
599
|
lastUpdated={displayValuesData.lastUpdated}
|
|
@@ -6,14 +6,11 @@ import MockAdapter from 'axios-mock-adapter';
|
|
|
6
6
|
import { SCProvider } from '../../../context';
|
|
7
7
|
import { mockSCStore } from '../../../context/mockStore';
|
|
8
8
|
import NotificationItem from '../components/NotificationItem';
|
|
9
|
-
import {
|
|
10
|
-
NOTIFICATION_TYPES,
|
|
11
|
-
SENSOR_TYPE,
|
|
12
|
-
EMERGENCY_TYPE,
|
|
13
|
-
} from '../../../configs/Constants';
|
|
9
|
+
import { NOTIFICATION_TYPES, EMERGENCY_TYPE } from '../../../configs/Constants';
|
|
14
10
|
import Routes from '../../../utils/Route';
|
|
15
11
|
import { API } from '../../../configs';
|
|
16
12
|
import api from '../../../utils/Apis/axios';
|
|
13
|
+
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
17
14
|
|
|
18
15
|
const wrapComponent = (item) => (
|
|
19
16
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -132,17 +129,16 @@ describe('test NotificationItem', () => {
|
|
|
132
129
|
}
|
|
133
130
|
|
|
134
131
|
const listSensorType = [
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
NOTIFICATION_TYPES.AIR_QUALITY,
|
|
133
|
+
NOTIFICATION_TYPES.TURBIDITY,
|
|
134
|
+
NOTIFICATION_TYPES.PH,
|
|
135
|
+
NOTIFICATION_TYPES.CLO,
|
|
136
|
+
NOTIFICATION_TYPES.UV,
|
|
140
137
|
];
|
|
141
|
-
for (const
|
|
142
|
-
test(`create ItemNotification
|
|
143
|
-
item.content_code =
|
|
138
|
+
for (const content_code of listSensorType) {
|
|
139
|
+
test(`create ItemNotification ${content_code}`, async () => {
|
|
140
|
+
item.content_code = content_code;
|
|
144
141
|
item.params = {
|
|
145
|
-
sensor_type: sensorType,
|
|
146
142
|
unit_id: 5,
|
|
147
143
|
summary_id: 11,
|
|
148
144
|
};
|
|
@@ -164,32 +160,16 @@ describe('test NotificationItem', () => {
|
|
|
164
160
|
});
|
|
165
161
|
}
|
|
166
162
|
|
|
167
|
-
it('test case NOTIFY_INDICATOR no sensor_type', async () => {
|
|
168
|
-
item.content_code = NOTIFICATION_TYPES.NOTIFY_INDICATOR;
|
|
169
|
-
item.params = {
|
|
170
|
-
sensor_type: null,
|
|
171
|
-
unit_id: 5,
|
|
172
|
-
summary_id: 11,
|
|
173
|
-
};
|
|
174
|
-
await act(async () => {
|
|
175
|
-
tree = await create(wrapComponent(item));
|
|
176
|
-
});
|
|
177
|
-
const instance = tree.root;
|
|
178
|
-
const button = instance.findAllByType(TouchableOpacity);
|
|
179
|
-
expect(button).toHaveLength(0);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
163
|
const listSensorType2 = [
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
164
|
+
NOTIFICATION_TYPES.SMOKE,
|
|
165
|
+
NOTIFICATION_TYPES.FIRE,
|
|
166
|
+
NOTIFICATION_TYPES.SOS,
|
|
167
|
+
NOTIFICATION_TYPES.FILTER_WATER,
|
|
187
168
|
];
|
|
188
|
-
for (const
|
|
189
|
-
test(`create ItemNotification
|
|
190
|
-
item.content_code =
|
|
169
|
+
for (const content_code of listSensorType2) {
|
|
170
|
+
test(`create ItemNotification ${content_code}`, async () => {
|
|
171
|
+
item.content_code = content_code;
|
|
191
172
|
item.params = {
|
|
192
|
-
sensor_type: sensorType,
|
|
193
173
|
unit_id: 70,
|
|
194
174
|
sensor_id: 394,
|
|
195
175
|
};
|
|
@@ -212,10 +192,9 @@ describe('test NotificationItem', () => {
|
|
|
212
192
|
});
|
|
213
193
|
}
|
|
214
194
|
|
|
215
|
-
|
|
216
|
-
item.content_code = NOTIFICATION_TYPES.
|
|
195
|
+
test('test onClick Item Notify', async () => {
|
|
196
|
+
item.content_code = NOTIFICATION_TYPES.AIR_QUALITY;
|
|
217
197
|
item.params = {
|
|
218
|
-
sensor_type: 'air_quality',
|
|
219
198
|
unit_id: 5,
|
|
220
199
|
summary_id: 11,
|
|
221
200
|
};
|
|
@@ -314,4 +293,29 @@ describe('test NotificationItem', () => {
|
|
|
314
293
|
const button = instance.findAllByType(TouchableOpacity);
|
|
315
294
|
expect(button).toHaveLength(0);
|
|
316
295
|
});
|
|
296
|
+
|
|
297
|
+
test('test case NOTIFY_REMOVE_UNIT to unit_onwer', async () => {
|
|
298
|
+
item.content_code = NOTIFICATION_TYPES.NOTIFY_REMOVE_UNIT;
|
|
299
|
+
item.params = {
|
|
300
|
+
unit_id: 1,
|
|
301
|
+
unit_owner_name: 'EoH owner',
|
|
302
|
+
unit_name: 'EoH',
|
|
303
|
+
};
|
|
304
|
+
await act(async () => {
|
|
305
|
+
tree = await create(wrapComponent(item));
|
|
306
|
+
});
|
|
307
|
+
const instance = tree.root;
|
|
308
|
+
const customText = instance.findByProps({
|
|
309
|
+
accessibilityLabel: AccessibilityLabel.CUSTOM_TEXT,
|
|
310
|
+
});
|
|
311
|
+
expect(customText.props.children[0].props.children).toEqual('Unit ');
|
|
312
|
+
expect(customText.props.children[1].props.children).toEqual('EoH');
|
|
313
|
+
expect(customText.props.children[2].props.children).toEqual(
|
|
314
|
+
' has been removed by '
|
|
315
|
+
);
|
|
316
|
+
expect(customText.props.children[3].props.children).toEqual('EoH owner');
|
|
317
|
+
expect(customText.props.children[4].props.children).toEqual(
|
|
318
|
+
'. You cannot access to this unit anymore.'
|
|
319
|
+
);
|
|
320
|
+
});
|
|
317
321
|
});
|
|
@@ -7,14 +7,11 @@ import styles from '../styles/NotificationItemStyles';
|
|
|
7
7
|
import Text from '../../../commons/Text';
|
|
8
8
|
import { Colors, API, Images } from '../../../configs';
|
|
9
9
|
import IconComponent from '../../../commons/IconComponent';
|
|
10
|
-
import {
|
|
11
|
-
NOTIFICATION_TYPES,
|
|
12
|
-
SENSOR_TYPE,
|
|
13
|
-
EMERGENCY_TYPE,
|
|
14
|
-
} from '../../../configs/Constants';
|
|
10
|
+
import { NOTIFICATION_TYPES, EMERGENCY_TYPE } from '../../../configs/Constants';
|
|
15
11
|
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
16
12
|
import { axiosPost } from '../../../utils/Apis/axios';
|
|
17
13
|
import Routes from '../../../utils/Route';
|
|
14
|
+
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
18
15
|
|
|
19
16
|
const NotificationItem = memo(({ item }) => {
|
|
20
17
|
const t = useTranslations();
|
|
@@ -63,141 +60,133 @@ const NotificationItem = memo(({ item }) => {
|
|
|
63
60
|
/>
|
|
64
61
|
),
|
|
65
62
|
};
|
|
66
|
-
case NOTIFICATION_TYPES.
|
|
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
|
-
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
196
|
-
};
|
|
197
|
-
default:
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
200
|
-
|
|
63
|
+
case NOTIFICATION_TYPES.AIR_QUALITY:
|
|
64
|
+
return {
|
|
65
|
+
content: customColorText(
|
|
66
|
+
t('text_notification_content_air_quality_high')
|
|
67
|
+
),
|
|
68
|
+
redirect: () =>
|
|
69
|
+
navigation.navigate(Routes.UnitStack, {
|
|
70
|
+
screen: Routes.UnitSummary,
|
|
71
|
+
params: {
|
|
72
|
+
summaryId: params?.summary_id,
|
|
73
|
+
unitId,
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
76
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
77
|
+
};
|
|
78
|
+
case NOTIFICATION_TYPES.TURBIDITY:
|
|
79
|
+
return {
|
|
80
|
+
content: customColorText(
|
|
81
|
+
t('text_notification_content_air_quality_high')
|
|
82
|
+
),
|
|
83
|
+
redirect: () =>
|
|
84
|
+
navigation.navigate(Routes.UnitStack, {
|
|
85
|
+
screen: Routes.UnitSummary,
|
|
86
|
+
params: {
|
|
87
|
+
summaryId: params?.summary_id,
|
|
88
|
+
unitId,
|
|
89
|
+
},
|
|
90
|
+
}),
|
|
91
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
92
|
+
};
|
|
93
|
+
case NOTIFICATION_TYPES.PH:
|
|
94
|
+
return {
|
|
95
|
+
content: customColorText(
|
|
96
|
+
t('text_notification_content_pH_index_high')
|
|
97
|
+
),
|
|
98
|
+
redirect: () =>
|
|
99
|
+
navigation.navigate(Routes.UnitStack, {
|
|
100
|
+
screen: Routes.UnitSummary,
|
|
101
|
+
params: {
|
|
102
|
+
summaryId: params?.summary_id,
|
|
103
|
+
unitId,
|
|
104
|
+
},
|
|
105
|
+
}),
|
|
106
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
107
|
+
};
|
|
108
|
+
case NOTIFICATION_TYPES.CLO:
|
|
109
|
+
return {
|
|
110
|
+
content: customColorText(t('text_notification_content_clo_high')),
|
|
111
|
+
redirect: () =>
|
|
112
|
+
navigation.navigate(Routes.UnitStack, {
|
|
113
|
+
screen: Routes.UnitSummary,
|
|
114
|
+
params: {
|
|
115
|
+
summaryId: params?.summary_id,
|
|
116
|
+
unitId,
|
|
117
|
+
},
|
|
118
|
+
}),
|
|
119
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
120
|
+
};
|
|
121
|
+
case NOTIFICATION_TYPES.UV:
|
|
122
|
+
return {
|
|
123
|
+
content: customColorText(
|
|
124
|
+
t('text_notification_content_uv_index_high')
|
|
125
|
+
),
|
|
126
|
+
redirect: () =>
|
|
127
|
+
navigation.navigate(Routes.UnitStack, {
|
|
128
|
+
screen: Routes.UnitSummary,
|
|
129
|
+
params: {
|
|
130
|
+
summaryId: params?.summary_id,
|
|
131
|
+
unitId,
|
|
132
|
+
},
|
|
133
|
+
}),
|
|
134
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
135
|
+
};
|
|
136
|
+
case NOTIFICATION_TYPES.SMOKE:
|
|
137
|
+
return {
|
|
138
|
+
content: customColorText(t('text_notification_content_smoke')),
|
|
139
|
+
redirect: () =>
|
|
140
|
+
navigation.navigate(Routes.UnitStack, {
|
|
141
|
+
screen: Routes.DeviceDetail,
|
|
142
|
+
params: {
|
|
143
|
+
unitId,
|
|
144
|
+
sensorId,
|
|
145
|
+
},
|
|
146
|
+
}),
|
|
147
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
148
|
+
};
|
|
149
|
+
case NOTIFICATION_TYPES.FIRE:
|
|
150
|
+
return {
|
|
151
|
+
content: customColorText(t('text_notification_content_fire')),
|
|
152
|
+
redirect: () =>
|
|
153
|
+
navigation.navigate(Routes.UnitStack, {
|
|
154
|
+
screen: Routes.DeviceDetail,
|
|
155
|
+
params: {
|
|
156
|
+
unitId,
|
|
157
|
+
sensorId,
|
|
158
|
+
},
|
|
159
|
+
}),
|
|
160
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
161
|
+
};
|
|
162
|
+
case NOTIFICATION_TYPES.SOS:
|
|
163
|
+
return {
|
|
164
|
+
content: customColorText(t('text_notification_content_active_sos')),
|
|
165
|
+
redirect: () =>
|
|
166
|
+
navigation.navigate(Routes.UnitStack, {
|
|
167
|
+
screen: Routes.DeviceDetail,
|
|
168
|
+
params: {
|
|
169
|
+
unitId,
|
|
170
|
+
sensorId,
|
|
171
|
+
},
|
|
172
|
+
}),
|
|
173
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
174
|
+
};
|
|
175
|
+
case NOTIFICATION_TYPES.FILTER_WATER:
|
|
176
|
+
return {
|
|
177
|
+
content: customColorText(
|
|
178
|
+
t('text_notification_content_replace_water_filter')
|
|
179
|
+
),
|
|
180
|
+
redirect: () =>
|
|
181
|
+
navigation.navigate(Routes.UnitStack, {
|
|
182
|
+
screen: Routes.DeviceDetail,
|
|
183
|
+
params: {
|
|
184
|
+
unitId,
|
|
185
|
+
sensorId,
|
|
186
|
+
},
|
|
187
|
+
}),
|
|
188
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
189
|
+
};
|
|
201
190
|
case NOTIFICATION_TYPES.NOTIFY_REMOVE_UNIT:
|
|
202
191
|
return {
|
|
203
192
|
content: customColorText(
|
|
@@ -379,7 +368,11 @@ const NotificationItem = memo(({ item }) => {
|
|
|
379
368
|
</View>
|
|
380
369
|
|
|
381
370
|
<View style={styles.viewRight}>
|
|
382
|
-
<Text
|
|
371
|
+
<Text
|
|
372
|
+
type="Body"
|
|
373
|
+
color={Colors.Gray9}
|
|
374
|
+
accessibilityLabel={AccessibilityLabel.CUSTOM_TEXT}
|
|
375
|
+
>
|
|
383
376
|
{content}
|
|
384
377
|
</Text>
|
|
385
378
|
<Text color={Colors.Gray7} type="Label" style={[styles.time]}>
|
|
@@ -32,6 +32,7 @@ const SmartAccountConnecting = ({ route }) => {
|
|
|
32
32
|
smart_account_id,
|
|
33
33
|
smart_account_id_from_backend,
|
|
34
34
|
device_data,
|
|
35
|
+
chipId,
|
|
35
36
|
} = route.params;
|
|
36
37
|
|
|
37
38
|
const handleRefreshPercent = useCallback(() => {
|
|
@@ -60,6 +61,7 @@ const SmartAccountConnecting = ({ route }) => {
|
|
|
60
61
|
device_data: data.sensors_unidentified || device_data,
|
|
61
62
|
unit_id: unit_id,
|
|
62
63
|
smart_account_id_from_backend: data.smart_account_id,
|
|
64
|
+
chipId: data?.chip_id,
|
|
63
65
|
});
|
|
64
66
|
|
|
65
67
|
clearTimeout(timeConnecting);
|
|
@@ -96,6 +98,7 @@ const SmartAccountConnecting = ({ route }) => {
|
|
|
96
98
|
stationId,
|
|
97
99
|
username,
|
|
98
100
|
brand,
|
|
101
|
+
chipId,
|
|
99
102
|
});
|
|
100
103
|
clearTimeout(timeAddDevice);
|
|
101
104
|
}, 1000);
|