@eohjsc/react-native-smart-city 0.3.0 → 0.3.1

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 (128) hide show
  1. package/README.md +1 -1
  2. package/package.json +3 -3
  3. package/src/commons/Action/ItemQuickAction.js +11 -2
  4. package/src/commons/Action/__test__/ItemQuickAction.test.js +11 -6
  5. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +31 -20
  6. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +3 -2
  7. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +0 -1
  8. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +45 -48
  9. package/src/commons/ActionGroup/__test__/index.test.js +2 -2
  10. package/src/commons/ConnectingProcess/index.js +11 -7
  11. package/src/commons/Device/ConnectedViewHeader.js +1 -1
  12. package/src/commons/Device/HistoryChart.js +3 -3
  13. package/src/commons/Device/ItemDevice.js +15 -11
  14. package/src/commons/Device/SonosSpeaker/index.js +1 -1
  15. package/src/commons/FieldTemplate/ScheduleField/index.js +2 -2
  16. package/src/commons/Header/HeaderCustom.js +2 -1
  17. package/src/commons/HorizontalPicker/index.js +2 -2
  18. package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +0 -6
  19. package/src/commons/MediaPlayerDetail/index.js +19 -50
  20. package/src/commons/SubUnit/Favorites/index.js +2 -3
  21. package/src/commons/SubUnit/ShortDetail.js +1 -2
  22. package/src/commons/SubUnit/__test__/Item.test.js +0 -1
  23. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +2 -13
  24. package/src/commons/UnitSummary/ConfigHistoryChart.js +22 -13
  25. package/src/commons/WheelDateTimePicker/index.js +2 -2
  26. package/src/configs/API.js +4 -13
  27. package/src/configs/Constants.js +13 -0
  28. package/src/context/actionType.ts +8 -0
  29. package/src/context/mockStore.ts +10 -0
  30. package/src/context/reducer.ts +38 -2
  31. package/src/hooks/Common/index.js +2 -0
  32. package/src/hooks/Common/useGGHomeDeviceConnected.js +16 -0
  33. package/src/hooks/Common/useGetIdUser.js +1 -5
  34. package/src/hooks/Common/useSensorsStatus.js +5 -8
  35. package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +198 -0
  36. package/src/hooks/IoT/__test__/useRemoteControl.test.js +198 -0
  37. package/src/hooks/IoT/index.js +4 -0
  38. package/src/hooks/IoT/useGGHomeConnection.js +91 -0
  39. package/src/hooks/IoT/useRemoteControl.js +79 -0
  40. package/src/hooks/index.js +4 -0
  41. package/src/hooks/useReceiveNotifications.js +8 -4
  42. package/src/iot/Monitor.js +3 -2
  43. package/src/iot/RemoteControl/Bluetooth.js +1 -1
  44. package/src/iot/RemoteControl/GoogleHome.js +75 -49
  45. package/src/iot/RemoteControl/Internet.js +1 -1
  46. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +90 -21
  47. package/src/iot/RemoteControl/__test__/Internet.test.js +4 -4
  48. package/src/iot/RemoteControl/__test__/LgThinq.test.js +5 -5
  49. package/src/iot/RemoteControl/index.js +52 -52
  50. package/src/screens/ActivityLog/hooks/__test__/index.test.js +3 -3
  51. package/src/screens/ActivityLog/hooks/index.js +1 -1
  52. package/src/screens/AddLocationMaps/index.js +5 -4
  53. package/src/screens/AddNewAction/SelectAction.js +8 -8
  54. package/src/screens/AddNewAction/SetupSensor.js +7 -7
  55. package/src/screens/AddNewAction/__test__/SelectAction.test.js +2 -2
  56. package/src/screens/AddNewDevice/ConnectingDevices.js +1 -1
  57. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +2 -2
  58. package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
  59. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
  60. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +3 -3
  61. package/src/screens/AddNewGateway/SetupGatewayWifi.js +1 -0
  62. package/src/screens/AllCamera/index.js +4 -4
  63. package/src/screens/Automate/MultiUnits.js +8 -8
  64. package/src/screens/Automate/index.js +3 -3
  65. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +4 -4
  66. package/src/screens/Device/EditDevice/index.js +2 -2
  67. package/src/screens/Device/__test__/detail.test.js +13 -5
  68. package/src/screens/Device/components/DetailHistoryChart.js +1 -1
  69. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +1 -0
  70. package/src/screens/Device/components/SensorDisplayItem.js +5 -2
  71. package/src/screens/Device/detail.js +49 -16
  72. package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
  73. package/src/screens/EditActionsList/index.js +1 -1
  74. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  75. package/src/screens/HanetCamera/Detail.js +1 -1
  76. package/src/screens/HanetCamera/__test__/Detail.test.js +2 -2
  77. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +3 -2
  78. package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
  79. package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
  80. package/src/screens/ManageAccess/hooks/index.js +7 -4
  81. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +2 -2
  82. package/src/screens/MoveToAnotherSubUnit/index.js +1 -1
  83. package/src/screens/Notification/__test__/NotificationItem.test.js +4 -4
  84. package/src/screens/Notification/components/NotificationItem.js +17 -20
  85. package/src/screens/Notification/index.js +9 -2
  86. package/src/screens/PlayBackCamera/Timer.js +2 -2
  87. package/src/screens/PlayBackCamera/index.js +3 -3
  88. package/src/screens/ScanChipQR/hooks/index.js +15 -16
  89. package/src/screens/ScriptDetail/index.js +14 -10
  90. package/src/screens/SelectUnit/index.js +4 -2
  91. package/src/screens/SetSchedule/index.js +9 -9
  92. package/src/screens/Sharing/Components/SensorItem.js +10 -12
  93. package/src/screens/Sharing/SelectPermission.js +14 -6
  94. package/src/screens/SideMenuDetail/__test__/index.test.js +4 -4
  95. package/src/screens/SideMenuDetail/index.js +2 -3
  96. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -2
  97. package/src/screens/SubUnit/Detail.js +1 -2
  98. package/src/screens/SubUnit/ManageSubUnit.js +12 -7
  99. package/src/screens/SubUnit/__test__/Detail.test.js +1 -1
  100. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +27 -1
  101. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +1 -1
  102. package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
  103. package/src/screens/Unit/ChooseLocation.js +6 -13
  104. package/src/screens/Unit/Detail.js +30 -75
  105. package/src/screens/Unit/SelectAddress.js +34 -21
  106. package/src/screens/Unit/SmartAccount.js +4 -4
  107. package/src/screens/Unit/Summaries.js +17 -1
  108. package/src/screens/Unit/__test__/CheckSendEmail.test.js +9 -1
  109. package/src/screens/Unit/__test__/Detail.test.js +16 -15
  110. package/src/screens/Unit/__test__/SelectAddress.test.js +72 -13
  111. package/src/screens/Unit/__test__/SmartAccount.test.js +1 -1
  112. package/src/screens/Unit/__test__/Summaries.test.js +100 -0
  113. package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +50 -0
  114. package/src/screens/Unit/styles.js +4 -0
  115. package/src/screens/UnitSummary/__test__/index.test.js +55 -1
  116. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +31 -2
  117. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +2 -13
  118. package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -1
  119. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +11 -2
  120. package/src/screens/UnitSummary/components/RunningDevices/index.js +7 -10
  121. package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
  122. package/src/screens/UnitSummary/index.js +15 -1
  123. package/src/utils/Apis/axios.js +16 -25
  124. package/src/utils/Converter/time.js +0 -18
  125. package/src/utils/I18n/translations/en.json +2 -1
  126. package/src/utils/I18n/translations/vi.json +3 -1
  127. package/src/utils/Permission/common.js +39 -0
  128. package/src/utils/Utils.js +5 -1
@@ -32,7 +32,6 @@ import {
32
32
  import { useFavoriteDevice } from './hooks/useFavoriteDevice';
33
33
  import BottomButtonView from '../../commons/BottomButtonView';
34
34
  import Text from '../../commons/Text';
35
- import { transformDatetime } from '../../utils/Converter/time';
36
35
  import { AlertAction, ButtonPopup, MenuActionMore } from '../../commons';
37
36
  import { TESTID } from '../../configs/Constants';
38
37
 
@@ -40,7 +39,12 @@ import { usePopover } from '../../hooks/Common';
40
39
  import { useConfigGlobalState } from '../../iot/states';
41
40
  import { useNavigation } from '@react-navigation/native';
42
41
  import styles from './styles';
43
- import { useIsOwnerOfUnit, useBoolean } from '../../hooks/Common';
42
+ import {
43
+ useIsOwnerOfUnit,
44
+ useBoolean,
45
+ useGGHomeDeviceConnected,
46
+ } from '../../hooks/Common';
47
+ import { useGGHomeConnection } from '../../hooks/IoT';
44
48
  import { SensorDisplayItem } from './components/SensorDisplayItem';
45
49
  import { useSCContextSelector } from '../../context';
46
50
  import { EmergencyCountdown } from './components/EmergencyCountdown';
@@ -48,6 +52,7 @@ import { SensorConnectStatusViewHeader } from './components/SensorConnectStatusV
48
52
  import { useDisconnectedDevice } from './hooks/useDisconnectedDevice';
49
53
  import { Card } from '../../commons/CardShadow';
50
54
  import PreventAccess from '../../commons/PreventAccess';
55
+ import { notImplemented } from '../../utils/Utils';
51
56
 
52
57
  const DeviceDetail = ({ route }) => {
53
58
  const t = useTranslations();
@@ -66,8 +71,7 @@ const DeviceDetail = ({ route }) => {
66
71
  // eslint-disable-next-line no-unused-vars
67
72
  const [configValues, setConfigValues] = useConfigGlobalState('configValues');
68
73
 
69
- const { unitData, unitId, sensorData, sensorId, isGGHomeConnected } =
70
- route.params;
74
+ const { unitData, unitId, sensorData, sensorId } = route.params;
71
75
  const [unit, setUnit] = useState(unitData || { id: unitId });
72
76
  const [sensor, setSensor] = useState(sensorData || { id: sensorId });
73
77
  const [station, setStation] = useState(sensor?.station);
@@ -89,6 +93,7 @@ const DeviceDetail = ({ route }) => {
89
93
  const isBluetoothEnabled = useSCContextSelector((state) => {
90
94
  return state.app.isBluetoothEnabled;
91
95
  });
96
+ const { isConnected: isGGHomeConnected } = useGGHomeDeviceConnected(sensor);
92
97
 
93
98
  const isDeviceConnectedViaBle = useMemo(
94
99
  () =>
@@ -157,9 +162,24 @@ const DeviceDetail = ({ route }) => {
157
162
  }
158
163
  }, [fetchUnitDetail, unitId, unitData]);
159
164
 
165
+ const { connectGoogleHome } = useGGHomeConnection();
166
+
167
+ useEffect(() => {
168
+ if (
169
+ unit.remote_control_options &&
170
+ unit.remote_control_options.googlehome?.length &&
171
+ isNetworkConnected
172
+ ) {
173
+ (async () => {
174
+ await connectGoogleHome(unit.remote_control_options.googlehome);
175
+ })();
176
+ }
177
+ // eslint-disable-next-line react-hooks/exhaustive-deps
178
+ }, [unit, isNetworkConnected]);
179
+
160
180
  const fetchSensorDetail = useCallback(async () => {
161
181
  const { success, data, resp_status } = await axiosGet(
162
- API.SENSOR.SENSOR_DETAIL(sensorId)
182
+ API.DEVICE.SENSOR_DETAIL(sensorId)
163
183
  );
164
184
  if (success) {
165
185
  setSensor(data);
@@ -185,7 +205,7 @@ const DeviceDetail = ({ route }) => {
185
205
  }
186
206
 
187
207
  const { success, data } = await axiosGet(
188
- API.SENSOR.DISPLAY(sensor?.id),
208
+ API.DEVICE.DISPLAY(sensor?.id),
189
209
  {},
190
210
  true
191
211
  );
@@ -195,10 +215,10 @@ const DeviceDetail = ({ route }) => {
195
215
  setServerDown(false);
196
216
  if (data.items.length) {
197
217
  const config = data.items[0].configuration;
198
- if (config.hasOwnProperty('max_value')) {
218
+ if (Object.prototype.hasOwnProperty.call(config, 'max_value')) {
199
219
  setMaxValue(config.max_value);
200
220
  }
201
- if (config.hasOwnProperty('device')) {
221
+ if (Object.prototype.hasOwnProperty.call(config, 'device')) {
202
222
  // for emergency
203
223
  setDeviceId(config.device.id);
204
224
  const last_event = config.device.last_event;
@@ -216,7 +236,7 @@ const DeviceDetail = ({ route }) => {
216
236
  setLoading((preState) => ({ ...preState, displayTemplate: false }));
217
237
 
218
238
  const controlResult = await axiosGet(
219
- API.SENSOR.REMOTE_CONTROL_OPTIONS(sensor?.id),
239
+ API.DEVICE.REMOTE_CONTROL_OPTIONS(sensor?.id),
220
240
  {},
221
241
  true
222
242
  );
@@ -405,8 +425,17 @@ const DeviceDetail = ({ route }) => {
405
425
 
406
426
  const onRefresh = useCallback(() => {
407
427
  fetchDataDeviceDetail();
428
+ if (
429
+ unit.remote_control_options &&
430
+ unit.remote_control_options.googlehome?.length &&
431
+ isNetworkConnected
432
+ ) {
433
+ (async () => {
434
+ await connectGoogleHome(unit.remote_control_options.googlehome);
435
+ })();
436
+ }
408
437
  // eslint-disable-next-line react-hooks/exhaustive-deps
409
- }, [sensor, fetchDataDeviceDetail]);
438
+ }, [sensor, unit, isNetworkConnected, fetchDataDeviceDetail]);
410
439
 
411
440
  const getData = useCallback(
412
441
  (item) => {
@@ -433,6 +462,7 @@ const DeviceDetail = ({ route }) => {
433
462
  if (item.type !== 'value') {
434
463
  return;
435
464
  }
465
+
436
466
  if (!item.configuration) {
437
467
  return;
438
468
  }
@@ -450,7 +480,7 @@ const DeviceDetail = ({ route }) => {
450
480
 
451
481
  const fetchValues = async () => {
452
482
  const { success, data, resp_status } = await axiosGet(
453
- API.SENSOR.DISPLAY_VALUES_V2(sensor?.id),
483
+ API.DEVICE.DISPLAY_VALUES_V2(sensor?.id),
454
484
  {
455
485
  params: params,
456
486
  }
@@ -458,7 +488,10 @@ const DeviceDetail = ({ route }) => {
458
488
  if (success) {
459
489
  setDisplayValues(data.configs);
460
490
  setConnected(data.is_connected);
461
- transformDatetime(data, ['last_updated']);
491
+ data.last_updated = data.last_updated
492
+ ? moment(data.last_updated)
493
+ : data.last_updated;
494
+
462
495
  setLastUpdated(data.last_updated);
463
496
  } else if (resp_status >= 500) {
464
497
  setServerDown(true);
@@ -478,7 +511,7 @@ const DeviceDetail = ({ route }) => {
478
511
  useEffect(() => {
479
512
  setDisplayValues((currentDisplayValues) => {
480
513
  for (const [configId, value] of Object.entries(configValues)) {
481
- const intId = parseInt(configId);
514
+ const intId = parseInt(configId, 10);
482
515
  const index = currentDisplayValues.findIndex(
483
516
  (element) => element.id === intId
484
517
  );
@@ -602,12 +635,12 @@ const DeviceDetail = ({ route }) => {
602
635
 
603
636
  const getDataFromLocal = async () => {
604
637
  const displayData = await getLocalData(
605
- `@CACHE_REQUEST_${API.SENSOR.DISPLAY(sensor?.id)}`
638
+ `@CACHE_REQUEST_${API.DEVICE.DISPLAY(sensor?.id)}`
606
639
  );
607
640
  displayData && setDisplay(JSON.parse(displayData));
608
641
 
609
642
  const controlOptionData = await getLocalData(
610
- `@CACHE_REQUEST_${API.SENSOR.REMOTE_CONTROL_OPTIONS(sensor?.id)}`
643
+ `@CACHE_REQUEST_${API.DEVICE.REMOTE_CONTROL_OPTIONS(sensor?.id)}`
611
644
  );
612
645
  controlOptionData && setControlOptions(JSON.parse(controlOptionData));
613
646
  setLoading((preState) => ({ ...preState, displayTemplate: false }));
@@ -619,7 +652,7 @@ const DeviceDetail = ({ route }) => {
619
652
  } else if (item.doAction) {
620
653
  item.doAction();
621
654
  } else {
622
- alert(t('feature_under_development'));
655
+ notImplemented(t);
623
656
  }
624
657
  };
625
658
 
@@ -47,7 +47,7 @@ export const useDisconnectedDevice = (
47
47
  );
48
48
 
49
49
  const checkNetworkConnect = useCallback(
50
- async (isNetworkConnected, isBluetoothEnabled, serverDown) => {
50
+ async () => {
51
51
  if (!isDeviceHasBle) {
52
52
  return;
53
53
  }
@@ -72,10 +72,10 @@ export const useDisconnectedDevice = (
72
72
  }
73
73
  },
74
74
  // eslint-disable-next-line react-hooks/exhaustive-deps
75
- [isDeviceHasBle]
75
+ [isDeviceHasBle, isNetworkConnected, isBluetoothEnabled, serverDown]
76
76
  );
77
77
 
78
78
  useEffect(() => {
79
- checkNetworkConnect(isNetworkConnected, isBluetoothEnabled, serverDown);
80
- }, [isNetworkConnected, isBluetoothEnabled, checkNetworkConnect, serverDown]);
79
+ checkNetworkConnect();
80
+ }, [checkNetworkConnect]);
81
81
  };
@@ -142,7 +142,7 @@ const EditActionsList = () => {
142
142
  data={actionsList}
143
143
  renderItem={renderItem}
144
144
  keyExtractor={(item) => `draggable-item-${item.key}`}
145
- onDragEnd={({ data }) => setActionList(data)}
145
+ onDragEnd={({ data: dragData }) => setActionList(dragData)}
146
146
  extraData={actionsList}
147
147
  containerStyle={styles.containerStyle}
148
148
  />
@@ -34,11 +34,11 @@ const DropDownItem = ({ label, data, onSelectItem, isOpen, onOpen, index }) => {
34
34
 
35
35
  {isOpen && (
36
36
  <View style={[styles.dropDownItem]}>
37
- {data.map((item, index) => (
37
+ {data.map((item, i) => (
38
38
  <Text
39
39
  style={styles.dropDownText}
40
40
  onPress={handleSelectItem(item)}
41
- key={index}
41
+ key={i}
42
42
  testID={TESTID.DROP_DOWN_PICKER_ITEM}
43
43
  >
44
44
  {item?.label}
@@ -39,7 +39,7 @@ const HanetCameraDetail = ({ route }) => {
39
39
 
40
40
  const fetchDisplayConfig = useCallback(async () => {
41
41
  const { success, data } = await axiosGet(
42
- API.SENSOR.DISPLAY(sensor?.id),
42
+ API.DEVICE.DISPLAY(sensor?.id),
43
43
  {},
44
44
  true
45
45
  );
@@ -101,7 +101,7 @@ describe('Test HanetCameraDetail', () => {
101
101
  });
102
102
 
103
103
  test('Test render HanetCameraDetail', async () => {
104
- mock.onGet(API.SENSOR.DISPLAY(1)).reply(200, responseDisplay.data);
104
+ mock.onGet(API.DEVICE.DISPLAY(1)).reply(200, responseDisplay.data);
105
105
  mock.onGet(API.CAMERA.HANET.CHECKIN(2)).reply(200, responseCheckin.data);
106
106
  await act(async () => {
107
107
  tree = await create(wrapComponent(route));
@@ -123,7 +123,7 @@ describe('Test HanetCameraDetail', () => {
123
123
  });
124
124
 
125
125
  test('Test change date', async () => {
126
- mock.onGet(API.SENSOR.DISPLAY(1)).reply(200, responseDisplay.data);
126
+ mock.onGet(API.DEVICE.DISPLAY(1)).reply(200, responseDisplay.data);
127
127
  mock.onGet(API.CAMERA.HANET.CHECKIN(1)).reply(200, responseCheckin.data);
128
128
  await act(async () => {
129
129
  tree = await create(wrapComponent(route));
@@ -31,7 +31,7 @@ const RequestFaceIDPopup = ({
31
31
  text: t('pick_available_image_from_your_phone'),
32
32
  onChoose: async () => {
33
33
  setHide();
34
- const options = {
34
+ const pickerOptions = {
35
35
  mediaType: 'photo',
36
36
  compressImageMaxHeight: 1280,
37
37
  compressImageMaxWidth: 738,
@@ -39,8 +39,9 @@ const RequestFaceIDPopup = ({
39
39
  forceJpg: true,
40
40
  };
41
41
  try {
42
- const result = await ImagePicker.openPicker(options);
42
+ const result = await ImagePicker.openPicker(pickerOptions);
43
43
  onChooseFile && onChooseFile(result);
44
+ // eslint-disable-next-line no-empty
44
45
  } catch (e) {}
45
46
  },
46
47
  },
@@ -16,13 +16,13 @@ const useHanetCheckinData = (hanetCamera) => {
16
16
  const [loadingMore, setLoadingMore] = useState(false);
17
17
  const [canLoadMore, setCanLoadMore] = useState(true);
18
18
 
19
- const fetchData = async (page, date) => {
19
+ const fetchData = async (selectedPage, selectedDate) => {
20
20
  if (!hanetCamera) {
21
21
  return;
22
22
  }
23
- setPage(page);
24
- setDate(date);
25
- if (page === 1) {
23
+ setPage(selectedPage);
24
+ setDate(selectedDate);
25
+ if (selectedPage === 1) {
26
26
  setRefreshing(true);
27
27
  } else {
28
28
  if (!canLoadMore) {
@@ -32,8 +32,8 @@ const useHanetCheckinData = (hanetCamera) => {
32
32
  }
33
33
 
34
34
  const params = new URLSearchParams();
35
- params.append('page', page);
36
- params.append('date', date.format('YYYY-MM-DD'));
35
+ params.append('page', selectedPage);
36
+ params.append('date', selectedDate.format('YYYY-MM-DD'));
37
37
  const { success, data } = await axiosGet(
38
38
  API.CAMERA.HANET.CHECKIN(hanetCamera.device_id),
39
39
  {
@@ -43,17 +43,17 @@ const useHanetCheckinData = (hanetCamera) => {
43
43
  if (success && data) {
44
44
  setCountMember(data.count_member);
45
45
  setCountStranger(data.count_stranger);
46
- if (page === 1) {
46
+ if (selectedPage === 1) {
47
47
  setCheckinData(data.results || []);
48
48
  } else {
49
- setCanLoadMore(page < Math.ceil(data.count / 20));
49
+ setCanLoadMore(selectedPage < Math.ceil(data.count / 20));
50
50
  setCheckinData((prevData) =>
51
51
  _.uniqBy(prevData.concat(data.results || []), 'id')
52
52
  );
53
53
  }
54
54
  }
55
55
 
56
- if (page === 1) {
56
+ if (selectedPage === 1) {
57
57
  setRefreshing(false);
58
58
  } else {
59
59
  setLoadingMore(false);
@@ -75,8 +75,8 @@ const useHanetCheckinData = (hanetCamera) => {
75
75
  const onMomentumScrollBegin = () =>
76
76
  (onEndReachedCalledDuringMomentum = false);
77
77
 
78
- const onChangeDate = (date) => {
79
- fetchData(page, date);
78
+ const onChangeDate = (selectedDate) => {
79
+ fetchData(page, selectedDate);
80
80
  };
81
81
 
82
82
  const onReceiveNewCheckinData = (data) => {
@@ -13,12 +13,12 @@ const useHanetPlaceMembers = (place) => {
13
13
  const [loadingMore, setLoadingMore] = useState(false);
14
14
  const [canLoadMore, setCanLoadMore] = useState(true);
15
15
 
16
- const fetchData = async (page) => {
16
+ const fetchData = async (selectedPage) => {
17
17
  if (!place) {
18
18
  return;
19
19
  }
20
- setPage(page);
21
- if (page === 1) {
20
+ setPage(selectedPage);
21
+ if (selectedPage === 1) {
22
22
  setRefreshing(true);
23
23
  } else {
24
24
  if (!canLoadMore) {
@@ -28,23 +28,23 @@ const useHanetPlaceMembers = (place) => {
28
28
  }
29
29
 
30
30
  const params = new URLSearchParams();
31
- params.append('page', page);
32
- const { success, data } = await axiosGet(
31
+ params.append('page', selectedPage);
32
+ const { success, data: membersData } = await axiosGet(
33
33
  API.CAMERA.HANET.PLACE_MEMBERS(place.place_id),
34
34
  {
35
35
  params,
36
36
  }
37
37
  );
38
- if (success && data) {
39
- if (page === 1) {
40
- setData(data.results || []);
38
+ if (success && membersData) {
39
+ if (selectedPage === 1) {
40
+ setData(membersData.results || []);
41
41
  } else {
42
- setCanLoadMore(page < Math.ceil(data.count / 20));
43
- setData((prevData) => prevData.concat(data.results || []));
42
+ setCanLoadMore(selectedPage < Math.ceil(membersData.count / 20));
43
+ setData((prevData) => prevData.concat(membersData.results || []));
44
44
  }
45
45
  }
46
46
 
47
- if (page === 1) {
47
+ if (selectedPage === 1) {
48
48
  setRefreshing(false);
49
49
  } else {
50
50
  setLoadingMore(false);
@@ -8,11 +8,14 @@ export default (unit, sensor) => {
8
8
  const [isLoading, setIsLoading] = useState(false);
9
9
  const fetchData = useCallback(async () => {
10
10
  setIsLoading(true);
11
- const { success, data } = await axiosGet(API.UNIT.MANAGE_ACCESS(unit.id), {
12
- params: { sensor_id: sensor.id },
13
- });
11
+ const { success, data: accessData } = await axiosGet(
12
+ API.UNIT.MANAGE_ACCESS(unit.id),
13
+ {
14
+ params: { sensor_id: sensor.id },
15
+ }
16
+ );
14
17
  if (success) {
15
- setData(data);
18
+ setData(accessData);
16
19
  }
17
20
  setIsLoading(false);
18
21
  }, [unit.id, sensor.id]);
@@ -136,13 +136,13 @@ describe('Test Render ListSubUnit', () => {
136
136
  sensors: [],
137
137
  });
138
138
  });
139
- mock.onPatch(API.SENSOR.CHANGE_SUB_UNIT(200, 3, 73)).reply(200);
139
+ mock.onPatch(API.DEVICE.CHANGE_SUB_UNIT(200, 3, 73)).reply(200);
140
140
  await bottomButtonView.props.onPressMain();
141
141
  expect(mockNavigate).toBeCalled();
142
142
  const TouchableOpacities = instance.findAllByType(TouchableOpacity);
143
143
  await TouchableOpacities[2].props.onPress();
144
144
  mockNavigate.mockClear();
145
- mock.onPatch(API.SENSOR.CHANGE_SUB_UNIT(200, 3, 73)).reply(400);
145
+ mock.onPatch(API.DEVICE.CHANGE_SUB_UNIT(200, 3, 73)).reply(400);
146
146
  await bottomButtonView.props.onPressMain();
147
147
  expect(mockNavigate).not.toBeCalled();
148
148
  });
@@ -49,7 +49,7 @@ const MoveToAnotherSubUnit = memo(({ route }) => {
49
49
 
50
50
  const onSubmit = useCallback(async () => {
51
51
  const { success } = await axiosPatch(
52
- API.SENSOR.CHANGE_SUB_UNIT(unit.id, station.id, sensor.id),
52
+ API.DEVICE.CHANGE_SUB_UNIT(unit.id, station.id, sensor.id),
53
53
  {
54
54
  station_id: selectedSubUnit.id,
55
55
  }
@@ -254,10 +254,10 @@ describe('test NotificationItem', () => {
254
254
 
255
255
  test('test render Notify not in any case', () => {
256
256
  item.content_code = 'NEW CASE';
257
- (item.params = "{ 'unit_id': 1 }"),
258
- act(() => {
259
- tree = create(wrapComponent(item));
260
- });
257
+ item.params = "{ 'unit_id': 1 }";
258
+ act(() => {
259
+ tree = create(wrapComponent(item));
260
+ });
261
261
  const instance = tree.root;
262
262
  const button = instance.findByType(TouchableOpacity);
263
263
  act(() => {
@@ -41,7 +41,7 @@ const NotificationItem = memo(({ item }) => {
41
41
  return values;
42
42
  }, [paramsJSON]);
43
43
 
44
- const customColorText = (text, params) => {
44
+ const customColorText = (text, colorParams) => {
45
45
  return text.split('**').map((str, i) =>
46
46
  i % 2 === 0 ? (
47
47
  <Text type="Body" key={i} style={styles.textNotification}>
@@ -49,7 +49,7 @@ const NotificationItem = memo(({ item }) => {
49
49
  </Text>
50
50
  ) : (
51
51
  <Text type="Body" bold key={i} style={styles.textNotification}>
52
- {params[(i - 1) / 2]}
52
+ {colorParams[(i - 1) / 2]}
53
53
  </Text>
54
54
  )
55
55
  );
@@ -167,7 +167,6 @@ const NotificationItem = memo(({ item }) => {
167
167
  }),
168
168
  };
169
169
  case NOTIFICATION_TYPES.BOOKING_EXPIRED_AND_VIOLATION_CREATED:
170
- const violated_booking_id = paramsJSON.violated_booking_id;
171
170
  return {
172
171
  content: customColorText(
173
172
  t(
@@ -178,7 +177,7 @@ const NotificationItem = memo(({ item }) => {
178
177
  redirect: () =>
179
178
  navigation.navigate(Routes.SmartParkingStack, {
180
179
  screen: Routes.SmartParkingBookingDetails,
181
- params: { id: violated_booking_id || booking_id },
180
+ params: { id: paramsJSON.violated_booking_id || booking_id },
182
181
  }),
183
182
  };
184
183
  case NOTIFICATION_TYPES.MOVE_CAR_WITHOUT_PAY_VIOLATION:
@@ -206,7 +205,6 @@ const NotificationItem = memo(({ item }) => {
206
205
  }),
207
206
  };
208
207
  case NOTIFICATION_TYPES.PAY_FINE_AND_EXTEND_SUCCESSFULLY:
209
- const new_booking_id = paramsJSON.booking_id_new;
210
208
  return {
211
209
  content: customColorText(
212
210
  t('text_notification_content_pay_fine_and_extend_successfully'),
@@ -215,7 +213,7 @@ const NotificationItem = memo(({ item }) => {
215
213
  redirect: () =>
216
214
  navigation.navigate(Routes.SmartParkingStack, {
217
215
  screen: Routes.SmartParkingBookingDetails,
218
- params: { id: new_booking_id },
216
+ params: { id: paramsJSON.booking_id_new },
219
217
  }),
220
218
  };
221
219
  case NOTIFICATION_TYPES.STOP_VIOLATION_FREE_PARKING_ZONE:
@@ -231,8 +229,7 @@ const NotificationItem = memo(({ item }) => {
231
229
  }),
232
230
  };
233
231
  case NOTIFICATION_TYPES.NOTIFY_INDICATOR:
234
- const { sensor_type, summary_id } = paramsJSON;
235
- switch (sensor_type) {
232
+ switch (paramsJSON.sensor_type) {
236
233
  case SENSOR_TYPE.AIR_QUALITY:
237
234
  return {
238
235
  content: customColorText(
@@ -243,7 +240,7 @@ const NotificationItem = memo(({ item }) => {
243
240
  navigation.navigate(Routes.UnitStack, {
244
241
  screen: Routes.UnitSummary,
245
242
  params: {
246
- summaryId: summary_id,
243
+ summaryId: paramsJSON.summary_id,
247
244
  unitId,
248
245
  },
249
246
  }),
@@ -259,7 +256,7 @@ const NotificationItem = memo(({ item }) => {
259
256
  navigation.navigate(Routes.UnitStack, {
260
257
  screen: Routes.UnitSummary,
261
258
  params: {
262
- summaryId: summary_id,
259
+ summaryId: paramsJSON.summary_id,
263
260
  unitId,
264
261
  },
265
262
  }),
@@ -275,7 +272,7 @@ const NotificationItem = memo(({ item }) => {
275
272
  navigation.navigate(Routes.UnitStack, {
276
273
  screen: Routes.UnitSummary,
277
274
  params: {
278
- summaryId: summary_id,
275
+ summaryId: paramsJSON.summary_id,
279
276
  unitId,
280
277
  },
281
278
  }),
@@ -291,7 +288,7 @@ const NotificationItem = memo(({ item }) => {
291
288
  navigation.navigate(Routes.UnitStack, {
292
289
  screen: Routes.UnitSummary,
293
290
  params: {
294
- summaryId: summary_id,
291
+ summaryId: paramsJSON.summary_id,
295
292
  unitId,
296
293
  },
297
294
  }),
@@ -307,7 +304,7 @@ const NotificationItem = memo(({ item }) => {
307
304
  navigation.navigate(Routes.UnitStack, {
308
305
  screen: Routes.UnitSummary,
309
306
  params: {
310
- summaryId: summary_id,
307
+ summaryId: paramsJSON.summary_id,
311
308
  unitId,
312
309
  },
313
310
  }),
@@ -388,12 +385,13 @@ const NotificationItem = memo(({ item }) => {
388
385
  }
389
386
 
390
387
  case NOTIFICATION_TYPES.NOTIFY_REMOVE_UNIT:
391
- const unitOwerName = paramsJSON?.unit_owner_name;
392
- const textNotify = unitOwerName
393
- ? t('text_notification_content_remove_unit_to_member')
394
- : t('text_notification_content_remove_unit_to_owner');
395
388
  return {
396
- content: customColorText(textNotify, arrParams),
389
+ content: customColorText(
390
+ paramsJSON?.unit_owner_name
391
+ ? t('text_notification_content_remove_unit_to_member')
392
+ : t('text_notification_content_remove_unit_to_owner'),
393
+ arrParams
394
+ ),
397
395
  redirect: () => null,
398
396
  iconContent: (
399
397
  <IconComponent icon={'home'} style={styles.backgroundSummer} />
@@ -474,7 +472,6 @@ const NotificationItem = memo(({ item }) => {
474
472
  ),
475
473
  };
476
474
  case NOTIFICATION_TYPES.NOTIFY_RENAME_SUB_UNIT:
477
- const stationId = paramsJSON?.sub_unit_id;
478
475
  return {
479
476
  content: customColorText(
480
477
  t('text_notification_content_rename_sub_unit'),
@@ -485,7 +482,7 @@ const NotificationItem = memo(({ item }) => {
485
482
  screen: Routes.UnitDetail,
486
483
  params: {
487
484
  unitId,
488
- stationId,
485
+ stationId: paramsJSON?.sub_unit_id,
489
486
  },
490
487
  });
491
488
  },
@@ -13,6 +13,7 @@ import {
13
13
  unwatchNotificationData,
14
14
  } from '../../utils/Monitor';
15
15
  import { useSCContextSelector } from '../../context';
16
+ import { notImplemented } from '../../utils/Utils';
16
17
 
17
18
  let page = 1;
18
19
 
@@ -26,12 +27,18 @@ const Notification = memo(() => {
26
27
  <View style={styles.rightComponent}>
27
28
  <TouchableOpacity
28
29
  style={styles.iconPlus}
29
- onPress={() => alert(t('feature_under_development'))}
30
+ onPress={() => {
31
+ notImplemented(t);
32
+ }}
30
33
  >
31
34
  <Icon name={'plus'} size={27} color={Colors.Black} />
32
35
  </TouchableOpacity>
33
36
 
34
- <TouchableOpacity onPress={() => alert(t('feature_under_development'))}>
37
+ <TouchableOpacity
38
+ onPress={() => {
39
+ notImplemented(t);
40
+ }}
41
+ >
35
42
  <Icon name={'search'} size={27} color={Colors.Black} />
36
43
  </TouchableOpacity>
37
44
  </View>
@@ -70,8 +70,8 @@ const Timer = ({
70
70
  }, []);
71
71
 
72
72
  useEffect(() => {
73
- const scrollListener = scrollX.addListener(({ value }) => {
74
- !isFirstTime && onChangeValue && onChangeValue(value, selected);
73
+ const scrollListener = scrollX.addListener(({ value: timeValue }) => {
74
+ !isFirstTime && onChangeValue && onChangeValue(timeValue, selected);
75
75
  });
76
76
  return () => scrollX.removeListener(scrollListener);
77
77
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -62,7 +62,7 @@ const PlayBackCamera = () => {
62
62
  dateTemp = date;
63
63
  }, [selected]);
64
64
 
65
- const onChangeValue = (value, selected) => {
65
+ const onChangeValue = (value, selectedTime) => {
66
66
  if (!isFirstTime) {
67
67
  const currentTime =
68
68
  parseFloat(arrHourTemp[0]) +
@@ -78,11 +78,11 @@ const PlayBackCamera = () => {
78
78
  const m = t4[0] < 10 ? '0' + t4[0] : t4[0];
79
79
  const s = t5 < 10 ? '0' + t5 : t5;
80
80
  setHour({ h, m, s });
81
- if (value + 0.5 > currentTime * 96 && selected === now) {
81
+ if (value + 0.5 > currentTime * 96 && selectedTime === now) {
82
82
  setUri(item?.configuration?.uri);
83
83
  } else {
84
84
  const playback = item?.configuration?.playback || '';
85
- const date = selected.split('-');
85
+ const date = selectedTime.split('-');
86
86
  setUri(
87
87
  `${playback.split('=')[0]}=${date[0]}${date[1]}${
88
88
  date[2]