@eohjsc/react-native-smart-city 0.2.82 → 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 (43) hide show
  1. package/package.json +3 -3
  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 +7 -1
  14. package/src/commons/Device/ItemDevice.js +8 -5
  15. package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
  16. package/src/commons/EmergencyButton/AlertSent.js +2 -2
  17. package/src/commons/SubUnit/Favorites/index.js +2 -0
  18. package/src/commons/SubUnit/ShortDetail.js +7 -1
  19. package/src/configs/API.js +2 -4
  20. package/src/configs/Constants.js +2 -0
  21. package/src/iot/RemoteControl/Internet.js +8 -1
  22. package/src/iot/RemoteControl/index.js +4 -2
  23. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +2 -2
  24. package/src/screens/Device/EditDevice/index.js +2 -2
  25. package/src/screens/Device/__test__/detail.test.js +18 -11
  26. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +2 -2
  27. package/src/screens/Device/components/SensorDisplayItem.js +2 -2
  28. package/src/screens/Device/detail.js +58 -20
  29. package/src/screens/Notification/__test__/NotificationItem.test.js +186 -14
  30. package/src/screens/Notification/components/NotificationItem.js +128 -2
  31. package/src/screens/Notification/styles/NotificationItemStyles.js +3 -3
  32. package/src/screens/SubUnit/AddSubUnit.js +4 -1
  33. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +148 -0
  34. package/src/screens/Unit/Detail.js +10 -0
  35. package/src/screens/Unit/Summaries.js +2 -2
  36. package/src/screens/Unit/__test__/CheckSendEmail.test.js +10 -0
  37. package/src/screens/Unit/__test__/Detail.test.js +10 -0
  38. package/src/screens/Unit/components/__test__/SharedUnit.test.js +21 -2
  39. package/src/screens/UnitSummary/__test__/index.test.js +3 -3
  40. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -2
  41. package/src/screens/UnitSummary/index.js +52 -9
  42. package/src/utils/I18n/translations/en.json +7 -0
  43. package/src/utils/I18n/translations/vi.json +7 -0
@@ -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
 
@@ -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
 
@@ -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>
@@ -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/`,
@@ -340,6 +340,7 @@ export const TESTID = {
340
340
 
341
341
  // ADD SUB UNIT
342
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',
343
344
 
344
345
  SCANNING_RESPONSE_TITLE: 'SCANNING_RESPONSE_TITLE',
345
346
  SCANNING_RESPONSE_DESCRIPTION: 'SCANNING_RESPONSE_DESCRIPTION',
@@ -634,6 +635,7 @@ export const NOTIFICATION_TYPES = {
634
635
  PARKING_COMPLETED_DUE_TO_CAR_LEAVE: 'PARKING_COMPLETED_DUE_TO_CAR_LEAVE',
635
636
  NOTIFY_INVITE_MEMBER: 'NOTIFY_INVITE_MEMBER',
636
637
  REMINDER: 'REMINDER',
638
+ NOTIFY_INDICATOR: 'NOTIFY_INDICATOR',
637
639
  NOTIFY_REMOVE_UNIT: 'NOTIFY_REMOVE_UNIT',
638
640
  NOTIFY_REMOVE_MEMBER: 'NOTIFY_REMOVE_MEMBER',
639
641
  NOTIFY_MEMBER_LEAVE_UNIT: 'NOTIFY_MEMBER_LEAVE_UNIT',
@@ -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;
@@ -90,7 +90,7 @@ describe('Test EditDevice', () => {
90
90
  await act(async () => {
91
91
  await alertAction.props.rightButtonClick();
92
92
  });
93
- expect(axios.patch).toHaveBeenCalledWith(API.SENSOR.RENAME_SENSOR(1), {
93
+ expect(axios.patch).toHaveBeenCalledWith(API.SENSOR.SENSOR_DETAIL(1), {
94
94
  name: 'new_name',
95
95
  });
96
96
  expect(alertAction.props.visible).toBeFalsy();
@@ -119,7 +119,7 @@ describe('Test EditDevice', () => {
119
119
  await act(async () => {
120
120
  await alertAction.props.rightButtonClick();
121
121
  });
122
- expect(axios.delete).toHaveBeenCalledWith(API.SENSOR.REMOVE_SENSOR(1));
122
+ expect(axios.delete).toHaveBeenCalledWith(API.SENSOR.SENSOR_DETAIL(1));
123
123
  expect(alertAction.props.visible).toBeFalsy();
124
124
  expect(mockPop).toHaveBeenCalled();
125
125
  });
@@ -29,7 +29,7 @@ const EditDevice = memo(() => {
29
29
  useEditDevice();
30
30
  const renameSensor = useCallback(async () => {
31
31
  const { success, data } = await axiosPatch(
32
- API.SENSOR.RENAME_SENSOR(sensor?.id),
32
+ API.SENSOR.SENSOR_DETAIL(sensor?.id),
33
33
  {
34
34
  name: inputName,
35
35
  }
@@ -53,7 +53,7 @@ const EditDevice = memo(() => {
53
53
 
54
54
  const deleteSensor = useCallback(async () => {
55
55
  hideAlertAction();
56
- const { success } = await axiosDelete(API.SENSOR.REMOVE_SENSOR(sensor?.id));
56
+ const { success } = await axiosDelete(API.SENSOR.SENSOR_DETAIL(sensor?.id));
57
57
 
58
58
  if (success) {
59
59
  navigation.pop(2);
@@ -93,7 +93,7 @@ describe('test DeviceDetail', () => {
93
93
  beforeEach(() => {
94
94
  route = {
95
95
  params: {
96
- unit: {
96
+ unitData: {
97
97
  id: 1,
98
98
  name: 'Unit name',
99
99
  address: '298 Dien Bien Phu',
@@ -105,10 +105,11 @@ describe('test DeviceDetail', () => {
105
105
  id: 2,
106
106
  name: 'Station name',
107
107
  },
108
- sensor: {
108
+ sensorData: {
109
109
  id: 1,
110
110
  is_managed_by_backend: true,
111
111
  station: { id: 2, name: 'Station name' },
112
+ name: 'Sensor name',
112
113
  },
113
114
  title: 'Button',
114
115
  },
@@ -252,7 +253,9 @@ describe('test DeviceDetail', () => {
252
253
  });
253
254
  expect(axios.post).toHaveBeenCalledWith(API.SENSOR.QUICK_ACTION(1), {
254
255
  key: responseDisplay.data.items[1].configuration.configuration.action1,
256
+ data: null,
255
257
  source: 'internet',
258
+ action_name: undefined,
256
259
  });
257
260
 
258
261
  const button2 = instance.find(
@@ -263,7 +266,9 @@ describe('test DeviceDetail', () => {
263
266
  });
264
267
  expect(axios.post).toHaveBeenCalledWith(API.SENSOR.QUICK_ACTION(1), {
265
268
  key: responseDisplay.data.items[1].configuration.configuration.action2,
269
+ data: null,
266
270
  source: 'internet',
271
+ action_name: undefined,
267
272
  });
268
273
 
269
274
  const button3 = instance.find(
@@ -274,7 +279,9 @@ describe('test DeviceDetail', () => {
274
279
  });
275
280
  expect(axios.post).toHaveBeenCalledWith(API.SENSOR.QUICK_ACTION(1), {
276
281
  key: responseDisplay.data.items[1].configuration.configuration.action3,
282
+ data: null,
277
283
  source: 'internet',
284
+ action_name: undefined,
278
285
  });
279
286
  });
280
287
 
@@ -628,7 +635,7 @@ describe('test DeviceDetail', () => {
628
635
  });
629
636
 
630
637
  test('not fetch value if not managed by backend', async () => {
631
- route.params.sensor.is_managed_by_backend = false;
638
+ route.params.sensorData.is_managed_by_backend = false;
632
639
 
633
640
  await act(async () => {
634
641
  tree = await create(wrapComponent(account, route));
@@ -638,7 +645,7 @@ describe('test DeviceDetail', () => {
638
645
  });
639
646
 
640
647
  test('render CurrentRainSensor but is other device', async () => {
641
- route.params.sensor.is_other_device = true;
648
+ route.params.sensorData.is_other_device = true;
642
649
  route.params.isGGHomeConnected = true;
643
650
 
644
651
  const responseDisplay = {
@@ -708,9 +715,9 @@ describe('test DeviceDetail', () => {
708
715
  });
709
716
 
710
717
  test('Add device to Favourites', async () => {
711
- const unit_id = route.params.unit.id;
718
+ const unit_id = route.params.unitData.id;
712
719
  const station_id = route.params.station.id;
713
- const sensor = route.params.sensor;
720
+ const sensor = route.params.sensorData;
714
721
  sensor.is_favourite = false;
715
722
 
716
723
  await act(async () => {
@@ -736,9 +743,9 @@ describe('test DeviceDetail', () => {
736
743
  });
737
744
 
738
745
  test('Remove device from Favourites', async () => {
739
- const unit_id = route.params.unit.id;
746
+ const unit_id = route.params.unitData.id;
740
747
  const station_id = route.params.station.id;
741
- const sensor = route.params.sensor;
748
+ const sensor = route.params.sensorData;
742
749
  sensor.is_favourite = true;
743
750
 
744
751
  await act(async () => {
@@ -810,12 +817,12 @@ describe('test DeviceDetail', () => {
810
817
  await menu.props.onItemClick(gotoActivityLog);
811
818
  });
812
819
  expect(mockedNavigate).toHaveBeenCalledWith(Routes.ActivityLog, {
813
- id: route.params.sensor.id,
820
+ id: route.params.sensorData.id,
814
821
  type: 'action',
815
- share: route.params.unit,
822
+ share: route.params.unitData,
816
823
  filterEnabled: {
817
824
  date: true,
818
- user: Boolean(route.params.unit.id),
825
+ user: Boolean(route.params.unitData.id),
819
826
  },
820
827
  });
821
828
  });
@@ -3,7 +3,7 @@ import { ConnectedViewHeader, DisconnectedView } from '../../../commons/Device';
3
3
  import { DEVICE_TYPE } from '../../../configs/Constants';
4
4
 
5
5
  export const SensorConnectStatusViewHeader = (props) => {
6
- if (!!props.sensor && !props.sensor.is_other_device) {
6
+ if (!!props.sensor && !props.sensor?.is_other_device) {
7
7
  if (props.connected) {
8
8
  return (
9
9
  <>
@@ -31,7 +31,7 @@ export const SensorConnectStatusViewHeader = (props) => {
31
31
  return <DisconnectedView sensor={props.sensor} />;
32
32
  }
33
33
  } else {
34
- if (props.sensor.device_type === DEVICE_TYPE.LG_THINQ) {
34
+ if (props.sensor?.device_type === DEVICE_TYPE.LG_THINQ) {
35
35
  return (
36
36
  <>
37
37
  <ConnectedViewHeader lastUpdated={props.lastUpdated} />
@@ -40,8 +40,8 @@ export const SensorDisplayItem = ({
40
40
  const t = useTranslations();
41
41
  const userId = useSCContextSelector((state) => state.auth.account.user.id);
42
42
  const doAction = useCallback(
43
- (action, data) => {
44
- sendRemoteCommand(sensor, action, data, userId);
43
+ (action, data, actionName) => {
44
+ sendRemoteCommand(sensor, action, data, userId, actionName);
45
45
  },
46
46
  [sensor, userId]
47
47
  );