@eohjsc/react-native-smart-city 0.2.81 → 0.2.84

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 (72) hide show
  1. package/assets/images/Event.svg +9 -0
  2. package/package.json +2 -2
  3. package/src/commons/ActionGroup/CurtainButtonTemplate.js +32 -21
  4. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +8 -6
  5. package/src/commons/ActionGroup/OnOffTemplate/index.js +11 -3
  6. package/src/commons/ActionGroup/OneBigButtonTemplate.js +10 -7
  7. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +5 -2
  8. package/src/commons/ActionGroup/StatesGridActionTemplate.js +7 -3
  9. package/src/commons/ActionGroup/ThreeButtonTemplate.js +33 -24
  10. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +18 -6
  11. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +9 -1
  12. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +25 -13
  13. package/src/commons/ActionGroup/__test__/index.test.js +48 -14
  14. package/src/commons/Automate/ItemAutomate.js +1 -1
  15. package/src/commons/Automate/ItemAutomateStyles.js +5 -1
  16. package/src/commons/Device/HorizontalBarChart.js +7 -1
  17. package/src/commons/Device/ItemDevice.js +8 -5
  18. package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -1
  19. package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +1 -1
  20. package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
  21. package/src/commons/EmergencyButton/AlertSent.js +2 -2
  22. package/src/commons/FullLoading/index.js +35 -0
  23. package/src/commons/ImagePicker/__test__/ImagePicker.test.js +24 -3
  24. package/src/commons/MediaPlayerDetail/index.js +1 -0
  25. package/src/commons/SubUnit/Favorites/index.js +2 -0
  26. package/src/commons/SubUnit/OneTap/ItemOneTap.js +3 -0
  27. package/src/commons/SubUnit/ShortDetail.js +7 -1
  28. package/src/commons/index.js +2 -0
  29. package/src/configs/API.js +4 -4
  30. package/src/configs/Constants.js +13 -0
  31. package/src/iot/RemoteControl/Internet.js +8 -1
  32. package/src/iot/RemoteControl/index.js +4 -2
  33. package/src/screens/AddCommon/SelectSubUnit.js +6 -0
  34. package/src/screens/AddNewAction/SelectAction.js +46 -28
  35. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -3
  36. package/src/screens/AddNewAutoSmart/index.js +18 -1
  37. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +21 -12
  38. package/src/screens/AllCamera/index.js +76 -44
  39. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +2 -2
  40. package/src/screens/Device/EditDevice/index.js +2 -2
  41. package/src/screens/Device/__test__/detail.test.js +18 -11
  42. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +2 -2
  43. package/src/screens/Device/components/SensorDisplayItem.js +2 -2
  44. package/src/screens/Device/detail.js +58 -20
  45. package/src/screens/Device/styles.js +2 -0
  46. package/src/screens/Notification/__test__/NotificationItem.test.js +186 -14
  47. package/src/screens/Notification/components/NotificationItem.js +147 -3
  48. package/src/screens/Notification/index.js +4 -1
  49. package/src/screens/Notification/styles/NotificationItemStyles.js +3 -3
  50. package/src/screens/ScanChipQR/hooks/index.js +3 -19
  51. package/src/screens/Sharing/SelectUser.js +17 -10
  52. package/src/screens/Sharing/__test__/SelectUser.test.js +73 -0
  53. package/src/screens/SubUnit/AddSubUnit.js +4 -1
  54. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +148 -0
  55. package/src/screens/Unit/Detail.js +28 -4
  56. package/src/screens/Unit/ManageUnit.js +87 -31
  57. package/src/screens/Unit/ManageUnitStyles.js +14 -0
  58. package/src/screens/Unit/SmartAccount.js +11 -3
  59. package/src/screens/Unit/Summaries.js +2 -2
  60. package/src/screens/Unit/__test__/CheckSendEmail.test.js +10 -0
  61. package/src/screens/Unit/__test__/Detail.test.js +53 -0
  62. package/src/screens/Unit/__test__/ManageUnit.test.js +69 -0
  63. package/src/screens/Unit/__test__/SmartAccount.test.js +37 -8
  64. package/src/screens/Unit/components/__test__/SharedUnit.test.js +21 -2
  65. package/src/screens/Unit/hook/useStateAlertRemove.js +1 -1
  66. package/src/screens/UnitSummary/__test__/index.test.js +3 -3
  67. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -2
  68. package/src/screens/UnitSummary/index.js +52 -9
  69. package/src/utils/Apis/axios.js +7 -2
  70. package/src/utils/I18n/translations/en.json +11 -1
  71. package/src/utils/I18n/translations/vi.json +11 -1
  72. package/src/{screens/Notification → utils}/Monitor.js +1 -1
@@ -148,38 +148,56 @@ const SelectAction = memo(({ route }) => {
148
148
  checkedItem,
149
149
  t,
150
150
  ]);
151
-
152
151
  const onSave = useCallback(async () => {
153
152
  if (isSelectSensor) {
154
153
  await checkConditionToContinue();
155
154
  } else {
156
- let list_action = [...actions];
157
- list_action = list_action.map((item) => ({
158
- action: item.action,
159
- data: item.data,
160
- }));
161
- const { success } = await axiosPost(
162
- API.AUTOMATE.ADD_SCRIPT_ACTION(automateId),
163
- {
164
- list_action,
165
- unit: unit.id,
155
+ if (automateId) {
156
+ let list_action = [...actions];
157
+ list_action = list_action.map((item) => ({
158
+ action: item.action,
159
+ data: item.data,
160
+ }));
161
+ const { success } = await axiosPost(
162
+ API.AUTOMATE.ADD_SCRIPT_ACTION(automateId),
163
+ {
164
+ list_action,
165
+ unit: unit.id,
166
+ }
167
+ );
168
+ if (!success) {
169
+ ToastBottomHelper.error(t('not_permission'));
166
170
  }
167
- );
168
- if (!success) {
169
- ToastBottomHelper.error(t('not_permission'));
171
+ navigate(Routes.ScriptDetail, {
172
+ id: automateId,
173
+ name: scriptName,
174
+ havePermission: true,
175
+ unit,
176
+ saveAt: moment().valueOf(),
177
+ type: type,
178
+ isAutomateTab,
179
+ isCreateNewAction,
180
+ isMultiUnits,
181
+ automate,
182
+ });
183
+ } else {
184
+ navigate(Routes.AddNewOneTap, {
185
+ automateData: {
186
+ action: actions[0].action,
187
+ },
188
+ type,
189
+ unit,
190
+ isAutomateTab,
191
+ isSelectSensor,
192
+ isMultiUnits,
193
+ automateId,
194
+ automate: {
195
+ ...automate,
196
+ action: actions[0].action,
197
+ },
198
+ scriptName,
199
+ });
170
200
  }
171
- navigate(Routes.ScriptDetail, {
172
- id: automateId,
173
- name: scriptName,
174
- havePermission: true,
175
- unit,
176
- saveAt: moment().valueOf(),
177
- type: type,
178
- isAutomateTab,
179
- isCreateNewAction,
180
- isMultiUnits,
181
- automate,
182
- });
183
201
  }
184
202
  // eslint-disable-next-line react-hooks/exhaustive-deps
185
203
  }, [
@@ -284,14 +302,14 @@ const SelectAction = memo(({ route }) => {
284
302
  () => (
285
303
  <BottomButtonView
286
304
  style={styles.bottomButtonView}
287
- mainTitle={t(isSelectSensor ? 'continue' : 'save')}
305
+ mainTitle={t(automateId ? 'save' : 'continue')}
288
306
  onPressMain={onSave}
289
307
  typeMain={
290
308
  actions.length > 0 || !!checkedItem?.id ? 'primary' : 'disabled'
291
309
  }
292
310
  />
293
311
  ),
294
- [onSave, actions, checkedItem, isSelectSensor, t]
312
+ [t, automateId, onSave, actions.length, checkedItem?.id]
295
313
  );
296
314
 
297
315
  useEffect(() => {
@@ -3,7 +3,7 @@ import { act, create } from 'react-test-renderer';
3
3
  import AddNewAutoSmart from '..';
4
4
  import { SCProvider } from '../../../context';
5
5
  import { mockSCStore } from '../../../context/mockStore';
6
- import { TESTID } from '../../../configs/Constants';
6
+ import { AUTOMATE_TYPE, TESTID } from '../../../configs/Constants';
7
7
  import ItemAutomate from '../../../commons/Automate/ItemAutomate';
8
8
  import Routes from '../../../utils/Route';
9
9
 
@@ -34,7 +34,7 @@ describe('test AddNewAutoSmart', () => {
34
34
  let tree;
35
35
  let route = {
36
36
  params: {
37
- type: 'value_change',
37
+ type: AUTOMATE_TYPE.VALUE_CHANGE,
38
38
  unit: { id: 1 },
39
39
  },
40
40
  };
@@ -49,7 +49,7 @@ describe('test AddNewAutoSmart', () => {
49
49
  });
50
50
  const instance = tree.root;
51
51
  const items = instance.findAllByType(ItemAutomate);
52
- expect(items).toHaveLength(2);
52
+ expect(items).toHaveLength(3);
53
53
 
54
54
  await act(async () => {
55
55
  await items[0].props.onPress();
@@ -42,6 +42,13 @@ const AddNewAutoSmart = memo(({ route }) => {
42
42
  type: AUTOMATE_TYPE.SCHEDULE,
43
43
  route: Routes.SetSchedule,
44
44
  },
45
+ {
46
+ type: AUTOMATE_TYPE.EVENT,
47
+ route: Routes.SelectSensorDevices,
48
+ data: {
49
+ title: AUTOMATE_SELECT.SELECT_DEVICE,
50
+ },
51
+ },
45
52
  ],
46
53
  [AUTOMATE_TYPE.VALUE_CHANGE]: [
47
54
  {
@@ -55,6 +62,13 @@ const AddNewAutoSmart = memo(({ route }) => {
55
62
  type: AUTOMATE_TYPE.SCHEDULE,
56
63
  route: Routes.SetSchedule,
57
64
  },
65
+ {
66
+ type: AUTOMATE_TYPE.EVENT,
67
+ route: Routes.SelectSensorDevices,
68
+ data: {
69
+ title: AUTOMATE_SELECT.SELECT_DEVICE,
70
+ },
71
+ },
58
72
  ],
59
73
  [AUTOMATE_TYPE.ONE_TAP_ONLY]: [
60
74
  {
@@ -84,7 +98,10 @@ const AddNewAutoSmart = memo(({ route }) => {
84
98
  scriptName,
85
99
  };
86
100
 
87
- if (dataAutomate.type === AUTOMATE_TYPE.VALUE_CHANGE && isMultiUnits) {
101
+ if (
102
+ (dataAutomate.type === AUTOMATE_TYPE.VALUE_CHANGE && isMultiUnits) ||
103
+ (dataAutomate.type === AUTOMATE_TYPE.EVENT && isMultiUnits)
104
+ ) {
88
105
  navigate(Routes.SelectUnit, params);
89
106
  } else {
90
107
  navigate(dataAutomate.route, params);
@@ -60,7 +60,7 @@ const ConnectWifiWarning = memo(({ route }) => {
60
60
  undefined
61
61
  );
62
62
  });
63
- socket.on('message', function (msg, rinfo) {
63
+ socket.on('message', (msg, rinfo) => {
64
64
  const data = JSON.parse(msg.toString());
65
65
  if (data.hasOwnProperty('wifi')) {
66
66
  navigate(Routes.GatewayWifiList, {
@@ -71,27 +71,36 @@ const ConnectWifiWarning = memo(({ route }) => {
71
71
  });
72
72
  }
73
73
  if (data.hasOwnProperty('gateway')) {
74
- navigate(Routes.Dashboard);
75
- ToastBottomHelper.success(t('completed'));
74
+ const checkWifiInterval = setInterval(() => {
75
+ // eslint-disable-next-line promise/prefer-await-to-then
76
+ WifiManager.getCurrentWifiSSID().then(async (ssid) => {
77
+ if (ssid !== wifi_ssid) {
78
+ const { success } = await axiosPost(
79
+ API.UNIT.ADD_GATEWAY(unit_id),
80
+ {
81
+ chip: chip_id,
82
+ imei: data.gateway.imei,
83
+ chip_name: data.gateway.model,
84
+ }
85
+ );
86
+ if (success) {
87
+ navigate(Routes.Dashboard);
88
+ ToastBottomHelper.success(t('add_gateway_success'));
89
+ clearInterval(checkWifiInterval);
90
+ }
91
+ }
92
+ });
93
+ }, 3000);
76
94
  }
77
95
  });
78
96
  socket.on('error', () => {
79
97
  ToastBottomHelper.error(t('server_error'));
80
98
  goBack();
81
99
  });
82
- return () => {
83
- socket.close();
84
- };
85
100
  };
86
101
 
87
102
  const handleConnectWifiGateway = async () => {
88
103
  setIsLoading(true);
89
- const { success } = await axiosPost(API.UNIT.ADD_GATEWAY(unit_id), {
90
- chip: chip_id,
91
- });
92
- if (success) {
93
- ToastBottomHelper.success(t('add_gateway_success'));
94
- }
95
104
  // eslint-disable-next-line promise/prefer-await-to-then
96
105
  WifiManager.connectToProtectedSSID(wifi_ssid, wifi_pass, false).then(
97
106
  () => {
@@ -1,4 +1,10 @@
1
- import React, { useEffect, useMemo, useRef, useState } from 'react';
1
+ import React, {
2
+ useCallback,
3
+ useEffect,
4
+ useMemo,
5
+ useRef,
6
+ useState,
7
+ } from 'react';
2
8
  import { View, Text, TouchableOpacity, Platform, Image } from 'react-native';
3
9
  import { useRoute, useNavigation } from '@react-navigation/native';
4
10
  import { chunk } from 'lodash';
@@ -28,36 +34,51 @@ const AllCamera = () => {
28
34
  const [isFullScreen, setIsFullScreen] = useState(false);
29
35
  const [dataFullScreen, setDataFullScreen] = useState();
30
36
 
31
- const handleFullScreen = (data) => {
32
- setIsFullScreen(!isFullScreen);
33
- setDataFullScreen(data);
34
- };
37
+ const handleFullScreen = useCallback(
38
+ (data) => {
39
+ setIsFullScreen(!isFullScreen);
40
+ setDataFullScreen(data);
41
+ },
42
+ [isFullScreen]
43
+ );
35
44
 
36
- const onPressAmount = (value) => () => {
37
- setAmount(value);
38
- value === 1 && setActiveCamera(arrCameras[0]);
39
- const dataTemp = [...arrCameras];
40
- setData(value === 1 ? dataTemp : chunk(dataTemp, value));
41
- };
45
+ const onPressAmount = useCallback(
46
+ (value) => () => {
47
+ setAmount(value);
48
+ value === 1 && setActiveCamera(arrCameras[0]);
49
+ const dataTemp = [...arrCameras];
50
+ setData(value === 1 ? dataTemp : chunk(dataTemp, value));
51
+ setCurrentPage(1);
52
+ },
53
+ [arrCameras]
54
+ );
42
55
 
43
- const onPressNext = () =>
56
+ const onPressNext = useCallback(() => {
44
57
  currentPage !== data.length && carouselRef?.current?.snapToNext();
58
+ }, [currentPage, data.length]);
45
59
 
46
- const onPressPrev = () =>
60
+ const onPressPrev = useCallback(() => {
47
61
  currentPage !== 1 && carouselRef?.current?.snapToPrev();
62
+ }, [currentPage]);
48
63
 
49
- const onSnapToItem = (index) => {
50
- setActiveCamera(data[index]);
51
- setCurrentPage(index + 1);
52
- };
64
+ const onSnapToItem = useCallback(
65
+ (index) => {
66
+ setActiveCamera(data[index]);
67
+ setCurrentPage(index + 1);
68
+ },
69
+ [data]
70
+ );
53
71
 
54
72
  const onClose = () => {
55
73
  setIsFullScreen(false);
56
74
  };
57
75
 
58
- const goToPlayBack = (item, thumbnail) => () => {
59
- navigate(Routes.PlaybackCamera, { item, thumbnail });
60
- };
76
+ const goToPlayBack = useCallback(
77
+ (item, thumbnail) => () => {
78
+ navigate(Routes.PlaybackCamera, { item, thumbnail });
79
+ },
80
+ [navigate]
81
+ );
61
82
 
62
83
  const CameraItem = ({ item, width, height }) => {
63
84
  return (
@@ -82,7 +103,7 @@ const AllCamera = () => {
82
103
  );
83
104
  };
84
105
 
85
- const renderItem = ({ item, index }) => {
106
+ const renderItem = ({ item }) => {
86
107
  return (
87
108
  <View style={styles.wrapItem}>
88
109
  {amount === 1 ? (
@@ -93,13 +114,13 @@ const AllCamera = () => {
93
114
  <CameraItem
94
115
  key={item?.id}
95
116
  item={item[0]}
96
- width={188}
117
+ width={Constants.width / 2}
97
118
  height={112}
98
119
  />
99
120
  <CameraItem
100
121
  key={item?.id}
101
122
  item={item[1]}
102
- width={188}
123
+ width={Constants.width / 2}
103
124
  height={112}
104
125
  />
105
126
  </View>
@@ -107,13 +128,13 @@ const AllCamera = () => {
107
128
  <CameraItem
108
129
  key={item?.id}
109
130
  item={item[2]}
110
- width={188}
131
+ width={Constants.width / 2}
111
132
  height={112}
112
133
  />
113
134
  <CameraItem
114
135
  key={item?.id}
115
136
  item={item[3]}
116
- width={188}
137
+ width={Constants.width / 2}
117
138
  height={112}
118
139
  />
119
140
  </View>
@@ -138,19 +159,23 @@ const AllCamera = () => {
138
159
 
139
160
  const renderCarousel = useMemo(() => {
140
161
  return (
141
- <Carousel
142
- ref={carouselRef}
143
- data={data}
144
- renderItem={renderItem}
145
- sliderWidth={Constants.width}
146
- itemWidth={Constants.width}
147
- inactiveSlideScale={1}
148
- onSnapToItem={onSnapToItem}
149
- inactiveSlideOpacity={1}
150
- extraData={data}
151
- loop={false}
152
- isForceIndex={Platform.OS === 'android'}
153
- />
162
+ <View style={styles.wrapCarousel}>
163
+ <Carousel
164
+ ref={carouselRef}
165
+ data={data}
166
+ renderItem={renderItem}
167
+ sliderWidth={Constants.width}
168
+ itemWidth={Constants.width}
169
+ inactiveSlideScale={1}
170
+ onSnapToItem={onSnapToItem}
171
+ inactiveSlideOpacity={1}
172
+ extraData={data}
173
+ loop={false}
174
+ lockScrollWhileSnapping
175
+ isForceIndex={Platform.OS === 'android'}
176
+ removeClippedSubviews={false}
177
+ />
178
+ </View>
154
179
  );
155
180
  // eslint-disable-next-line react-hooks/exhaustive-deps
156
181
  }, [data]);
@@ -182,6 +207,17 @@ const AllCamera = () => {
182
207
  // eslint-disable-next-line react-hooks/exhaustive-deps
183
208
  }, [amount]);
184
209
 
210
+ const renderName = useMemo(
211
+ () => (
212
+ <Text style={styles.cameraName}>
213
+ {amount === 1
214
+ ? activeCamera?.configuration?.name
215
+ : `${currentPage}/${data.length}`}
216
+ </Text>
217
+ ),
218
+ [activeCamera?.configuration?.name, amount, currentPage, data.length]
219
+ );
220
+
185
221
  useEffect(() => {
186
222
  const to = setTimeout(() => {
187
223
  carouselRef?.current?.snapToItem();
@@ -203,16 +239,12 @@ const AllCamera = () => {
203
239
  <TouchableOpacity style={styles.buttonNext} onPress={onPressPrev}>
204
240
  <Image source={Images.arrowLeft} />
205
241
  </TouchableOpacity>
206
- <Text numberOfLines={1} style={styles.cameraName}>
207
- {amount === 1
208
- ? activeCamera?.configuration?.name
209
- : `${currentPage}/${data.length}`}
210
- </Text>
242
+ {renderName}
211
243
  <TouchableOpacity style={styles.buttonNext} onPress={onPressNext}>
212
244
  <Image source={Images.arrowLeft} style={styles.arrowRight} />
213
245
  </TouchableOpacity>
214
246
  </View>
215
- <View style={styles.wrapCarousel}>{renderCarousel}</View>
247
+ {renderCarousel}
216
248
  {renderAmount}
217
249
  </View>
218
250
  </View>
@@ -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
  );