@eohjsc/react-native-smart-city 0.2.79 → 0.2.83

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.
Files changed (60) hide show
  1. package/package.json +4 -4
  2. package/src/commons/ActionGroup/CurtainButtonTemplate.js +32 -21
  3. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +8 -6
  4. package/src/commons/ActionGroup/OnOffTemplate/index.js +11 -3
  5. package/src/commons/ActionGroup/OneBigButtonTemplate.js +10 -7
  6. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +5 -2
  7. package/src/commons/ActionGroup/StatesGridActionTemplate.js +7 -3
  8. package/src/commons/ActionGroup/ThreeButtonTemplate.js +33 -24
  9. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +18 -6
  10. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +9 -1
  11. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +25 -13
  12. package/src/commons/ActionGroup/__test__/index.test.js +48 -14
  13. package/src/commons/Device/HorizontalBarChart.js +8 -2
  14. package/src/commons/Device/ItemDevice.js +8 -5
  15. package/src/commons/Device/LinearChart.js +1 -1
  16. package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
  17. package/src/commons/EmergencyButton/AlertSent.js +2 -2
  18. package/src/commons/ImagePicker/__test__/ImagePicker.test.js +24 -3
  19. package/src/commons/MediaPlayerDetail/index.js +1 -0
  20. package/src/commons/SubUnit/Favorites/index.js +2 -0
  21. package/src/commons/SubUnit/ShortDetail.js +7 -1
  22. package/src/configs/API.js +2 -4
  23. package/src/configs/Constants.js +5 -0
  24. package/src/iot/RemoteControl/Internet.js +8 -1
  25. package/src/iot/RemoteControl/index.js +4 -2
  26. package/src/screens/AddCommon/SelectSubUnit.js +6 -0
  27. package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +52 -0
  28. package/src/screens/AllCamera/index.js +76 -44
  29. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +2 -2
  30. package/src/screens/Device/EditDevice/index.js +2 -2
  31. package/src/screens/Device/__test__/detail.test.js +18 -11
  32. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +2 -2
  33. package/src/screens/Device/components/SensorDisplayItem.js +2 -2
  34. package/src/screens/Device/detail.js +58 -20
  35. package/src/screens/Notification/__test__/NotificationItem.test.js +186 -14
  36. package/src/screens/Notification/components/NotificationItem.js +147 -3
  37. package/src/screens/Notification/index.js +4 -1
  38. package/src/screens/Notification/styles/NotificationItemStyles.js +3 -3
  39. package/src/screens/Sharing/SelectUser.js +17 -10
  40. package/src/screens/Sharing/__test__/SelectUser.test.js +73 -0
  41. package/src/screens/SubUnit/AddSubUnit.js +4 -1
  42. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +148 -0
  43. package/src/screens/Unit/Detail.js +28 -4
  44. package/src/screens/Unit/ManageUnit.js +88 -32
  45. package/src/screens/Unit/ManageUnitStyles.js +20 -0
  46. package/src/screens/Unit/SmartAccount.js +6 -2
  47. package/src/screens/Unit/Summaries.js +2 -2
  48. package/src/screens/Unit/__test__/CheckSendEmail.test.js +10 -0
  49. package/src/screens/Unit/__test__/Detail.test.js +53 -0
  50. package/src/screens/Unit/__test__/ManageUnit.test.js +69 -0
  51. package/src/screens/Unit/__test__/SmartAccount.test.js +37 -8
  52. package/src/screens/Unit/components/__test__/SharedUnit.test.js +21 -2
  53. package/src/screens/Unit/hook/useStateAlertRemove.js +1 -1
  54. package/src/screens/UnitSummary/__test__/index.test.js +3 -3
  55. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -2
  56. package/src/screens/UnitSummary/index.js +52 -9
  57. package/src/utils/Apis/axios.js +7 -2
  58. package/src/utils/I18n/translations/en.json +10 -1
  59. package/src/utils/I18n/translations/vi.json +10 -1
  60. package/src/{screens/Notification → utils}/Monitor.js +1 -1
@@ -75,6 +75,9 @@ describe('Test ActionGroup', () => {
75
75
  id: 20,
76
76
  key: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
77
77
  };
78
+ const sensor = {
79
+ name: 'Sensor name',
80
+ };
78
81
  let actionGroupData;
79
82
  let wrapper;
80
83
 
@@ -154,7 +157,9 @@ describe('Test ActionGroup', () => {
154
157
  const actionGroup = actionGroupData;
155
158
  const mockDoAction = jest.fn();
156
159
  await act(() => {
157
- wrapper = renderer.create(wrapComponent(actionGroup, mockDoAction));
160
+ wrapper = renderer.create(
161
+ wrapComponent(actionGroup, mockDoAction, sensor)
162
+ );
158
163
  });
159
164
  const instance = wrapper.root;
160
165
  const buttons = instance.findAllByType(TouchableOpacity);
@@ -170,21 +175,27 @@ describe('Test ActionGroup', () => {
170
175
  });
171
176
  expect(mockDoAction).toHaveBeenCalledTimes(1);
172
177
  expect(mockDoAction).toHaveBeenCalledWith(
173
- actionGroup.configuration.action1_data
178
+ actionGroup.configuration.action1_data,
179
+ null,
180
+ 'Sensor name up'
174
181
  );
175
182
  act(() => {
176
183
  buttons[1].props.onPress();
177
184
  });
178
185
  expect(mockDoAction).toHaveBeenCalledTimes(2);
179
186
  expect(mockDoAction).toHaveBeenCalledWith(
180
- actionGroup.configuration.action2_data
187
+ actionGroup.configuration.action2_data,
188
+ null,
189
+ 'Sensor name stop'
181
190
  );
182
191
  act(() => {
183
192
  buttons[2].props.onPress();
184
193
  });
185
194
  expect(mockDoAction).toHaveBeenCalledTimes(3);
186
195
  expect(mockDoAction).toHaveBeenCalledWith(
187
- actionGroup.configuration.action3_data
196
+ actionGroup.configuration.action3_data,
197
+ null,
198
+ 'Sensor name down'
188
199
  );
189
200
  });
190
201
 
@@ -220,7 +231,9 @@ describe('Test ActionGroup', () => {
220
231
  };
221
232
  const mockDoAction = jest.fn();
222
233
  await act(() => {
223
- wrapper = renderer.create(wrapComponent(actionGroup, mockDoAction));
234
+ wrapper = renderer.create(
235
+ wrapComponent(actionGroup, mockDoAction, sensor)
236
+ );
224
237
  });
225
238
  const instance = wrapper.root;
226
239
  const buttons = instance.findAllByType(TouchableOpacity);
@@ -236,21 +249,27 @@ describe('Test ActionGroup', () => {
236
249
  });
237
250
  expect(mockDoAction).toHaveBeenCalledTimes(1);
238
251
  expect(mockDoAction).toHaveBeenCalledWith(
239
- actionGroup.configuration.action1_data
252
+ actionGroup.configuration.action1_data,
253
+ null,
254
+ 'Sensor name up'
240
255
  );
241
256
  act(() => {
242
257
  buttons[1].props.onPress();
243
258
  });
244
259
  expect(mockDoAction).toHaveBeenCalledTimes(2);
245
260
  expect(mockDoAction).toHaveBeenCalledWith(
246
- actionGroup.configuration.action2_data
261
+ actionGroup.configuration.action2_data,
262
+ null,
263
+ 'Sensor name stop'
247
264
  );
248
265
  act(() => {
249
266
  buttons[2].props.onPress();
250
267
  });
251
268
  expect(mockDoAction).toHaveBeenCalledTimes(3);
252
269
  expect(mockDoAction).toHaveBeenCalledWith(
253
- actionGroup.configuration.action3_data
270
+ actionGroup.configuration.action3_data,
271
+ null,
272
+ 'Sensor name down'
254
273
  );
255
274
  });
256
275
 
@@ -279,7 +298,9 @@ describe('Test ActionGroup', () => {
279
298
  },
280
299
  };
281
300
  await act(() => {
282
- wrapper = renderer.create(wrapComponent(actionGroup, mockDoAction));
301
+ wrapper = renderer.create(
302
+ wrapComponent(actionGroup, mockDoAction, sensor)
303
+ );
283
304
  });
284
305
  const instance = wrapper.root;
285
306
  const buttons = instance.findAllByType(TouchableOpacity);
@@ -288,7 +309,11 @@ describe('Test ActionGroup', () => {
288
309
  buttons[0].props.onPress();
289
310
  });
290
311
  expect(mockDoAction).toHaveBeenCalledTimes(1);
291
- expect(mockDoAction).toHaveBeenCalledWith(action_data);
312
+ expect(mockDoAction).toHaveBeenCalledWith(
313
+ action_data,
314
+ null,
315
+ 'Sensor name up'
316
+ );
292
317
  });
293
318
 
294
319
  test('render ActionGroup on_off_button_action_template', async () => {
@@ -303,9 +328,12 @@ describe('Test ActionGroup', () => {
303
328
  icon_off: 'caret-up',
304
329
  text_off: 'OFF',
305
330
  },
331
+ title: 'Power',
306
332
  };
307
333
  await act(() => {
308
- wrapper = renderer.create(wrapComponent(actionGroup, mockDoAction, {}));
334
+ wrapper = renderer.create(
335
+ wrapComponent(actionGroup, mockDoAction, sensor)
336
+ );
309
337
  });
310
338
  const instance = wrapper.root;
311
339
  const buttons = instance.findAllByType(TouchableOpacity);
@@ -329,7 +357,9 @@ describe('Test ActionGroup', () => {
329
357
  },
330
358
  };
331
359
  await act(() => {
332
- wrapper = renderer.create(wrapComponent(actionGroup, mockDoAction, {}));
360
+ wrapper = renderer.create(
361
+ wrapComponent(actionGroup, mockDoAction, sensor)
362
+ );
333
363
  });
334
364
  const instance = wrapper.root;
335
365
  const text = instance.findAllByType(Text);
@@ -366,7 +396,9 @@ describe('Test ActionGroup', () => {
366
396
  },
367
397
  };
368
398
  await act(() => {
369
- wrapper = renderer.create(wrapComponent(actionGroup, mockDoAction, {}));
399
+ wrapper = renderer.create(
400
+ wrapComponent(actionGroup, mockDoAction, sensor)
401
+ );
370
402
  });
371
403
  const instance = wrapper.root;
372
404
  const texts = instance.findAllByType(Text);
@@ -413,7 +445,9 @@ describe('Test ActionGroup', () => {
413
445
  };
414
446
  const mockDoAction = jest.fn();
415
447
  await act(() => {
416
- wrapper = renderer.create(wrapComponent(actionGroup, mockDoAction, {}));
448
+ wrapper = renderer.create(
449
+ wrapComponent(actionGroup, mockDoAction, sensor)
450
+ );
417
451
  });
418
452
  const instance = wrapper.root;
419
453
 
@@ -1,6 +1,6 @@
1
1
  import React, { memo, useEffect, useMemo, useState } from 'react';
2
2
  import { View, StyleSheet } from 'react-native';
3
- import HighchartsReactNative from '@highcharts/highcharts-react-native/src/HighchartsReactNative';
3
+ import HighchartsReactNative from '@eohjsc/highcharts';
4
4
  import { isEmpty } from 'lodash';
5
5
 
6
6
  import { Colors } from '../../configs';
@@ -33,6 +33,7 @@ const HorizontalBarChart = memo(({ datas, config }) => {
33
33
  },
34
34
  yAxis: {
35
35
  min: 0,
36
+ minRange: 0.5,
36
37
  title: {
37
38
  text: null,
38
39
  },
@@ -55,7 +56,12 @@ const HorizontalBarChart = memo(({ datas, config }) => {
55
56
  useHTML: true,
56
57
  formatter: function () {
57
58
  const { unit, price } = JSON.parse(this.series.name);
58
- const textColor = this.color === '#00979D' ? '#FFFFFF' : '#262626';
59
+ const textColor =
60
+ this.color === '#00979D'
61
+ ? this.y === 0
62
+ ? '#262626'
63
+ : '#FFFFFF'
64
+ : '#262626';
59
65
  const valueStyle = `color:${textColor};font-weight:normal;font-size:12px;`;
60
66
  const costStyle = valueStyle + 'font-weight:bold;';
61
67
 
@@ -30,6 +30,7 @@ const ItemDevice = memo(
30
30
  sensor,
31
31
  unit,
32
32
  station,
33
+ isNetworkConnected,
33
34
  isGGHomeConnected,
34
35
  status,
35
36
  wrapStyle,
@@ -39,9 +40,9 @@ const ItemDevice = memo(
39
40
 
40
41
  const goToSensorDisplay = useCallback(() => {
41
42
  navigation.navigate(Routes.DeviceDetail, {
42
- unit,
43
+ unitData: unit,
43
44
  station,
44
- sensor,
45
+ sensorData: sensor,
45
46
  title,
46
47
  isGGHomeConnected,
47
48
  });
@@ -56,13 +57,15 @@ const ItemDevice = memo(
56
57
  );
57
58
  };
58
59
 
59
- const isNetworkConnected =
60
- status === undefined ? sensor.is_connected : status.is_connected;
60
+ const isConnectedViaInternet =
61
+ status === undefined
62
+ ? isNetworkConnected && sensor.is_connected
63
+ : isNetworkConnected && status.is_connected;
61
64
  const isBLEConnected = isDeviceConnected(
62
65
  sensor?.remote_control_options?.bluetooth?.address
63
66
  );
64
67
  const isConnected =
65
- isNetworkConnected || isGGHomeConnected || isBLEConnected;
68
+ isConnectedViaInternet || isGGHomeConnected || isBLEConnected;
66
69
  const borderColor = isConnected ? Colors.Gray4 : Colors.Red6;
67
70
  const textConnected = isConnected ? t('connected') : t('disconnected');
68
71
 
@@ -1,6 +1,6 @@
1
1
  import React, { memo, useState, useEffect, useCallback } from 'react';
2
2
  import { StyleSheet, View } from 'react-native';
3
- import HighchartsReactNative from '@highcharts/highcharts-react-native';
3
+ import HighchartsReactNative from '@eohjsc/highcharts';
4
4
  import moment from 'moment';
5
5
  import { Colors } from '../../configs';
6
6
 
@@ -44,9 +44,9 @@ const AlertSendConfirm = ({
44
44
  <Text
45
45
  type="Body"
46
46
  style={styles.textLocation}
47
- >{`${unit.name} - ${station.name}`}</Text>
47
+ >{`${unit?.name} - ${station?.name}`}</Text>
48
48
  <Text type="Body" style={styles.textAddress}>
49
- {unit.address}
49
+ {unit?.address}
50
50
  </Text>
51
51
  </View>
52
52
  </ButtonPopup>
@@ -58,7 +58,7 @@ const AlertSent = ({
58
58
  <Text
59
59
  type="H5"
60
60
  style={styles.location}
61
- >{`${unit.name} - ${station.name}`}</Text>
61
+ >{`${unit?.name} - ${station?.name}`}</Text>
62
62
  <IconFill name="alert" size={42} style={styles.alert} />
63
63
  <Text semibold style={styles.textAlertSent}>
64
64
  {data.title}
@@ -67,7 +67,7 @@ const AlertSent = ({
67
67
  {data.message}
68
68
  {isDashboard && (
69
69
  <Text type="H4" semibold>
70
- {` ${unit.name}: ${station.name}.`}
70
+ {` ${unit?.name}: ${station?.name}.`}
71
71
  </Text>
72
72
  )}
73
73
  </Text>
@@ -41,9 +41,9 @@ describe('Test ImagePicker', () => {
41
41
  Platform.OS = 'android';
42
42
  const options = {
43
43
  mediaType: 'photo',
44
- maxWidth: 1024,
45
- quality: 0.8,
46
- saveToPhotos: true,
44
+ compressImageMaxWidth: 1280,
45
+ compressImageMaxHeight: 720,
46
+ compressImageQuality: 0.8,
47
47
  };
48
48
  act(() => {
49
49
  tree = renderer.create(wrapComponent(options));
@@ -51,5 +51,26 @@ describe('Test ImagePicker', () => {
51
51
  const instance = tree.root;
52
52
  const textInputs = instance.findAllByType(ButtonPopup);
53
53
  expect(textInputs.length).toBe(1);
54
+ act(() => {
55
+ textInputs[0].props.onPressMain();
56
+ });
57
+ });
58
+ test('create ImagePicker onChooseFile', () => {
59
+ Platform.OS = 'android';
60
+ const options = {
61
+ mediaType: 'photo',
62
+ compressImageMaxWidth: 1280,
63
+ compressImageMaxHeight: 720,
64
+ compressImageQuality: 0.8,
65
+ };
66
+ act(() => {
67
+ tree = renderer.create(wrapComponent(options));
68
+ });
69
+ const instance = tree.root;
70
+ const textInputs = instance.findAllByType(ButtonPopup);
71
+ expect(textInputs.length).toBe(1);
72
+ act(() => {
73
+ textInputs[0].props.onPressSecondary();
74
+ });
54
75
  });
55
76
  });
@@ -164,6 +164,7 @@ const MediaPlayerDetail = ({
164
164
  activeOpacity={1}
165
165
  style={styles.videoBtn}
166
166
  onPress={onTapGoDetail}
167
+ testID={TESTID.SUB_UNIT_GO_DETAIL}
167
168
  >
168
169
  {paused ? (
169
170
  <View style={[styles.player, style]}>
@@ -15,6 +15,7 @@ const SubUnitFavorites = ({
15
15
  unit,
16
16
  isOwner,
17
17
  favorites,
18
+ isNetworkConnected,
18
19
  isGGHomeConnected,
19
20
  wrapItemStyle,
20
21
  }) => {
@@ -71,6 +72,7 @@ const SubUnitFavorites = ({
71
72
  sensor={sensor}
72
73
  unit={unit}
73
74
  station={sensor.station}
75
+ isNetworkConnected={isNetworkConnected}
74
76
  isGGHomeConnected={isGGHomeConnected}
75
77
  status={sensorsStatus.find((s) => s.id === sensor.id)}
76
78
  wrapStyle={wrapItemStyle}
@@ -19,7 +19,12 @@ const { standardizeWidth, standardizeHeight } = standardizeCameraScreenSize(
19
19
  Device.screenWidth - 32
20
20
  );
21
21
 
22
- const ShortDetailSubUnit = ({ unit, station, isGGHomeConnected }) => {
22
+ const ShortDetailSubUnit = ({
23
+ unit,
24
+ station,
25
+ isNetworkConnected,
26
+ isGGHomeConnected,
27
+ }) => {
23
28
  const t = useTranslations();
24
29
  const isFocused = useIsFocused();
25
30
  const { navigate } = useNavigation();
@@ -146,6 +151,7 @@ const ShortDetailSubUnit = ({ unit, station, isGGHomeConnected }) => {
146
151
  sensor={sensor}
147
152
  unit={unit}
148
153
  station={station}
154
+ isNetworkConnected={isNetworkConnected}
149
155
  isGGHomeConnected={isGGHomeConnected}
150
156
  status={sensorsStatus.find((s) => s.id === sensor.id)}
151
157
  />
@@ -53,6 +53,8 @@ const API = {
53
53
  SCConfig.apiRoot + '/property_manager/stations/check_chip_finalized/',
54
54
  },
55
55
  SENSOR: {
56
+ SENSOR_DETAIL: (id) =>
57
+ SCConfig.apiRoot + `/property_manager/sensors/${id}/`,
56
58
  DISPLAY: (id) =>
57
59
  SCConfig.apiRoot + `/property_manager/sensors/${id}/display/`,
58
60
  DISPLAY_VALUES: (id) =>
@@ -82,10 +84,6 @@ const API = {
82
84
  `/property_manager/${unit_id}/sub_units/${station_id}/devices/${id}/remove_from_favourites/`,
83
85
  DISPLAY_ACTIONS: (id) =>
84
86
  SCConfig.apiRoot + `/property_manager/sensors/${id}/display_actions/`,
85
- RENAME_SENSOR: (id) =>
86
- SCConfig.apiRoot + `/property_manager/sensors/${id}/`,
87
- REMOVE_SENSOR: (id) =>
88
- SCConfig.apiRoot + `/property_manager/sensors/${id}/`,
89
87
  CHANGE_SUB_UNIT: (unit_id, station_id, id) =>
90
88
  SCConfig.apiRoot +
91
89
  `/property_manager/${unit_id}/sub_units/${station_id}/devices/${id}/change_sub_unit/`,
@@ -210,6 +210,7 @@ export const TESTID = {
210
210
  SUB_UNIT_STATION: 'SUB_UNIT_STATION',
211
211
  SUB_UNIT_SELECT_AUTOMATE_TYPE: 'SUB_UNIT_SELECT_AUTOMATE_TYPE',
212
212
  SUB_UNIT_TEXT_DROPDOWN: 'SUB_UNIT_TEXT_DROPDOWN',
213
+ SUB_UNIT_GO_DETAIL: 'SUB_UNIT_GO_DETAIL',
213
214
 
214
215
  // NavBar
215
216
  NAVBAR_ICON_BARS: 'NAVBAR_ICON_BARS',
@@ -339,6 +340,7 @@ export const TESTID = {
339
340
 
340
341
  // ADD SUB UNIT
341
342
  ADD_SUB_UNIT_BUTTON_CHOOSE_PHOTO: 'ADD_SUB_UNIT_BUTTON_CHOOSE_PHOTO',
343
+ ADD_SUB_UNIT_BUTTON_CHOOSE_LOCATION: 'ADD_SUB_UNIT_BUTTON_CHOOSE_LOCATION',
342
344
 
343
345
  SCANNING_RESPONSE_TITLE: 'SCANNING_RESPONSE_TITLE',
344
346
  SCANNING_RESPONSE_DESCRIPTION: 'SCANNING_RESPONSE_DESCRIPTION',
@@ -436,6 +438,7 @@ export const TESTID = {
436
438
  MANAGE_UNIT_LIST_EMERGENCY_CONTACT: 'MANAGE_UNIT_LIST_EMERGENCY_CONTACT',
437
439
  MANAGE_UNIT_DETAIL_LIST_CONTACT_BUTTON:
438
440
  'MANAGE_UNIT_DETAIL_LIST_CONTACT_BUTTON',
441
+ MANAGE_UNIT_GO_TO_SUBUNIT: 'MANAGE_UNIT_GO_TO_SUBUNIT',
439
442
 
440
443
  // Add Vehicle
441
444
  ADD_VEHICLE_TAKE_PHOTO: 'ADD_VEHICLE_TAKE_PHOTO',
@@ -632,9 +635,11 @@ export const NOTIFICATION_TYPES = {
632
635
  PARKING_COMPLETED_DUE_TO_CAR_LEAVE: 'PARKING_COMPLETED_DUE_TO_CAR_LEAVE',
633
636
  NOTIFY_INVITE_MEMBER: 'NOTIFY_INVITE_MEMBER',
634
637
  REMINDER: 'REMINDER',
638
+ NOTIFY_INDICATOR: 'NOTIFY_INDICATOR',
635
639
  NOTIFY_REMOVE_UNIT: 'NOTIFY_REMOVE_UNIT',
636
640
  NOTIFY_REMOVE_MEMBER: 'NOTIFY_REMOVE_MEMBER',
637
641
  NOTIFY_MEMBER_LEAVE_UNIT: 'NOTIFY_MEMBER_LEAVE_UNIT',
642
+ NOTIFY_RENAME_UNIT: 'NOTIFY_RENAME_UNIT',
638
643
  };
639
644
 
640
645
  export const ACTIVITY_LOG_TYPES = {
@@ -4,7 +4,13 @@ import { ToastBottomHelper } from '../../utils/Utils';
4
4
  import { axiosPost } from '../../utils/Apis/axios';
5
5
  import { API } from '../../configs';
6
6
 
7
- export const sendCommandOverInternet = async (sensor, action, data, source) => {
7
+ export const sendCommandOverInternet = async (
8
+ sensor,
9
+ action,
10
+ data,
11
+ source,
12
+ actionName
13
+ ) => {
8
14
  if (data !== null) {
9
15
  if (Number.isInteger(data)) {
10
16
  data = data.toString(16).toUpperCase();
@@ -15,6 +21,7 @@ export const sendCommandOverInternet = async (sensor, action, data, source) => {
15
21
  key: action.key,
16
22
  data,
17
23
  source,
24
+ action_name: actionName,
18
25
  });
19
26
  if (success) {
20
27
  ToastBottomHelper.success(t('Command is sent to device via internet'));
@@ -12,7 +12,8 @@ export const sendRemoteCommand = async (
12
12
  sensor,
13
13
  action,
14
14
  data,
15
- userId = null
15
+ userId = null,
16
+ actionName
16
17
  ) => {
17
18
  // No action, raise not authorized
18
19
  let result = false;
@@ -31,7 +32,8 @@ export const sendRemoteCommand = async (
31
32
  sensor,
32
33
  action,
33
34
  data,
34
- 'bluetooth'
35
+ 'bluetooth',
36
+ actionName
35
37
  );
36
38
  } else {
37
39
  throw err;
@@ -24,6 +24,8 @@ const AddCommonSelectSubUnit = ({ route }) => {
24
24
  listSelectDevice,
25
25
  smart_account_id,
26
26
  smart_account_id_from_backend,
27
+ username,
28
+ brand,
27
29
  } = route.params;
28
30
  const [selectedIndex, setSelectedIndex] = useState(-1);
29
31
  const [unit, setUnit] = useState([]);
@@ -86,6 +88,8 @@ const AddCommonSelectSubUnit = ({ route }) => {
86
88
  smart_account_id: smart_account_id,
87
89
  unit_id: unit_id,
88
90
  smart_account_id_from_backend: smart_account_id_from_backend,
91
+ username,
92
+ brand,
89
93
  });
90
94
  break;
91
95
  case 'AddVconnexDevice':
@@ -115,6 +119,8 @@ const AddCommonSelectSubUnit = ({ route }) => {
115
119
  smart_account_id,
116
120
  unit_id,
117
121
  smart_account_id_from_backend,
122
+ username,
123
+ brand,
118
124
  ]);
119
125
 
120
126
  const handleSelectIndex = (index) => {
@@ -7,6 +7,9 @@ import { SCProvider } from '../../../context';
7
7
  import { mockSCStore } from '../../../context/mockStore';
8
8
  import SetupGatewayWifi from '../SetupGatewayWifi';
9
9
  import DisplayChecking from '../../../commons/DisplayChecking';
10
+ import { AlertAction } from '../../../commons';
11
+ import _TextInputPassword from '../../../commons/Form/TextInputPassword';
12
+ import _TextInput from '../../../commons/Form/TextInput';
10
13
 
11
14
  const wrapComponent = (route) => (
12
15
  <SCProvider initState={mockSCStore({})}>
@@ -87,4 +90,53 @@ describe('Test SetupGatewayWifi', () => {
87
90
  const displayLoadingConnect = instance.findByType(DisplayChecking);
88
91
  expect(displayLoadingConnect.props.visible).toBeTruthy();
89
92
  });
93
+
94
+ test('test render AlertAction', async () => {
95
+ await act(async () => {
96
+ tree = await create(wrapComponent(route));
97
+ });
98
+ const instance = tree.root;
99
+ const alertAction = instance.findByType(AlertAction);
100
+ await act(async () => {
101
+ alertAction.props.hideModal();
102
+ alertAction.props.leftButtonClick();
103
+ });
104
+ expect(alertAction).toBeDefined();
105
+ });
106
+
107
+ test('test render _TextInputPassword', async () => {
108
+ await act(async () => {
109
+ tree = await create(wrapComponent(route));
110
+ });
111
+ const instance = tree.root;
112
+ const textInputPassword = instance.findByType(_TextInputPassword);
113
+ await act(async () => {
114
+ textInputPassword.props.onChange('new_name');
115
+ });
116
+ expect(textInputPassword.props.value).toEqual('new_name');
117
+ });
118
+
119
+ test('test render TextInput', async () => {
120
+ await act(async () => {
121
+ tree = await create(wrapComponent(route));
122
+ });
123
+ const instance = tree.root;
124
+ const textInput = instance.findByType(_TextInput);
125
+ await act(async () => {
126
+ textInput.props.onChange('new_text');
127
+ });
128
+ expect(textInput.props.value).toEqual('new_text');
129
+ });
130
+
131
+ test('test render DisplayChecking', async () => {
132
+ await act(async () => {
133
+ tree = await create(wrapComponent(route));
134
+ });
135
+ const instance = tree.root;
136
+ const displayChecking = instance.findByType(DisplayChecking);
137
+ await act(async () => {
138
+ displayChecking.props.onClose();
139
+ });
140
+ expect(displayChecking).toBeDefined();
141
+ });
90
142
  });