@eohjsc/react-native-smart-city 0.2.82 → 0.2.85
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/assets/images/Event.svg +9 -0
- package/assets/images/brightness.svg +12 -0
- package/package.json +4 -2
- package/src/Images/Common/SuccessfullyConnected.svg +4 -0
- package/src/Images/Common/eye-closed.png +0 -0
- package/src/Images/Common/eye-closed@2x.png +0 -0
- package/src/Images/Common/eye-closed@3x.png +0 -0
- package/src/Images/Common/eye.png +0 -0
- package/src/Images/Common/eye@2x.png +0 -0
- package/src/Images/Common/eye@3x.png +0 -0
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +32 -21
- package/src/commons/ActionGroup/LightActionTemplate.js +103 -0
- package/src/commons/ActionGroup/LightActionTemplateStyles.js +57 -0
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +8 -6
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +33 -31
- package/src/commons/ActionGroup/OnOffTemplate/index.js +11 -3
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +10 -7
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +5 -2
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +7 -3
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +33 -24
- package/src/commons/ActionGroup/__test__/LightActionTemplate.test.js +59 -0
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +18 -6
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +9 -1
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +25 -13
- package/src/commons/ActionGroup/__test__/index.test.js +48 -14
- package/src/commons/ActionGroup/index.js +3 -0
- package/src/commons/Automate/ItemAutomate.js +1 -1
- package/src/commons/Automate/ItemAutomateStyles.js +5 -1
- package/src/commons/CardShadow/index.js +5 -2
- package/src/commons/CardShadow/styles.js +2 -3
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +16 -0
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +42 -0
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +27 -0
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +18 -0
- package/src/commons/ConnectingProcess/index.js +202 -0
- package/src/commons/ConnectingProcess/styles.js +69 -0
- package/src/commons/Device/HorizontalBarChart.js +7 -1
- package/src/commons/Device/ItemDevice.js +8 -5
- package/src/commons/Device/LinearChart.js +1 -0
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -1
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +1 -1
- package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
- package/src/commons/EmergencyButton/AlertSent.js +2 -2
- package/src/commons/Form/TextInputPassword.js +1 -1
- package/src/commons/FullLoading/index.js +35 -0
- package/src/commons/SubUnit/Favorites/index.js +2 -0
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +3 -0
- package/src/commons/SubUnit/ShortDetail.js +7 -1
- package/src/commons/index.js +2 -0
- package/src/configs/API.js +6 -4
- package/src/configs/Constants.js +25 -0
- package/src/configs/Images.js +2 -0
- package/src/context/actionType.ts +2 -0
- package/src/context/reducer.ts +10 -0
- package/src/hooks/Common/useBlockBackAndroid.js +3 -1
- package/src/iot/RemoteControl/Internet.js +8 -1
- package/src/iot/RemoteControl/index.js +4 -2
- package/src/navigations/AddDeviceStack.js +10 -0
- package/src/screens/AddCommon/SelectSubUnit.js +29 -6
- package/src/screens/AddCommon/SelectUnit.js +24 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +120 -1
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +16 -1
- package/src/screens/AddNewAction/SelectAction.js +46 -28
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -3
- package/src/screens/AddNewAutoSmart/index.js +18 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +55 -16
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +52 -23
- package/src/screens/AddNewGateway/SelectGateway.js +132 -0
- package/src/screens/AddNewGateway/SelectGatewayStyles.js +55 -0
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -52
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +2 -2
- package/src/screens/Device/EditDevice/index.js +2 -2
- package/src/screens/Device/__test__/detail.test.js +18 -11
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +2 -2
- package/src/screens/Device/components/SensorDisplayItem.js +2 -2
- package/src/screens/Device/detail.js +64 -26
- package/src/screens/Device/styles.js +2 -0
- package/src/screens/Notification/__test__/NotificationItem.test.js +197 -15
- package/src/screens/Notification/components/NotificationItem.js +188 -14
- package/src/screens/Notification/styles/NotificationItemStyles.js +3 -3
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +10 -7
- package/src/screens/ScanChipQR/hooks/index.js +48 -40
- package/src/screens/SubUnit/AddSubUnit.js +4 -1
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +148 -0
- package/src/screens/Unit/Detail.js +33 -1
- package/src/screens/Unit/ManageUnit.js +1 -1
- package/src/screens/Unit/ManageUnitStyles.js +0 -6
- package/src/screens/Unit/SmartAccount.js +5 -1
- package/src/screens/Unit/Summaries.js +2 -2
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +10 -0
- package/src/screens/Unit/__test__/Detail.test.js +10 -0
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +21 -2
- package/src/screens/UnitSummary/__test__/index.test.js +3 -3
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -2
- package/src/screens/UnitSummary/index.js +52 -9
- package/src/utils/Apis/axios.js +1 -1
- package/src/utils/I18n/translations/en.json +16 -0
- package/src/utils/I18n/translations/vi.json +16 -1
- package/src/utils/Route/index.js +2 -0
|
@@ -34,11 +34,11 @@ const NotificationItem = memo(({ item }) => {
|
|
|
34
34
|
const customColorText = (text, params) => {
|
|
35
35
|
return text.split('**').map((str, i) =>
|
|
36
36
|
i % 2 === 0 ? (
|
|
37
|
-
<Text type="Body" key={i}>
|
|
37
|
+
<Text type="Body" key={i} style={styles.textNotification}>
|
|
38
38
|
{str}
|
|
39
39
|
</Text>
|
|
40
40
|
) : (
|
|
41
|
-
<Text type="Body" bold key={i}>
|
|
41
|
+
<Text type="Body" bold key={i} style={styles.textNotification}>
|
|
42
42
|
{params[(i - 1) / 2]}
|
|
43
43
|
</Text>
|
|
44
44
|
)
|
|
@@ -49,6 +49,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
49
49
|
const paramsJSON = JSON.parse(params.replace(regex, '"'));
|
|
50
50
|
const booking_id = paramsJSON.booking_id && paramsJSON.booking_id;
|
|
51
51
|
const unitId = paramsJSON?.unit_id;
|
|
52
|
+
const sensorId = paramsJSON?.sensor_id;
|
|
52
53
|
switch (content_code) {
|
|
53
54
|
case NOTIFICATION_TYPES.NOTIFY_INVITE_MEMBER:
|
|
54
55
|
return {
|
|
@@ -79,7 +80,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
79
80
|
),
|
|
80
81
|
redirect: () =>
|
|
81
82
|
navigation.navigate(Routes.SmartParkingStack, {
|
|
82
|
-
|
|
83
|
+
screen: Routes.SmartParkingBookingDetails,
|
|
83
84
|
params: { id: booking_id },
|
|
84
85
|
}),
|
|
85
86
|
};
|
|
@@ -92,7 +93,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
92
93
|
),
|
|
93
94
|
redirect: () =>
|
|
94
95
|
navigation.navigate(Routes.SmartParkingStack, {
|
|
95
|
-
|
|
96
|
+
screen: Routes.SmartParkingBookingDetails,
|
|
96
97
|
params: { id: booking_id },
|
|
97
98
|
}),
|
|
98
99
|
};
|
|
@@ -104,7 +105,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
104
105
|
),
|
|
105
106
|
redirect: () =>
|
|
106
107
|
navigation.navigate(Routes.SmartParkingStack, {
|
|
107
|
-
|
|
108
|
+
screen: Routes.SmartParkingBookingDetails,
|
|
108
109
|
params: { id: booking_id },
|
|
109
110
|
}),
|
|
110
111
|
};
|
|
@@ -116,7 +117,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
116
117
|
),
|
|
117
118
|
redirect: () =>
|
|
118
119
|
navigation.navigate(Routes.SmartParkingStack, {
|
|
119
|
-
|
|
120
|
+
screen: Routes.MyBookingList,
|
|
120
121
|
params: { tab: 1 },
|
|
121
122
|
}),
|
|
122
123
|
};
|
|
@@ -128,7 +129,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
128
129
|
),
|
|
129
130
|
redirect: () =>
|
|
130
131
|
navigation.navigate(Routes.SmartParkingStack, {
|
|
131
|
-
|
|
132
|
+
screen: Routes.MyBookingList,
|
|
132
133
|
params: { tab: 1 },
|
|
133
134
|
}),
|
|
134
135
|
};
|
|
@@ -140,7 +141,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
140
141
|
),
|
|
141
142
|
redirect: () =>
|
|
142
143
|
navigation.navigate(Routes.SmartParkingStack, {
|
|
143
|
-
|
|
144
|
+
screen: Routes.SmartParkingBookingDetails,
|
|
144
145
|
params: { id: booking_id },
|
|
145
146
|
}),
|
|
146
147
|
};
|
|
@@ -152,7 +153,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
152
153
|
),
|
|
153
154
|
redirect: () =>
|
|
154
155
|
navigation.navigate(Routes.SmartParkingStack, {
|
|
155
|
-
|
|
156
|
+
screen: Routes.MyBookingList,
|
|
156
157
|
params: { tab: 1 },
|
|
157
158
|
}),
|
|
158
159
|
};
|
|
@@ -167,7 +168,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
167
168
|
),
|
|
168
169
|
redirect: () =>
|
|
169
170
|
navigation.navigate(Routes.SmartParkingStack, {
|
|
170
|
-
|
|
171
|
+
screen: Routes.SmartParkingBookingDetails,
|
|
171
172
|
params: { id: violated_booking_id || booking_id },
|
|
172
173
|
}),
|
|
173
174
|
};
|
|
@@ -179,7 +180,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
179
180
|
),
|
|
180
181
|
redirect: () =>
|
|
181
182
|
navigation.navigate(Routes.SmartParkingStack, {
|
|
182
|
-
|
|
183
|
+
screen: Routes.SmartParkingBookingDetails,
|
|
183
184
|
params: { id: booking_id },
|
|
184
185
|
}),
|
|
185
186
|
};
|
|
@@ -191,7 +192,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
191
192
|
),
|
|
192
193
|
redirect: () =>
|
|
193
194
|
navigation.navigate(Routes.SmartParkingStack, {
|
|
194
|
-
|
|
195
|
+
screen: Routes.SmartParkingBookingDetails,
|
|
195
196
|
params: { id: booking_id },
|
|
196
197
|
}),
|
|
197
198
|
};
|
|
@@ -204,7 +205,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
204
205
|
),
|
|
205
206
|
redirect: () =>
|
|
206
207
|
navigation.navigate(Routes.SmartParkingStack, {
|
|
207
|
-
|
|
208
|
+
screen: Routes.SmartParkingBookingDetails,
|
|
208
209
|
params: { id: new_booking_id },
|
|
209
210
|
}),
|
|
210
211
|
};
|
|
@@ -216,10 +217,135 @@ const NotificationItem = memo(({ item }) => {
|
|
|
216
217
|
),
|
|
217
218
|
redirect: () =>
|
|
218
219
|
navigation.navigate(Routes.SmartParkingStack, {
|
|
219
|
-
|
|
220
|
+
screen: Routes.SmartParkingBookingDetails,
|
|
220
221
|
params: { id: booking_id },
|
|
221
222
|
}),
|
|
222
223
|
};
|
|
224
|
+
case NOTIFICATION_TYPES.NOTIFY_INDICATOR:
|
|
225
|
+
const { sensor_type, summary_id } = paramsJSON;
|
|
226
|
+
switch (sensor_type) {
|
|
227
|
+
case 'air_quality':
|
|
228
|
+
return {
|
|
229
|
+
content: customColorText(
|
|
230
|
+
t('text_notification_content_air_quality_high'),
|
|
231
|
+
arrParams
|
|
232
|
+
),
|
|
233
|
+
redirect: () =>
|
|
234
|
+
navigation.navigate(Routes.UnitStack, {
|
|
235
|
+
screen: Routes.UnitSummary,
|
|
236
|
+
params: {
|
|
237
|
+
summaryId: summary_id,
|
|
238
|
+
unitId,
|
|
239
|
+
},
|
|
240
|
+
}),
|
|
241
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
242
|
+
};
|
|
243
|
+
case 'turbidity':
|
|
244
|
+
return {
|
|
245
|
+
content: customColorText(
|
|
246
|
+
t('text_notification_content_turbility_high'),
|
|
247
|
+
arrParams
|
|
248
|
+
),
|
|
249
|
+
redirect: () =>
|
|
250
|
+
navigation.navigate(Routes.UnitStack, {
|
|
251
|
+
screen: Routes.UnitSummary,
|
|
252
|
+
params: {
|
|
253
|
+
summaryId: summary_id,
|
|
254
|
+
unitId,
|
|
255
|
+
},
|
|
256
|
+
}),
|
|
257
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
258
|
+
};
|
|
259
|
+
case 'ph':
|
|
260
|
+
return {
|
|
261
|
+
content: customColorText(
|
|
262
|
+
t('text_notification_content_pH_index_high'),
|
|
263
|
+
arrParams
|
|
264
|
+
),
|
|
265
|
+
redirect: () =>
|
|
266
|
+
navigation.navigate(Routes.UnitStack, {
|
|
267
|
+
screen: Routes.UnitSummary,
|
|
268
|
+
params: {
|
|
269
|
+
summaryId: summary_id,
|
|
270
|
+
unitId,
|
|
271
|
+
},
|
|
272
|
+
}),
|
|
273
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
274
|
+
};
|
|
275
|
+
case 'clo':
|
|
276
|
+
return {
|
|
277
|
+
content: customColorText(
|
|
278
|
+
t('text_notification_content_clo_high'),
|
|
279
|
+
arrParams
|
|
280
|
+
),
|
|
281
|
+
redirect: () =>
|
|
282
|
+
navigation.navigate(Routes.UnitStack, {
|
|
283
|
+
screen: Routes.UnitSummary,
|
|
284
|
+
params: {
|
|
285
|
+
summaryId: summary_id,
|
|
286
|
+
unitId,
|
|
287
|
+
},
|
|
288
|
+
}),
|
|
289
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
290
|
+
};
|
|
291
|
+
case 'uv':
|
|
292
|
+
return {
|
|
293
|
+
content: customColorText(
|
|
294
|
+
t('text_notification_content_uv_index_high'),
|
|
295
|
+
arrParams
|
|
296
|
+
),
|
|
297
|
+
redirect: () =>
|
|
298
|
+
navigation.navigate(Routes.UnitStack, {
|
|
299
|
+
screen: Routes.UnitSummary,
|
|
300
|
+
params: {
|
|
301
|
+
summaryId: summary_id,
|
|
302
|
+
unitId,
|
|
303
|
+
},
|
|
304
|
+
}),
|
|
305
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
306
|
+
};
|
|
307
|
+
case 'smoke':
|
|
308
|
+
return {
|
|
309
|
+
content: customColorText(
|
|
310
|
+
t('text_notification_content_smoke'),
|
|
311
|
+
arrParams
|
|
312
|
+
),
|
|
313
|
+
redirect: () =>
|
|
314
|
+
navigation.navigate(Routes.UnitStack, {
|
|
315
|
+
screen: Routes.DeviceDetail,
|
|
316
|
+
params: {
|
|
317
|
+
unitId,
|
|
318
|
+
sensorId,
|
|
319
|
+
},
|
|
320
|
+
}),
|
|
321
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
322
|
+
};
|
|
323
|
+
case 'fire':
|
|
324
|
+
return {
|
|
325
|
+
content: customColorText(
|
|
326
|
+
t('text_notification_content_fire'),
|
|
327
|
+
arrParams
|
|
328
|
+
),
|
|
329
|
+
redirect: () =>
|
|
330
|
+
navigation.navigate(Routes.UnitStack, {
|
|
331
|
+
screen: Routes.DeviceDetail,
|
|
332
|
+
params: {
|
|
333
|
+
unitId,
|
|
334
|
+
sensorId,
|
|
335
|
+
},
|
|
336
|
+
}),
|
|
337
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
338
|
+
};
|
|
339
|
+
default:
|
|
340
|
+
return {
|
|
341
|
+
content: customColorText(
|
|
342
|
+
t('this_notification_will_be_updated_soon')
|
|
343
|
+
),
|
|
344
|
+
redirect: () => null,
|
|
345
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
|
|
223
349
|
case NOTIFICATION_TYPES.NOTIFY_REMOVE_UNIT:
|
|
224
350
|
const unitOwerName = paramsJSON?.unit_owner_name;
|
|
225
351
|
const textNotify = unitOwerName
|
|
@@ -272,6 +398,54 @@ const NotificationItem = memo(({ item }) => {
|
|
|
272
398
|
<IconComponent icon={'home'} style={styles.backgroundSummer} />
|
|
273
399
|
),
|
|
274
400
|
};
|
|
401
|
+
case NOTIFICATION_TYPES.NOTIFY_DEVICE_DISCONNECT:
|
|
402
|
+
return {
|
|
403
|
+
content: customColorText(
|
|
404
|
+
t('text_notification_content_divice_disconnect'),
|
|
405
|
+
arrParams
|
|
406
|
+
),
|
|
407
|
+
redirect: () => {
|
|
408
|
+
navigation.navigate(Routes.UnitStack, {
|
|
409
|
+
screen: Routes.DeviceDetail,
|
|
410
|
+
params: {
|
|
411
|
+
unitId,
|
|
412
|
+
sensorId,
|
|
413
|
+
},
|
|
414
|
+
});
|
|
415
|
+
},
|
|
416
|
+
};
|
|
417
|
+
case NOTIFICATION_TYPES.NOTIFY_UPDATE_ADDRESS:
|
|
418
|
+
return {
|
|
419
|
+
content: customColorText(
|
|
420
|
+
t('text_notification_content_update_address'),
|
|
421
|
+
arrParams
|
|
422
|
+
),
|
|
423
|
+
redirect: () => {
|
|
424
|
+
navigation.navigate(Routes.UnitStack, {
|
|
425
|
+
screen: Routes.UnitDetail,
|
|
426
|
+
params: {
|
|
427
|
+
unitId,
|
|
428
|
+
},
|
|
429
|
+
});
|
|
430
|
+
},
|
|
431
|
+
};
|
|
432
|
+
case NOTIFICATION_TYPES.NOTIFY_RENAME_SUB_UNIT:
|
|
433
|
+
const stationId = paramsJSON?.sub_unit_id;
|
|
434
|
+
return {
|
|
435
|
+
content: customColorText(
|
|
436
|
+
t('text_notification_content_rename_sub_unit'),
|
|
437
|
+
arrParams
|
|
438
|
+
),
|
|
439
|
+
redirect: () => {
|
|
440
|
+
navigation.navigate(Routes.UnitStack, {
|
|
441
|
+
screen: Routes.UnitDetail,
|
|
442
|
+
params: {
|
|
443
|
+
unitId,
|
|
444
|
+
stationId,
|
|
445
|
+
},
|
|
446
|
+
});
|
|
447
|
+
},
|
|
448
|
+
};
|
|
275
449
|
default:
|
|
276
450
|
return {
|
|
277
451
|
content: customColorText(t('this_notification_will_be_updated_soon')),
|
|
@@ -27,9 +27,6 @@ export default StyleSheet.create({
|
|
|
27
27
|
time: {
|
|
28
28
|
marginTop: 12,
|
|
29
29
|
},
|
|
30
|
-
textNotification: {
|
|
31
|
-
lineHeight: 26,
|
|
32
|
-
},
|
|
33
30
|
iconNotification: {
|
|
34
31
|
width: '46%',
|
|
35
32
|
},
|
|
@@ -52,4 +49,7 @@ export default StyleSheet.create({
|
|
|
52
49
|
height: 20,
|
|
53
50
|
resizeMode: 'contain',
|
|
54
51
|
},
|
|
52
|
+
textNotification: {
|
|
53
|
+
lineHeight: 23,
|
|
54
|
+
},
|
|
55
55
|
});
|
|
@@ -62,7 +62,7 @@ describe('test ScanChipQR', () => {
|
|
|
62
62
|
expect(qrScan[0].props.loading).toEqual(false);
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
test('onScan success', async () => {
|
|
65
|
+
test('onScan addDeviceNewFlow success', async () => {
|
|
66
66
|
const new_chip = {
|
|
67
67
|
id: 1,
|
|
68
68
|
name: 'ABC',
|
|
@@ -76,7 +76,7 @@ describe('test ScanChipQR', () => {
|
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
let tree;
|
|
79
|
-
const body = { id: 1, imei: '
|
|
79
|
+
const body = { id: 1, imei: 'SENSOR-X341241', name: 'New Chip' };
|
|
80
80
|
await act(async () => {
|
|
81
81
|
tree = await create(wrapComponent(route));
|
|
82
82
|
});
|
|
@@ -87,10 +87,14 @@ describe('test ScanChipQR', () => {
|
|
|
87
87
|
qrScan.props.onScan(JSON.stringify(body));
|
|
88
88
|
});
|
|
89
89
|
expect(qrScan.props.loading).toEqual(true);
|
|
90
|
-
expect(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
expect(mockedNavigate).toHaveBeenCalledWith(Routes.AddDeviceStack, {
|
|
91
|
+
params: {
|
|
92
|
+
scan_sensor_data: { id: 1, imei: 'SENSOR-X341241', name: 'New Chip' },
|
|
93
|
+
addType: 'AddDeviceNewFlow',
|
|
94
|
+
devicePrefixName: 'SENSOR',
|
|
95
|
+
unit_id: undefined,
|
|
96
|
+
},
|
|
97
|
+
screen: 'AddGatewaySelectGateway',
|
|
94
98
|
});
|
|
95
99
|
});
|
|
96
100
|
|
|
@@ -118,7 +122,6 @@ describe('test ScanChipQR', () => {
|
|
|
118
122
|
qrScan.props.onScan(JSON.stringify(body));
|
|
119
123
|
});
|
|
120
124
|
expect(qrScan.props.loading).toEqual(true);
|
|
121
|
-
expect(axios.post).toHaveBeenCalled();
|
|
122
125
|
expect(mockedGoBack).toHaveBeenCalled();
|
|
123
126
|
});
|
|
124
127
|
});
|
|
@@ -5,8 +5,7 @@ import { axiosPost } from '../../../utils/Apis/axios';
|
|
|
5
5
|
import Routes from '../../../utils/Route';
|
|
6
6
|
|
|
7
7
|
const useChipScan = (route) => {
|
|
8
|
-
const { unit_id,
|
|
9
|
-
route.params;
|
|
8
|
+
const { unit_id, imei } = route.params;
|
|
10
9
|
const navigation = useNavigation();
|
|
11
10
|
const [loading, setLoading] = useState(false);
|
|
12
11
|
|
|
@@ -14,47 +13,56 @@ const useChipScan = (route) => {
|
|
|
14
13
|
async (data) => {
|
|
15
14
|
setLoading(true);
|
|
16
15
|
const body = JSON.parse(data);
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
);
|
|
29
|
-
if (success) {
|
|
30
|
-
if (new_chip.is_wifi) {
|
|
31
|
-
navigation.navigate(Routes.ConnectWifiWarning, {
|
|
32
|
-
wifi_ssid: new_chip.wifi_ssid,
|
|
33
|
-
wifi_pass: new_chip.wifi_pass,
|
|
34
|
-
chip_id: new_chip.id,
|
|
35
|
-
unit_id: unit_id,
|
|
16
|
+
const devicePrefixName = body?.imei.split('-')[0];
|
|
17
|
+
switch (devicePrefixName) {
|
|
18
|
+
case 'SENSOR':
|
|
19
|
+
navigation.navigate(Routes.AddDeviceStack, {
|
|
20
|
+
screen: Routes.AddGatewaySelectGateway,
|
|
21
|
+
params: {
|
|
22
|
+
scan_sensor_data: { ...body },
|
|
23
|
+
addType: 'AddDeviceNewFlow',
|
|
24
|
+
unit_id: unit_id,
|
|
25
|
+
devicePrefixName,
|
|
26
|
+
},
|
|
36
27
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
break;
|
|
29
|
+
case 'ROBOT':
|
|
30
|
+
case 'LITE':
|
|
31
|
+
{
|
|
32
|
+
const { success, data: new_chip } = await axiosPost(
|
|
33
|
+
API.UNIT.CHIP_SCAN_GET_WIFI_INFO(),
|
|
34
|
+
{
|
|
35
|
+
imei: imei || body.imei,
|
|
36
|
+
qr_code: body.imei,
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
if (success) {
|
|
40
|
+
if (new_chip.is_wifi) {
|
|
41
|
+
navigation.navigate(Routes.ConnectWifiWarning, {
|
|
42
|
+
wifi_ssid: new_chip.wifi_ssid,
|
|
43
|
+
wifi_pass: new_chip.wifi_pass,
|
|
44
|
+
chip_id: new_chip.id,
|
|
45
|
+
unit_id: unit_id,
|
|
46
|
+
devicePrefixName,
|
|
47
|
+
body,
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
navigation.navigate(Routes.ConnectingGateway, {
|
|
51
|
+
new_chip,
|
|
52
|
+
...route.params,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
navigation.goBack();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
navigation.goBack();
|
|
62
|
+
break;
|
|
45
63
|
}
|
|
46
64
|
},
|
|
47
|
-
[
|
|
48
|
-
chipName,
|
|
49
|
-
imei,
|
|
50
|
-
navigation,
|
|
51
|
-
phoneNumber,
|
|
52
|
-
route.params,
|
|
53
|
-
station,
|
|
54
|
-
unit_id,
|
|
55
|
-
wifiName,
|
|
56
|
-
wifiPass,
|
|
57
|
-
]
|
|
65
|
+
[imei, navigation, route.params, unit_id]
|
|
58
66
|
);
|
|
59
67
|
|
|
60
68
|
return {
|
|
@@ -182,7 +182,10 @@ const AddSubUnit = ({ route }) => {
|
|
|
182
182
|
/>
|
|
183
183
|
|
|
184
184
|
{isAddUnit && (
|
|
185
|
-
<TouchableWithoutFeedback
|
|
185
|
+
<TouchableWithoutFeedback
|
|
186
|
+
testID={TESTID.ADD_SUB_UNIT_BUTTON_CHOOSE_LOCATION}
|
|
187
|
+
onPress={onChooseLocation}
|
|
188
|
+
>
|
|
186
189
|
<View style={styles.wrapGeolocation}>
|
|
187
190
|
<Text style={styles.addWallpaper}>{t('geolocation')}</Text>
|
|
188
191
|
<Text
|
|
@@ -199,4 +199,152 @@ describe('Test AddSubUnit', () => {
|
|
|
199
199
|
visibilityTime: 1000,
|
|
200
200
|
});
|
|
201
201
|
});
|
|
202
|
+
|
|
203
|
+
test('test create Unit', async () => {
|
|
204
|
+
const response = {
|
|
205
|
+
success: true,
|
|
206
|
+
status: 200,
|
|
207
|
+
data: {
|
|
208
|
+
id: 2,
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
route.params = {
|
|
212
|
+
...route.params,
|
|
213
|
+
location: 'Unit address',
|
|
214
|
+
isAddUnit: true,
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
axios.post.mockImplementation(async () => {
|
|
218
|
+
return response;
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
await act(async () => {
|
|
222
|
+
tree = await create(wrapComponent(route));
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
const instance = tree.root;
|
|
226
|
+
const viewButtonBottom = await makeValidateData(instance);
|
|
227
|
+
|
|
228
|
+
await act(async () => {
|
|
229
|
+
await viewButtonBottom.props.onRightClick();
|
|
230
|
+
});
|
|
231
|
+
expect(axios.post).toHaveBeenCalled();
|
|
232
|
+
expect(mockedNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
|
|
233
|
+
screen: Routes.UnitDetail,
|
|
234
|
+
params: {
|
|
235
|
+
unitId: response.data.id,
|
|
236
|
+
routeName: Routes.DashboardStack,
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test('test choose Location', async () => {
|
|
242
|
+
route.params = {
|
|
243
|
+
...route.params,
|
|
244
|
+
location: '',
|
|
245
|
+
isAddUnit: true,
|
|
246
|
+
};
|
|
247
|
+
await act(async () => {
|
|
248
|
+
tree = await create(wrapComponent(route));
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
const instance = tree.root;
|
|
252
|
+
const buttonChooseLocation = instance.find(
|
|
253
|
+
(el) => el.props.testID === TESTID.ADD_SUB_UNIT_BUTTON_CHOOSE_LOCATION
|
|
254
|
+
);
|
|
255
|
+
act(() => {
|
|
256
|
+
buttonChooseLocation.props.onPress();
|
|
257
|
+
});
|
|
258
|
+
expect(mockedNavigate).toHaveBeenCalledWith(Routes.AddLocationMaps);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
test('test create Unit Fail', async () => {
|
|
262
|
+
const response = {
|
|
263
|
+
success: false,
|
|
264
|
+
status: 400,
|
|
265
|
+
};
|
|
266
|
+
route.params = {
|
|
267
|
+
...route.params,
|
|
268
|
+
location: 'Unit address',
|
|
269
|
+
isAddUnit: true,
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
axios.post.mockImplementation(async () => {
|
|
273
|
+
return response;
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
await act(async () => {
|
|
277
|
+
tree = await create(wrapComponent(route));
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const instance = tree.root;
|
|
281
|
+
const viewButtonBottom = await makeValidateData(instance);
|
|
282
|
+
|
|
283
|
+
await act(async () => {
|
|
284
|
+
await viewButtonBottom.props.onRightClick();
|
|
285
|
+
});
|
|
286
|
+
expect(axios.post).toHaveBeenCalled();
|
|
287
|
+
expect(Toast.show).toHaveBeenCalledWith({
|
|
288
|
+
type: 'error',
|
|
289
|
+
position: 'bottom',
|
|
290
|
+
text1: getTranslate('en', 'text_create_unit_fail'),
|
|
291
|
+
visibilityTime: 1000,
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
test('test create sub-unit type AddHassiDevice', async () => {
|
|
296
|
+
const response = {
|
|
297
|
+
status: 200,
|
|
298
|
+
success: true,
|
|
299
|
+
data: {},
|
|
300
|
+
};
|
|
301
|
+
route.params = {
|
|
302
|
+
...route.params,
|
|
303
|
+
addType: 'AddHassiDevice',
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
axios.post.mockImplementation(async () => {
|
|
307
|
+
return response;
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
await act(async () => {
|
|
311
|
+
tree = await create(wrapComponent(route));
|
|
312
|
+
});
|
|
313
|
+
const instance = tree.root;
|
|
314
|
+
const viewButtonBottom = await makeValidateData(instance);
|
|
315
|
+
await act(async () => {
|
|
316
|
+
await viewButtonBottom.props.onRightClick();
|
|
317
|
+
});
|
|
318
|
+
expect(axios.post).toHaveBeenCalled();
|
|
319
|
+
expect(mockedGoBack).toHaveBeenCalled();
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
test('test create sub-unit type AddNewGateway', async () => {
|
|
323
|
+
const response = {
|
|
324
|
+
status: 200,
|
|
325
|
+
success: true,
|
|
326
|
+
data: {},
|
|
327
|
+
};
|
|
328
|
+
route.params = {
|
|
329
|
+
...route.params,
|
|
330
|
+
addType: 'AddNewGateway',
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
axios.post.mockImplementation(async () => {
|
|
334
|
+
return response;
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
await act(async () => {
|
|
338
|
+
tree = await create(wrapComponent(route));
|
|
339
|
+
});
|
|
340
|
+
const instance = tree.root;
|
|
341
|
+
const viewButtonBottom = await makeValidateData(instance);
|
|
342
|
+
await act(async () => {
|
|
343
|
+
await viewButtonBottom.props.onRightClick();
|
|
344
|
+
});
|
|
345
|
+
expect(axios.post).toHaveBeenCalled();
|
|
346
|
+
expect(mockedNavigate).toHaveBeenCalledWith(Routes.AddCommonSelectSubUnit, {
|
|
347
|
+
...route.params,
|
|
348
|
+
});
|
|
349
|
+
});
|
|
202
350
|
});
|