@eohjsc/react-native-smart-city 0.3.57 → 0.3.58
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 +2 -2
- package/src/commons/SubUnit/ShortDetail.js +1 -2
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +1 -2
- package/src/screens/AddCommon/SelectUnit.js +1 -2
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +4 -2
- package/src/screens/AddNewGateway/ConnectingDevice.js +2 -2
- package/src/screens/AddNewGateway/ConnectingModbusDevice.js +4 -4
- package/src/screens/AddNewGateway/ConnectingWifiDevice.js +9 -7
- package/src/screens/AddNewGateway/ConnectingWifiGuide.js +3 -3
- package/src/screens/AddNewGateway/ConnectingZigbeeDevice.js +4 -4
- package/src/screens/AddNewGateway/RenameNewDevices.js +4 -4
- package/src/screens/AddNewGateway/ScanGatewayQR.js +3 -3
- package/src/screens/AddNewGateway/ScanModbusQR.js +3 -3
- package/src/screens/AddNewGateway/ScanWifiDeviceQR.js +3 -3
- package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +10 -13
- package/src/screens/AddNewGateway/SelectDeviceType.js +6 -9
- package/src/screens/AddNewGateway/SelectDeviceUnit.js +1 -2
- package/src/screens/AddNewGateway/SelectModbusGateway.js +6 -7
- package/src/screens/AddNewGateway/SelectZigbeeGateway.js +4 -4
- package/src/screens/AddNewGateway/ShareWifiPassword.js +5 -5
- package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +6 -2
- package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +6 -2
- package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -2
- package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -2
- package/src/screens/SubUnit/Detail.js +1 -2
- package/src/screens/Unit/AddMenu.js +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eohjsc/react-native-smart-city",
|
|
3
3
|
"title": "React Native Smart Home",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.58",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -197,7 +197,7 @@
|
|
|
197
197
|
"react-native-svg": "^12.1.0",
|
|
198
198
|
"react-native-toast-message": "^2.1.1",
|
|
199
199
|
"react-native-udp": "^4.1.3",
|
|
200
|
-
"react-native-unimodules": "
|
|
200
|
+
"react-native-unimodules": "0.14.8",
|
|
201
201
|
"react-native-version-check": "^3.4.2",
|
|
202
202
|
"react-native-vlc-media-player": "^1.0.41",
|
|
203
203
|
"react-native-webview": "11.17.2",
|
|
@@ -167,8 +167,7 @@ describe('test ShortDetail Subunit', () => {
|
|
|
167
167
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.AddGatewayStack, {
|
|
168
168
|
screen: Routes.SelectDeviceType,
|
|
169
169
|
params: {
|
|
170
|
-
|
|
171
|
-
unitName: props.unit.name,
|
|
170
|
+
unit: props.unit,
|
|
172
171
|
subUnit: props.station,
|
|
173
172
|
},
|
|
174
173
|
});
|
|
@@ -123,8 +123,10 @@ describe('Test SelectUnit container', () => {
|
|
|
123
123
|
expect(mockedNavigate).toBeCalledWith('AddGatewayStack', {
|
|
124
124
|
screen: 'SelectDeviceType',
|
|
125
125
|
params: {
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
unit: {
|
|
127
|
+
id: 1,
|
|
128
|
+
name: 'Unit 1',
|
|
129
|
+
},
|
|
128
130
|
},
|
|
129
131
|
});
|
|
130
132
|
break;
|
|
@@ -12,7 +12,7 @@ const ConnectingDevice = ({
|
|
|
12
12
|
fail,
|
|
13
13
|
initState,
|
|
14
14
|
onReady,
|
|
15
|
-
|
|
15
|
+
unit,
|
|
16
16
|
subUnit,
|
|
17
17
|
chipId,
|
|
18
18
|
sensorId,
|
|
@@ -26,7 +26,7 @@ const ConnectingDevice = ({
|
|
|
26
26
|
const { navigate, goBack } = useNavigation();
|
|
27
27
|
|
|
28
28
|
const [renameParams, setRenameParams] = useState({
|
|
29
|
-
|
|
29
|
+
unit,
|
|
30
30
|
subUnit,
|
|
31
31
|
chipId,
|
|
32
32
|
sensorId,
|
|
@@ -9,7 +9,7 @@ import ConnectingDevice from './ConnectingDevice';
|
|
|
9
9
|
|
|
10
10
|
const ConnectingModbusDevice = ({ route }) => {
|
|
11
11
|
const t = useTranslations();
|
|
12
|
-
const {
|
|
12
|
+
const { unit, subUnit, chipId, qrData } = route?.params || {};
|
|
13
13
|
const [sensorId, setSensorId] = useState(null);
|
|
14
14
|
const [channelNameTemp, setChannelNameTemp] = useState('');
|
|
15
15
|
const [isChangeAddressSuccess, setIsChangeAddressSuccess] = useState(false);
|
|
@@ -27,7 +27,7 @@ const ConnectingModbusDevice = ({ route }) => {
|
|
|
27
27
|
setChannelNameTemp(channelName);
|
|
28
28
|
const { success, data } = await axiosPost(API.CHIP.SCAN_SENSOR(chipId), {
|
|
29
29
|
imei: qrData.imei,
|
|
30
|
-
unit:
|
|
30
|
+
unit: unit?.id,
|
|
31
31
|
station: subUnit?.id,
|
|
32
32
|
channel_name: channelName,
|
|
33
33
|
});
|
|
@@ -36,7 +36,7 @@ const ConnectingModbusDevice = ({ route }) => {
|
|
|
36
36
|
}
|
|
37
37
|
setSensorId(data.id);
|
|
38
38
|
},
|
|
39
|
-
[chipId, qrData, subUnit,
|
|
39
|
+
[chipId, qrData, subUnit, unit]
|
|
40
40
|
);
|
|
41
41
|
|
|
42
42
|
useEffect(() => {
|
|
@@ -66,7 +66,7 @@ const ConnectingModbusDevice = ({ route }) => {
|
|
|
66
66
|
title={t('connect_device')}
|
|
67
67
|
initState={t('connecting_to_gateway')}
|
|
68
68
|
onReady={onReady}
|
|
69
|
-
|
|
69
|
+
unit={unit}
|
|
70
70
|
subUnit={subUnit}
|
|
71
71
|
chipId={chipId}
|
|
72
72
|
sensorId={sensorId}
|
|
@@ -12,7 +12,7 @@ let isCallingAPI = false;
|
|
|
12
12
|
|
|
13
13
|
const ConnectingWifiDevice = ({ route }) => {
|
|
14
14
|
const t = useTranslations();
|
|
15
|
-
const {
|
|
15
|
+
const { unit, subUnit, gateway, selectedWifi, qrData, addDeviceType } =
|
|
16
16
|
route?.params || {};
|
|
17
17
|
const { goBack } = useNavigation();
|
|
18
18
|
|
|
@@ -38,7 +38,7 @@ const ConnectingWifiDevice = ({ route }) => {
|
|
|
38
38
|
isCallingAPI = true;
|
|
39
39
|
const timeout = setTimeout(async () => {
|
|
40
40
|
const { success, problem, data } = await axiosPost(
|
|
41
|
-
API.UNIT.CHIP_SCAN(
|
|
41
|
+
API.UNIT.CHIP_SCAN(unit?.id),
|
|
42
42
|
{
|
|
43
43
|
imei: gateway?.imei,
|
|
44
44
|
secret: qrData?.secret,
|
|
@@ -60,11 +60,13 @@ const ConnectingWifiDevice = ({ route }) => {
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
[
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
unit?.id,
|
|
64
|
+
gateway?.imei,
|
|
65
|
+
gateway?.model,
|
|
66
66
|
qrData?.secret,
|
|
67
|
-
subUnit,
|
|
67
|
+
subUnit?.id,
|
|
68
|
+
selectedWifi.ssid,
|
|
69
|
+
selectedWifi.password,
|
|
68
70
|
addingWifiDeviceFail,
|
|
69
71
|
]
|
|
70
72
|
);
|
|
@@ -85,7 +87,7 @@ const ConnectingWifiDevice = ({ route }) => {
|
|
|
85
87
|
fail={addingWifiDeviceFail}
|
|
86
88
|
initState={t('connecting_to_device')}
|
|
87
89
|
onReady={setChannelName}
|
|
88
|
-
|
|
90
|
+
unit={unit}
|
|
89
91
|
subUnit={subUnit}
|
|
90
92
|
chipId={chipId}
|
|
91
93
|
addDeviceType={addDeviceType}
|
|
@@ -25,7 +25,7 @@ const ConnectingWifiGuide = ({ route }) => {
|
|
|
25
25
|
const t = useTranslations();
|
|
26
26
|
const {
|
|
27
27
|
qrData,
|
|
28
|
-
|
|
28
|
+
unit,
|
|
29
29
|
subUnit,
|
|
30
30
|
addDeviceType,
|
|
31
31
|
stationId,
|
|
@@ -173,7 +173,7 @@ const ConnectingWifiGuide = ({ route }) => {
|
|
|
173
173
|
socket?.close();
|
|
174
174
|
socket = null;
|
|
175
175
|
navigate(Routes.ShareWifiPassword, {
|
|
176
|
-
|
|
176
|
+
unit,
|
|
177
177
|
subUnit,
|
|
178
178
|
wifiList,
|
|
179
179
|
qrData: qrData,
|
|
@@ -181,7 +181,7 @@ const ConnectingWifiGuide = ({ route }) => {
|
|
|
181
181
|
stationId,
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
|
-
}, [addDeviceType, navigate, qrData, stationId, subUnit,
|
|
184
|
+
}, [addDeviceType, navigate, qrData, stationId, subUnit, unit, wifiList]);
|
|
185
185
|
|
|
186
186
|
return (
|
|
187
187
|
<View style={styles.container}>
|
|
@@ -10,7 +10,7 @@ import ConnectingDevice from './ConnectingDevice';
|
|
|
10
10
|
const ConnectingZigbeeDevice = ({ route }) => {
|
|
11
11
|
const t = useTranslations();
|
|
12
12
|
const { goBack } = useNavigation();
|
|
13
|
-
const {
|
|
13
|
+
const { unit, subUnit, chipId } = route?.params || {};
|
|
14
14
|
|
|
15
15
|
const fail = useCallback(
|
|
16
16
|
(message) => {
|
|
@@ -31,7 +31,7 @@ const ConnectingZigbeeDevice = ({ route }) => {
|
|
|
31
31
|
{
|
|
32
32
|
channel_name: channelName,
|
|
33
33
|
station: subUnit?.id,
|
|
34
|
-
unit:
|
|
34
|
+
unit: unit?.id,
|
|
35
35
|
}
|
|
36
36
|
);
|
|
37
37
|
|
|
@@ -40,7 +40,7 @@ const ConnectingZigbeeDevice = ({ route }) => {
|
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
-
[chipId, fail, subUnit?.id,
|
|
43
|
+
[chipId, fail, subUnit?.id, unit?.id]
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
return (
|
|
@@ -49,7 +49,7 @@ const ConnectingZigbeeDevice = ({ route }) => {
|
|
|
49
49
|
fail={fail}
|
|
50
50
|
initState={t('connecting_to_gateway')}
|
|
51
51
|
onReady={onReady}
|
|
52
|
-
|
|
52
|
+
unit={unit}
|
|
53
53
|
subUnit={subUnit}
|
|
54
54
|
chipId={chipId}
|
|
55
55
|
sensorId={null}
|
|
@@ -20,7 +20,7 @@ const RenameNewDevices = memo(({ route }) => {
|
|
|
20
20
|
const t = useTranslations();
|
|
21
21
|
const { dispatch } = useNavigation();
|
|
22
22
|
|
|
23
|
-
const {
|
|
23
|
+
const { unit, subUnit, chipId, sensorId, addDeviceType } =
|
|
24
24
|
route?.params || {};
|
|
25
25
|
const [selectedItem, setSelectedItem] = useState({});
|
|
26
26
|
const [isCanRename, setIsCanRename] = useState(false);
|
|
@@ -68,7 +68,7 @@ const RenameNewDevices = memo(({ route }) => {
|
|
|
68
68
|
params: {
|
|
69
69
|
screen: Routes.UnitDetail,
|
|
70
70
|
params: {
|
|
71
|
-
unitId:
|
|
71
|
+
unitId: unit?.id,
|
|
72
72
|
stationId: subUnit?.id,
|
|
73
73
|
isSuccessfullyConnected: true,
|
|
74
74
|
routeName: Routes.DashboardStack,
|
|
@@ -78,7 +78,7 @@ const RenameNewDevices = memo(({ route }) => {
|
|
|
78
78
|
],
|
|
79
79
|
});
|
|
80
80
|
dispatch(resetAction);
|
|
81
|
-
}, [dispatch, info, subUnit?.id,
|
|
81
|
+
}, [dispatch, info, subUnit?.id, unit?.id]);
|
|
82
82
|
|
|
83
83
|
useEffect(() => {
|
|
84
84
|
(async () => {
|
|
@@ -244,7 +244,7 @@ const RenameNewDevices = memo(({ route }) => {
|
|
|
244
244
|
{t('successfully_connected')}
|
|
245
245
|
</Text>
|
|
246
246
|
<Text size={14} color={Colors.Gray9}>
|
|
247
|
-
{subUnit?.name}
|
|
247
|
+
{[unit?.name, subUnit?.name].filter(Boolean).join(' - ')}
|
|
248
248
|
</Text>
|
|
249
249
|
{renderListItem}
|
|
250
250
|
<Text size={16} color={Colors.Gray8} style={styles.textRename}>
|
|
@@ -8,7 +8,7 @@ import InvalidQRCode from '../ScanChipQR/components/InvalidQRCode';
|
|
|
8
8
|
|
|
9
9
|
const ScanGatewayQR = memo(({ route }) => {
|
|
10
10
|
// same as Scan Wifi Device, not sure if we should separated it
|
|
11
|
-
const {
|
|
11
|
+
const { unit, stationId } = route?.params || {};
|
|
12
12
|
const [isInvalidQrCode, setIsInvalidQrCode] = useState(false);
|
|
13
13
|
const { navigate, goBack } = useNavigation();
|
|
14
14
|
|
|
@@ -28,14 +28,14 @@ const ScanGatewayQR = memo(({ route }) => {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
navigate(Routes.ConnectingWifiGuide, {
|
|
31
|
-
|
|
31
|
+
unit,
|
|
32
32
|
stationId,
|
|
33
33
|
qrData: data,
|
|
34
34
|
addDeviceType: 'gateway',
|
|
35
35
|
});
|
|
36
36
|
setLoading(true);
|
|
37
37
|
},
|
|
38
|
-
[navigate, stationId,
|
|
38
|
+
[navigate, stationId, unit]
|
|
39
39
|
);
|
|
40
40
|
|
|
41
41
|
const onRetry = useCallback(() => {
|
|
@@ -14,7 +14,7 @@ import { Colors } from '../../configs';
|
|
|
14
14
|
|
|
15
15
|
const ScanModbusQR = memo(({ route }) => {
|
|
16
16
|
const t = useTranslations();
|
|
17
|
-
const {
|
|
17
|
+
const { unit, subUnit } = route?.params || {};
|
|
18
18
|
const { navigate, goBack } = useNavigation();
|
|
19
19
|
const [showPopupGuide, setShowPopupGuide, setHidePopupGuide] = useBoolean();
|
|
20
20
|
const [isInvalidQrCode, setIsInvalidQrCode] = useState(false);
|
|
@@ -36,12 +36,12 @@ const ScanModbusQR = memo(({ route }) => {
|
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
navigate(Routes.SelectModbusGateway, {
|
|
39
|
-
|
|
39
|
+
unit,
|
|
40
40
|
subUnit,
|
|
41
41
|
qrData: data,
|
|
42
42
|
});
|
|
43
43
|
},
|
|
44
|
-
[navigate,
|
|
44
|
+
[navigate, unit, subUnit]
|
|
45
45
|
);
|
|
46
46
|
|
|
47
47
|
const handleCancel = useCallback(() => {
|
|
@@ -6,7 +6,7 @@ import { useNavigation } from '@react-navigation/native';
|
|
|
6
6
|
import InvalidQRCode from '../ScanChipQR/components/InvalidQRCode';
|
|
7
7
|
|
|
8
8
|
const ScanWifiDeviceQR = memo(({ route }) => {
|
|
9
|
-
const {
|
|
9
|
+
const { unit, subUnit } = route?.params || {};
|
|
10
10
|
const [isInvalidQrCode, setIsInvalidQrCode] = useState(false);
|
|
11
11
|
const { navigate, goBack } = useNavigation();
|
|
12
12
|
|
|
@@ -26,13 +26,13 @@ const ScanWifiDeviceQR = memo(({ route }) => {
|
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
navigate(Routes.ConnectingWifiGuide, {
|
|
29
|
-
|
|
29
|
+
unit,
|
|
30
30
|
subUnit,
|
|
31
31
|
qrData: data,
|
|
32
32
|
});
|
|
33
33
|
setLoading(true);
|
|
34
34
|
},
|
|
35
|
-
[navigate,
|
|
35
|
+
[navigate, subUnit, unit]
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
const onRetry = useCallback(() => {
|
|
@@ -7,40 +7,37 @@ import Routes from '../../utils/Route';
|
|
|
7
7
|
import { DEVICE_TYPE } from '../../configs/Constants';
|
|
8
8
|
|
|
9
9
|
const SelectDeviceSubUnit = ({ route }) => {
|
|
10
|
-
const {
|
|
10
|
+
const { unit, deviceType } = route?.params || {};
|
|
11
11
|
const t = useTranslations();
|
|
12
12
|
const navigation = useNavigation();
|
|
13
13
|
const onPressNext = useCallback(
|
|
14
|
-
(
|
|
14
|
+
(chosenUnit, chosenSubUnit) => {
|
|
15
15
|
switch (deviceType) {
|
|
16
16
|
case DEVICE_TYPE.WIFI_DEVICE:
|
|
17
17
|
navigation.navigate(Routes.ScanWifiDeviceQR, {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
subUnit,
|
|
18
|
+
unit,
|
|
19
|
+
chosenSubUnit,
|
|
21
20
|
});
|
|
22
21
|
break;
|
|
23
22
|
case DEVICE_TYPE.MODBUS:
|
|
24
23
|
navigation.navigate(Routes.ScanModbusQR, {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
subUnit,
|
|
24
|
+
unit,
|
|
25
|
+
chosenSubUnit,
|
|
28
26
|
});
|
|
29
27
|
break;
|
|
30
28
|
case DEVICE_TYPE.ZIGBEE:
|
|
31
29
|
navigation.navigate(Routes.ConnectRouterGuide, {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
subUnit,
|
|
30
|
+
unit,
|
|
31
|
+
chosenSubUnit,
|
|
35
32
|
});
|
|
36
33
|
break;
|
|
37
34
|
}
|
|
38
35
|
},
|
|
39
|
-
[deviceType, navigation,
|
|
36
|
+
[deviceType, navigation, unit]
|
|
40
37
|
);
|
|
41
38
|
return (
|
|
42
39
|
<SelectSubUnit
|
|
43
|
-
unitId={
|
|
40
|
+
unitId={unit?.id}
|
|
44
41
|
title={t('text_select_sub_unit')}
|
|
45
42
|
subTitle={t('select_a_sub_unit_want_add_device')}
|
|
46
43
|
onPressNext={onPressNext}
|
|
@@ -53,7 +53,7 @@ const SelectDeviceGrid = ({ options, onSelect }) => {
|
|
|
53
53
|
|
|
54
54
|
const SelectDeviceType = ({ route }) => {
|
|
55
55
|
const t = useTranslations();
|
|
56
|
-
const {
|
|
56
|
+
const { unit, subUnit } = route?.params || {};
|
|
57
57
|
const { navigate, goBack } = useNavigation();
|
|
58
58
|
const [addType, setAddType] = useState();
|
|
59
59
|
const [selectedAddType, setSelectedAddType] = useState();
|
|
@@ -65,7 +65,7 @@ const SelectDeviceType = ({ route }) => {
|
|
|
65
65
|
image: <AddGatewayIcon width={60} height={60} />,
|
|
66
66
|
route: Routes.ScanGatewayQR,
|
|
67
67
|
data: {
|
|
68
|
-
|
|
68
|
+
unit,
|
|
69
69
|
},
|
|
70
70
|
title: t('gateway'),
|
|
71
71
|
subtitle: t('central_controller'),
|
|
@@ -77,8 +77,7 @@ const SelectDeviceType = ({ route }) => {
|
|
|
77
77
|
? Routes.ScanWifiDeviceQR
|
|
78
78
|
: Routes.SelectDeviceSubUnit,
|
|
79
79
|
data: {
|
|
80
|
-
|
|
81
|
-
unitName,
|
|
80
|
+
unit,
|
|
82
81
|
subUnit,
|
|
83
82
|
deviceType: DEVICE_TYPE.WIFI_DEVICE,
|
|
84
83
|
},
|
|
@@ -90,8 +89,7 @@ const SelectDeviceType = ({ route }) => {
|
|
|
90
89
|
image: <AddModbusDeviceIcon width={60} height={60} />,
|
|
91
90
|
route: subUnit?.id ? Routes.ScanModbusQR : Routes.SelectDeviceSubUnit,
|
|
92
91
|
data: {
|
|
93
|
-
|
|
94
|
-
unitName,
|
|
92
|
+
unit,
|
|
95
93
|
subUnit,
|
|
96
94
|
deviceType: DEVICE_TYPE.MODBUS,
|
|
97
95
|
},
|
|
@@ -105,8 +103,7 @@ const SelectDeviceType = ({ route }) => {
|
|
|
105
103
|
? Routes.ConnectRouterGuide
|
|
106
104
|
: Routes.SelectDeviceSubUnit,
|
|
107
105
|
data: {
|
|
108
|
-
|
|
109
|
-
unitName,
|
|
106
|
+
unit,
|
|
110
107
|
subUnit,
|
|
111
108
|
deviceType: DEVICE_TYPE.ZIGBEE,
|
|
112
109
|
},
|
|
@@ -118,7 +115,7 @@ const SelectDeviceType = ({ route }) => {
|
|
|
118
115
|
list.shift();
|
|
119
116
|
}
|
|
120
117
|
return list;
|
|
121
|
-
}, [
|
|
118
|
+
}, [unit, t, subUnit]);
|
|
122
119
|
|
|
123
120
|
const onRight = useCallback(() => {
|
|
124
121
|
if (selectedAddType?.route && selectedAddType?.data) {
|
|
@@ -7,29 +7,28 @@ import Routes from '../../utils/Route';
|
|
|
7
7
|
const SelectModbusGateway = ({ route }) => {
|
|
8
8
|
const t = useTranslations();
|
|
9
9
|
const navigation = useNavigation();
|
|
10
|
-
const {
|
|
10
|
+
const { unit, subUnit, qrData } = route?.params || {};
|
|
11
11
|
|
|
12
12
|
const onPressNext = useCallback(
|
|
13
13
|
(gateway) => {
|
|
14
14
|
navigation.navigate(Routes.ConnectingModbusDevice, {
|
|
15
|
-
|
|
15
|
+
unit,
|
|
16
16
|
subUnit,
|
|
17
17
|
chipId: gateway.id,
|
|
18
18
|
qrData,
|
|
19
19
|
});
|
|
20
20
|
},
|
|
21
|
-
[navigation,
|
|
21
|
+
[navigation, unit, subUnit, qrData]
|
|
22
22
|
);
|
|
23
23
|
|
|
24
24
|
const onPressOk = useCallback(
|
|
25
25
|
(gateway) => {
|
|
26
26
|
navigation.navigate(Routes.SelectDeviceType, {
|
|
27
|
-
|
|
28
|
-
unitName,
|
|
27
|
+
unit,
|
|
29
28
|
subUnit,
|
|
30
29
|
});
|
|
31
30
|
},
|
|
32
|
-
[navigation, subUnit,
|
|
31
|
+
[navigation, subUnit, unit]
|
|
33
32
|
);
|
|
34
33
|
|
|
35
34
|
return (
|
|
@@ -38,7 +37,7 @@ const SelectModbusGateway = ({ route }) => {
|
|
|
38
37
|
onPressOk={onPressOk}
|
|
39
38
|
title={t('text_select_a_gateway')}
|
|
40
39
|
subTitle={t('text_select_a_gateway')}
|
|
41
|
-
unitId={
|
|
40
|
+
unitId={unit?.id}
|
|
42
41
|
type="modbus"
|
|
43
42
|
/>
|
|
44
43
|
);
|
|
@@ -7,18 +7,18 @@ import Routes from '../../utils/Route';
|
|
|
7
7
|
const SelectZigbeeGateway = ({ route }) => {
|
|
8
8
|
const t = useTranslations();
|
|
9
9
|
const { navigate } = useNavigation();
|
|
10
|
-
const {
|
|
10
|
+
const { unit, subUnit } = route?.params || {};
|
|
11
11
|
|
|
12
12
|
const onPressNext = useCallback(
|
|
13
13
|
(gateway) => {
|
|
14
14
|
gateway &&
|
|
15
15
|
navigate(Routes.ZigbeeDeviceConnectGuide, {
|
|
16
|
-
|
|
16
|
+
unit,
|
|
17
17
|
subUnit,
|
|
18
18
|
chipId: gateway.id,
|
|
19
19
|
});
|
|
20
20
|
},
|
|
21
|
-
[
|
|
21
|
+
[unit, subUnit, navigate]
|
|
22
22
|
);
|
|
23
23
|
|
|
24
24
|
return (
|
|
@@ -26,7 +26,7 @@ const SelectZigbeeGateway = ({ route }) => {
|
|
|
26
26
|
onPressNext={onPressNext}
|
|
27
27
|
title={t('text_select_a_gateway')}
|
|
28
28
|
subTitle={t('text_select_a_gateway')}
|
|
29
|
-
unitId={
|
|
29
|
+
unitId={unit?.id}
|
|
30
30
|
type="zigbee"
|
|
31
31
|
/>
|
|
32
32
|
);
|
|
@@ -54,7 +54,7 @@ const WifiItem = ({ item, setIsShowPopupPassword, setSelectedWifi }) => {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
const ShareWifiPassword = ({ route }) => {
|
|
57
|
-
const { wifiList,
|
|
57
|
+
const { wifiList, unit, subUnit, qrData, addDeviceType, stationId } =
|
|
58
58
|
route?.params || {};
|
|
59
59
|
const t = useTranslations();
|
|
60
60
|
const { navigate } = useNavigation();
|
|
@@ -157,14 +157,14 @@ const ShareWifiPassword = ({ route }) => {
|
|
|
157
157
|
socket = null;
|
|
158
158
|
}
|
|
159
159
|
navigate(Routes.ConnectingWifiGuide, {
|
|
160
|
-
|
|
160
|
+
unit,
|
|
161
161
|
stationId,
|
|
162
162
|
subUnit,
|
|
163
163
|
qrData,
|
|
164
164
|
addDeviceType,
|
|
165
165
|
isBackFromOtherScreen: true,
|
|
166
166
|
});
|
|
167
|
-
}, [addDeviceType, navigate, qrData, stationId, subUnit,
|
|
167
|
+
}, [addDeviceType, navigate, qrData, stationId, subUnit, unit]);
|
|
168
168
|
|
|
169
169
|
useEffect(() => {
|
|
170
170
|
let checkWifiInterval;
|
|
@@ -189,7 +189,7 @@ const ShareWifiPassword = ({ route }) => {
|
|
|
189
189
|
socket?.close();
|
|
190
190
|
socket = null;
|
|
191
191
|
navigate(Routes.ConnectingWifiDevice, {
|
|
192
|
-
|
|
192
|
+
unit,
|
|
193
193
|
subUnit,
|
|
194
194
|
gateway: dataGateway.gateway[0],
|
|
195
195
|
qrData: qrData,
|
|
@@ -225,8 +225,8 @@ const ShareWifiPassword = ({ route }) => {
|
|
|
225
225
|
stationId,
|
|
226
226
|
subUnit,
|
|
227
227
|
t,
|
|
228
|
-
unitId,
|
|
229
228
|
wifiList,
|
|
229
|
+
unit,
|
|
230
230
|
]);
|
|
231
231
|
|
|
232
232
|
return (
|
|
@@ -218,7 +218,9 @@ describe('test share wifi password', () => {
|
|
|
218
218
|
const route = {
|
|
219
219
|
params: {
|
|
220
220
|
qrData: { org_slug: 'eoh', prefix: 'robot' },
|
|
221
|
-
|
|
221
|
+
unit: {
|
|
222
|
+
id: 1,
|
|
223
|
+
},
|
|
222
224
|
subUnit: {
|
|
223
225
|
id: 1,
|
|
224
226
|
},
|
|
@@ -244,7 +246,9 @@ describe('test share wifi password', () => {
|
|
|
244
246
|
expect(socket.close).toBeCalled();
|
|
245
247
|
|
|
246
248
|
expect(mockedNavigate).toBeCalledWith('ShareWifiPassword', {
|
|
247
|
-
|
|
249
|
+
unit: {
|
|
250
|
+
id: 1,
|
|
251
|
+
},
|
|
248
252
|
subUnit: {
|
|
249
253
|
id: 1,
|
|
250
254
|
},
|
|
@@ -55,7 +55,9 @@ describe('Test connecting modbus device', () => {
|
|
|
55
55
|
beforeEach(() => {
|
|
56
56
|
route = {
|
|
57
57
|
params: {
|
|
58
|
-
|
|
58
|
+
unit: {
|
|
59
|
+
id: 1,
|
|
60
|
+
},
|
|
59
61
|
subUnit: {
|
|
60
62
|
id: 2,
|
|
61
63
|
station: 'Station 2',
|
|
@@ -108,7 +110,9 @@ describe('Test connecting modbus device', () => {
|
|
|
108
110
|
});
|
|
109
111
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.RenameNewDevices, {
|
|
110
112
|
addDeviceType: undefined,
|
|
111
|
-
|
|
113
|
+
unit: {
|
|
114
|
+
id: 1,
|
|
115
|
+
},
|
|
112
116
|
subUnit: {
|
|
113
117
|
id: 2,
|
|
114
118
|
station: 'Station 2',
|
|
@@ -38,7 +38,9 @@ describe('Test select modbus gateway', () => {
|
|
|
38
38
|
beforeEach(() => {
|
|
39
39
|
route = {
|
|
40
40
|
params: {
|
|
41
|
-
|
|
41
|
+
unit: {
|
|
42
|
+
id: 1,
|
|
43
|
+
},
|
|
42
44
|
subUnit: {
|
|
43
45
|
id: 2,
|
|
44
46
|
},
|
|
@@ -67,7 +69,9 @@ describe('Test select modbus gateway', () => {
|
|
|
67
69
|
});
|
|
68
70
|
|
|
69
71
|
expect(mockedNavigate).toBeCalledWith(Routes.ConnectingModbusDevice, {
|
|
70
|
-
|
|
72
|
+
unit: {
|
|
73
|
+
id: 1,
|
|
74
|
+
},
|
|
71
75
|
subUnit: {
|
|
72
76
|
id: 2,
|
|
73
77
|
},
|
|
@@ -38,7 +38,9 @@ describe('Test select zigbee gateway', () => {
|
|
|
38
38
|
beforeEach(() => {
|
|
39
39
|
route = {
|
|
40
40
|
params: {
|
|
41
|
-
|
|
41
|
+
unit: {
|
|
42
|
+
id: 1,
|
|
43
|
+
},
|
|
42
44
|
subUnit: {
|
|
43
45
|
id: 2,
|
|
44
46
|
},
|
|
@@ -67,7 +69,9 @@ describe('Test select zigbee gateway', () => {
|
|
|
67
69
|
});
|
|
68
70
|
|
|
69
71
|
expect(mockedNavigate).toBeCalledWith(Routes.ZigbeeDeviceConnectGuide, {
|
|
70
|
-
|
|
72
|
+
unit: {
|
|
73
|
+
id: 1,
|
|
74
|
+
},
|
|
71
75
|
subUnit: {
|
|
72
76
|
id: 2,
|
|
73
77
|
},
|
|
@@ -44,7 +44,7 @@ const AddMenu = memo(({ unit, afterItemClick, showAdd, setHideAdd }) => {
|
|
|
44
44
|
image: <AddDeviceIcon width={43} height={43} />,
|
|
45
45
|
data: {
|
|
46
46
|
screen: Routes.SelectDeviceType,
|
|
47
|
-
params: {
|
|
47
|
+
params: { unit },
|
|
48
48
|
},
|
|
49
49
|
},
|
|
50
50
|
{
|