@eohjsc/react-native-smart-city 0.4.0 → 0.4.2

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 (84) hide show
  1. package/package.json +2 -8
  2. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +2 -1
  3. package/src/commons/ActionGroup/NumberUpDownActionTemplateStyle.js +4 -0
  4. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -1
  5. package/src/commons/ActionGroup/OptionsDropdownActionTemplateStyle.js +6 -0
  6. package/src/commons/ActionGroup/SliderRangeTemplate.js +4 -2
  7. package/src/commons/ActionGroup/SliderRangeTemplateStyles.js +1 -0
  8. package/src/commons/ActionGroup/StatesGridActionTemplate.js +2 -1
  9. package/src/commons/ActionGroup/StatesGridActionTemplateStyle.js +4 -0
  10. package/src/commons/ActionGroup/ThreeButtonTemplate/components/ThreeButtonDefault.js +7 -1
  11. package/src/commons/ActionGroup/ThreeButtonTemplate/components/ThreeButtonDefaultStyles.js +8 -0
  12. package/src/commons/ActionGroup/ThreeButtonTemplate/index.js +3 -1
  13. package/src/commons/ActionGroup/ThreeButtonTemplate/styles.js +3 -0
  14. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +0 -5
  15. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +0 -5
  16. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +24 -42
  17. package/src/commons/Dashboard/MyUnit/index.js +4 -2
  18. package/src/commons/DateTimeRangeChange/index.js +32 -4
  19. package/src/commons/Device/Emergency/EmergencyDetail.js +1 -1
  20. package/src/commons/Device/HistoryChart.js +52 -83
  21. package/src/commons/Device/PMSensor/PMSensorIndicator.js +3 -2
  22. package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
  23. package/src/commons/Device/ProgressBar/__test__/ProgressBar.test.js +0 -5
  24. package/src/commons/Device/ProgressBar/index.js +2 -2
  25. package/src/commons/Device/ProgressBar/styles.js +5 -0
  26. package/src/commons/Device/RainningSensor/CurrentRainSensor.js +5 -2
  27. package/src/commons/Device/WindDirection/Compass/index.js +9 -1
  28. package/src/commons/Device/WindSpeed/Anemometer/index.js +1 -4
  29. package/src/commons/FlatListDnD/index.js +31 -29
  30. package/src/commons/Form/TextInputPassword.js +2 -0
  31. package/src/commons/SelectActionCard/index.js +1 -1
  32. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +0 -7
  33. package/src/commons/Text/index.js +2 -2
  34. package/src/context/mockStore.ts +6 -1
  35. package/src/hooks/index.js +2 -1
  36. package/src/hooks/usePrevious.js +9 -0
  37. package/src/navigations/AddGatewayStack.js +0 -5
  38. package/src/screens/AQIGuide/__test__/AQIGuide.test.js +0 -5
  39. package/src/screens/ActivityLog/__test__/index.test.js +0 -9
  40. package/src/screens/AddNewGateway/SelectDeviceType.js +1 -1
  41. package/src/screens/Automate/AddNewAction/ChooseAction.js +19 -2
  42. package/src/screens/Automate/AddNewAction/Components/SelectDevices.js +2 -2
  43. package/src/screens/Automate/AddNewAction/NewActionWrapper.js +11 -7
  44. package/src/screens/Automate/AddNewAction/SelectControlDevices.js +4 -2
  45. package/src/screens/Automate/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +0 -7
  46. package/src/screens/Automate/EditActionsList/index.js +2 -2
  47. package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +0 -7
  48. package/src/screens/Automate/Scenario/__test__/AddNewOneTap.test.js +0 -7
  49. package/src/screens/Automate/ScriptDetail/__test__/index.test.js +17 -1
  50. package/src/screens/Automate/ScriptDetail/index.js +8 -6
  51. package/src/screens/ChangePosition/__test__/index.test.js +4 -1
  52. package/src/screens/ChangePosition/index.js +24 -21
  53. package/src/screens/ChangePosition/styles.js +19 -4
  54. package/src/screens/Device/__test__/detail.test.js +147 -89
  55. package/src/screens/Device/__test__/mqttDetail.test.js +2 -15
  56. package/src/screens/Device/components/ChartWrapper.js +32 -26
  57. package/src/screens/Device/components/SensorDisplayItem.js +33 -16
  58. package/src/screens/Device/components/VisualChart.js +12 -3
  59. package/src/screens/Device/components/__test__/VisualChart.test.js +0 -7
  60. package/src/screens/Device/detail.js +13 -12
  61. package/src/screens/Device/hooks/useDeviceWatchConfigControl.js +10 -6
  62. package/src/screens/Device/styles.js +1 -1
  63. package/src/screens/Notification/__test__/NotificationItem.test.js +2 -0
  64. package/src/screens/PlayBackCamera/Styles/index.js +1 -1
  65. package/src/screens/PlayBackCamera/index.js +7 -7
  66. package/src/screens/SharedUnit/__test__/ShareUnit.test.js +0 -5
  67. package/src/screens/Sharing/__test__/SelectUser.test.js +0 -7
  68. package/src/screens/SmartAccount/index.js +20 -11
  69. package/src/screens/SubUnit/EditSubUnit.js +1 -2
  70. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +0 -9
  71. package/src/screens/SubUnit/__test__/Detail.test.js +0 -7
  72. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +0 -12
  73. package/src/screens/TDSGuide/__test__/TDSGuide.test.js +0 -6
  74. package/src/screens/UVIndexGuide/__test__/UVIndexGuide.test.js +0 -6
  75. package/src/screens/Unit/__test__/CheckSendEmail.test.js +0 -11
  76. package/src/screens/Unit/__test__/Detail.test.js +0 -12
  77. package/src/screens/Unit/__test__/ManageUnit.test.js +0 -8
  78. package/src/screens/UnitSummary/components/PowerConsumption/index.js +4 -6
  79. package/src/screens/WaterQualityGuide/__test__/index.test.js +0 -5
  80. package/src/utils/I18n/translations/en.js +3 -1
  81. package/src/utils/I18n/translations/vi.js +3 -1
  82. package/src/utils/Route/index.js +0 -1
  83. package/src/screens/AddNewGateway/PlugAndPlay/ConnectRouterGuide.js +0 -49
  84. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectRouterGuide.test.js +0 -68
@@ -8,11 +8,9 @@ import React, {
8
8
  } from 'react';
9
9
  import { View, TouchableOpacity, Platform } from 'react-native';
10
10
  import { useNavigation, useFocusEffect } from '@react-navigation/native';
11
- import { useSelector } from 'react-redux';
12
11
  import { IconFill, IconOutline } from '@ant-design/icons-react-native';
13
12
  import { Icon } from '@ant-design/react-native';
14
13
  import moment from 'moment';
15
- import { get } from 'lodash';
16
14
 
17
15
  import { SCContext } from '../../context';
18
16
  import { Action } from '../../context/actionType';
@@ -130,7 +128,9 @@ const DeviceDetail = ({ route }) => {
130
128
  if (display.items.length === 0) {
131
129
  return false;
132
130
  }
133
- const action = display.items.filter((item) => item.type === 'action');
131
+ const action = display.items.filter(
132
+ (item) => (item.template || item.type) === 'action'
133
+ );
134
134
  if (action.length === 0) {
135
135
  return false;
136
136
  }
@@ -176,8 +176,8 @@ const DeviceDetail = ({ route }) => {
176
176
  const { isFavorite, addToFavorites, removeFromFavorites } =
177
177
  useFavoriteDevice(sensor);
178
178
 
179
- const currentUserId = useSelector((state) =>
180
- get(state, 'auth.account.user.id', 0)
179
+ const currentUserId = useSCContextSelector(
180
+ (state) => state.auth.account.user.id
181
181
  );
182
182
 
183
183
  const canManageSubUnit = useMemo(() => {
@@ -297,7 +297,7 @@ const DeviceDetail = ({ route }) => {
297
297
 
298
298
  success &&
299
299
  data.items.length &&
300
- data.items.some((item) => item.type === 'action') &&
300
+ data.items.some((item) => (item?.template || item?.type) === 'action') &&
301
301
  (await fetchRemoteControlOptions());
302
302
  }, [token, sensor, setDeviceId, fetchRemoteControlOptions]);
303
303
 
@@ -365,9 +365,9 @@ const DeviceDetail = ({ route }) => {
365
365
  menuItems.push({
366
366
  route: Routes.ChangePosition,
367
367
  data: {
368
- unit,
369
368
  sensor,
370
- displayItems: display.items,
369
+ display,
370
+ setDisplay,
371
371
  evaluate,
372
372
  station,
373
373
  fetchDataDeviceDetail,
@@ -454,7 +454,7 @@ const DeviceDetail = ({ route }) => {
454
454
  }
455
455
  return [...menuItems];
456
456
  }, [
457
- display.items,
457
+ display,
458
458
  isOwner,
459
459
  isShowSetupEmergencyContact,
460
460
  sideMenu,
@@ -572,9 +572,10 @@ const DeviceDetail = ({ route }) => {
572
572
  lastUpdated: lastUpdated,
573
573
  };
574
574
  });
575
- const configsData = data.configs.filter(
576
- (id) => !mqttConfigs.includes(id)
577
- );
575
+ let configsData = data?.configs || [];
576
+ if (![null, undefined, NaN].includes(mqttConfigs)) {
577
+ configsData = configsData.filter((item) => !mqttConfigs[item.id]);
578
+ }
578
579
  let configValues = getConfigGlobalState('configValues');
579
580
  let hasValueChange = false;
580
581
  configsData.map((config) => {
@@ -3,7 +3,11 @@ import { DEVICE_TYPE } from '../../../configs/Constants';
3
3
  import { getConfigControlFromDeviceDisplay } from '../utils';
4
4
  import { useWatchConfigs } from '../../../hooks/IoT';
5
5
 
6
- export const useDeviceWatchConfigControl = (device, display, mqttConfigs) => {
6
+ export const useDeviceWatchConfigControl = (
7
+ device,
8
+ display,
9
+ mqttConfigs = {}
10
+ ) => {
7
11
  const configsNeedWatching = useMemo(() => {
8
12
  if (
9
13
  !device?.is_managed_by_backend ||
@@ -13,10 +17,11 @@ export const useDeviceWatchConfigControl = (device, display, mqttConfigs) => {
13
17
  ) {
14
18
  return [];
15
19
  }
16
-
17
- const configsControl = getConfigControlFromDeviceDisplay(display);
18
- if (mqttConfigs?.length) {
19
- return configsControl.filter((id) => !mqttConfigs.includes(id));
20
+ let configsControl = getConfigControlFromDeviceDisplay(display);
21
+ if (![null, undefined, NaN].includes(mqttConfigs)) {
22
+ configsControl = configsControl.filter(
23
+ (configId) => !mqttConfigs[configId]
24
+ );
20
25
  }
21
26
  return configsControl;
22
27
  }, [
@@ -25,6 +30,5 @@ export const useDeviceWatchConfigControl = (device, display, mqttConfigs) => {
25
30
  device?.is_managed_by_backend,
26
31
  display,
27
32
  ]);
28
-
29
33
  useWatchConfigs(configsNeedWatching);
30
34
  };
@@ -29,7 +29,7 @@ export default StyleSheet.create({
29
29
  width: '100%',
30
30
  height: 150,
31
31
  paddingHorizontal: 16,
32
- marginBottom: 16,
32
+ marginBottom: 0,
33
33
  },
34
34
  bottomButtonEmergencyResolve: {
35
35
  borderTopWidth: 1,
@@ -56,6 +56,8 @@ describe('test NotificationItem', () => {
56
56
  NOTIFICATION_TYPES.NOTIFY_REMOVE_DEVICE,
57
57
  NOTIFICATION_TYPES.NOTIFY_CHANGE_UNIT_OLD_OWNER,
58
58
  NOTIFICATION_TYPES.SUBSCRIBE_SUCCESS,
59
+ NOTIFICATION_TYPES.NOTIFY_UPGRADE_SYSTEM,
60
+ NOTIFICATION_TYPES.TRIAL_WILL_END,
59
61
  ];
60
62
 
61
63
  for (const content_code of listCase2) {
@@ -50,7 +50,7 @@ export default StyleSheet.create({
50
50
  flexDirection: 'row',
51
51
  marginTop: -10,
52
52
  },
53
- commomButton: {
53
+ commonButton: {
54
54
  height: 40,
55
55
  justifyContent: 'center',
56
56
  alignItems: 'center',
@@ -205,7 +205,7 @@ const PlayBackCamera = () => {
205
205
  <TouchableOpacity
206
206
  accessibilityLabel={AccessibilityLabel.ON_PRESS_SUB_DATE}
207
207
  onPress={onSubtractDate}
208
- style={styles.commomButton}
208
+ style={styles.commonButton}
209
209
  >
210
210
  <Image source={Images.arrowLeft} />
211
211
  </TouchableOpacity>
@@ -219,14 +219,14 @@ const PlayBackCamera = () => {
219
219
  </Text>
220
220
  <TouchableOpacity
221
221
  onPress={onOpenDateModal}
222
- style={styles.commomButton}
222
+ style={styles.commonButton}
223
223
  >
224
224
  <Image source={Images.file} style={styles.iconDate} />
225
225
  </TouchableOpacity>
226
226
  <TouchableOpacity
227
227
  accessibilityLabel={AccessibilityLabel.ON_PRESS_ADD_DATE}
228
228
  onPress={onAddDate}
229
- style={styles.commomButton}
229
+ style={styles.commonButton}
230
230
  >
231
231
  <Image source={Images.arrowLeft} style={styles.arrowRight} />
232
232
  </TouchableOpacity>
@@ -283,19 +283,19 @@ const PlayBackCamera = () => {
283
283
  <View style={styles.wrapBottomButton}>
284
284
  <TouchableOpacity
285
285
  onPress={onPressCancel}
286
- style={styles.commomButton}
286
+ style={styles.commonButton}
287
287
  accessibilityLabel={AccessibilityLabel.ON_PRESS_CANCEL}
288
288
  >
289
- <Text type="h4" semibold hilight>
289
+ <Text type="h4" semibold highlight>
290
290
  {t('cancel')}
291
291
  </Text>
292
292
  </TouchableOpacity>
293
293
  <TouchableOpacity
294
294
  accessibilityLabel={AccessibilityLabel.ON_PRESS_OK}
295
295
  onPress={onPressOk}
296
- style={styles.commomButton}
296
+ style={styles.commonButton}
297
297
  >
298
- <Text type="h4" semibold hilight>
298
+ <Text type="h4" semibold highlight>
299
299
  {t('done')}
300
300
  </Text>
301
301
  </TouchableOpacity>
@@ -21,11 +21,6 @@ const wrapComponent = () => (
21
21
  </SCProvider>
22
22
  );
23
23
 
24
- jest.mock('react-redux', () => ({
25
- ...jest.requireActual('react-redux'),
26
- useSelector: jest.fn(),
27
- }));
28
-
29
24
  jest.mock('react', () => ({
30
25
  ...jest.requireActual('react'),
31
26
  useLayoutEffect: jest.fn(),
@@ -26,13 +26,6 @@ const mockedGoBack = jest.fn();
26
26
  const mockedDangerouslyGetState = jest.fn();
27
27
  const mockedDangerouslyGetParentGoBack = jest.fn();
28
28
 
29
- jest.mock('react-redux', () => {
30
- return {
31
- ...jest.requireActual('react-redux'),
32
- useSelector: jest.fn(),
33
- };
34
- });
35
-
36
29
  jest.mock('@react-navigation/native', () => {
37
30
  return {
38
31
  ...jest.requireActual('@react-navigation/native'),
@@ -1,12 +1,6 @@
1
- import React, { useState, useCallback, useMemo } from 'react';
2
- import {
3
- Image,
4
- View,
5
- ScrollView,
6
- TouchableOpacity,
7
- Keyboard,
8
- } from 'react-native';
9
-
1
+ import React, { useState, useCallback, useMemo, useRef } from 'react';
2
+ import { Image, View, TouchableOpacity, Keyboard } from 'react-native';
3
+ import { KeyboardAwareScrollView } from '@eohjsc/react-native-keyboard-aware-scroll-view';
10
4
  import { HeaderCustom } from '../../commons/Header';
11
5
  import Text from '../../commons/Text';
12
6
  import TextInput from '../../commons/Form/TextInput';
@@ -29,6 +23,8 @@ const SmartAccount = ({ route }) => {
29
23
  const [password, setPassword] = useState('');
30
24
  const [passwordError, setPasswordlErrorState] = useState();
31
25
  const [selectItemActive, setSelectItemActive] = useState(null);
26
+ const [disableKeyBoardAnimated, setDisableKeyBoardAnimated] = useState(true);
27
+ const keyboardAwareRef = useRef();
32
28
 
33
29
  const supplierItems = useMemo(() => {
34
30
  return [
@@ -106,13 +102,23 @@ const SmartAccount = ({ route }) => {
106
102
  [navigate]
107
103
  );
108
104
 
105
+ const onFocus = () => {
106
+ keyboardAwareRef?.current?.scrollToEnd(true);
107
+ setDisableKeyBoardAnimated(false);
108
+ };
109
+
109
110
  return (
110
111
  <View style={styles.container}>
111
112
  <HeaderCustom
112
113
  title={t('add_new_smart_account')}
113
114
  titleStyle={styles.title}
114
115
  />
115
- <ScrollView contentContainerStyle={styles.scroll}>
116
+ <KeyboardAwareScrollView
117
+ innerRef={(ref) => (keyboardAwareRef.current = ref)}
118
+ contentContainerStyle={styles.scroll}
119
+ enableOnAndroid
120
+ extraScrollHeight={100}
121
+ >
116
122
  <Text bold type="H4" color={Colors.Gray9} style={styles.text}>
117
123
  {t('smart_supplier')}
118
124
  </Text>
@@ -147,6 +153,8 @@ const SmartAccount = ({ route }) => {
147
153
  secureTextEntry={true}
148
154
  placeholder={t('enter_password')}
149
155
  onChange={(value) => setPassword(value)}
156
+ onFocus={onFocus}
157
+ onBlur={() => setDisableKeyBoardAnimated(true)}
150
158
  value={password}
151
159
  errorText={passwordError}
152
160
  returnKeyType={'done'}
@@ -158,13 +166,14 @@ const SmartAccount = ({ route }) => {
158
166
  AccessibilityLabel.ON_CHANGE_SEARCH_PASSWORD_SMART_ACCOUNT
159
167
  }
160
168
  />
161
- </ScrollView>
169
+ </KeyboardAwareScrollView>
162
170
  <BottomButtonView
163
171
  style={styles.bottomButtonView}
164
172
  mainTitle={t('save')}
165
173
  onPressMain={validate}
166
174
  typeMain={'primary'}
167
175
  accessibilityLabelPrefix={AccessibilityLabel.LOGIN_SMART_ACCOUNT}
176
+ disableKeyBoardAnimated={disableKeyBoardAnimated}
168
177
  />
169
178
  </View>
170
179
  );
@@ -1,6 +1,5 @@
1
1
  import React, { useState, useCallback, useEffect } from 'react';
2
2
  import { View, TouchableOpacity, Image } from 'react-native';
3
- import { connect } from 'react-redux';
4
3
  import { useIsFocused, useNavigation } from '@react-navigation/native';
5
4
  import { useTranslations } from '../../hooks/Common/useTranslations';
6
5
 
@@ -280,4 +279,4 @@ const EditSubUnit = ({ route }) => {
280
279
  );
281
280
  };
282
281
 
283
- export default connect()(EditSubUnit);
282
+ export default EditSubUnit;
@@ -23,20 +23,12 @@ const wrapComponent = (route, storeData = {}) => (
23
23
  );
24
24
 
25
25
  const mockedNavigate = jest.fn();
26
- const mockedDispatch = jest.fn();
27
26
  const mockedGoBack = jest.fn();
28
27
 
29
28
  const mock = new MockAdapter(api.axiosInstance);
30
29
  jest.mock('react-native-toast-message');
31
30
  jest.mock('react-native-image-resizer');
32
31
 
33
- jest.mock('react-redux', () => {
34
- return {
35
- ...jest.requireActual('react-redux'),
36
- useDispatch: () => mockedDispatch,
37
- };
38
- });
39
-
40
32
  const mockNavigationDispatch = jest.fn();
41
33
  const mockReplace = jest.fn();
42
34
 
@@ -69,7 +61,6 @@ describe('Test AddSubUnit', () => {
69
61
  },
70
62
  },
71
63
  };
72
- mockedDispatch.mockClear();
73
64
  mockedNavigate.mockClear();
74
65
  mockNavigationDispatch.mockClear();
75
66
  Toast.show.mockClear();
@@ -16,13 +16,6 @@ const mockedDangerouslyGetState = jest.fn();
16
16
  const mockedDangerouslyGetStatePop = jest.fn();
17
17
  const mockedPop = jest.fn();
18
18
 
19
- jest.mock('react-redux', () => {
20
- return {
21
- ...jest.requireActual('react-redux'),
22
- useSelector: jest.fn(),
23
- };
24
- });
25
-
26
19
  jest.mock('@react-navigation/native', () => {
27
20
  return {
28
21
  ...jest.requireActual('@react-navigation/native'),
@@ -25,18 +25,6 @@ const mockedPop = jest.fn();
25
25
  const mock = new MockAdapter(api.axiosInstance);
26
26
  jest.mock('react-native-toast-message');
27
27
 
28
- jest.mock('react-redux', () => {
29
- return {
30
- ...jest.requireActual('react-redux'),
31
- useDispatch: () => mockedDispatch,
32
- useSelector: jest.fn(),
33
- connect: () => {
34
- return (component) => component;
35
- },
36
- useIsFocused: jest.fn(),
37
- };
38
- });
39
-
40
28
  const mockUseIsFocused = jest.fn();
41
29
 
42
30
  jest.mock('@react-navigation/native', () => {
@@ -14,12 +14,6 @@ const wrapComponent = () => (
14
14
  </SCProvider>
15
15
  );
16
16
 
17
- jest.mock('react-redux', () => ({
18
- ...jest.requireActual('react-redux'),
19
- useSelector: jest.fn(),
20
- useDispatch: jest.fn(),
21
- }));
22
-
23
17
  jest.mock('react', () => ({
24
18
  ...jest.requireActual('react'),
25
19
  useLayoutEffect: jest.fn(),
@@ -14,12 +14,6 @@ const wrapComponent = () => (
14
14
  </SCProvider>
15
15
  );
16
16
 
17
- jest.mock('react-redux', () => ({
18
- ...jest.requireActual('react-redux'),
19
- useSelector: jest.fn(),
20
- useDispatch: jest.fn(),
21
- }));
22
-
23
17
  jest.mock('react', () => ({
24
18
  ...jest.requireActual('react'),
25
19
  useLayoutEffect: jest.fn(),
@@ -11,17 +11,6 @@ import NavBar from '../../../commons/NavBar';
11
11
 
12
12
  const mock = new MockAdapter(api.axiosInstance);
13
13
 
14
- const mockDispatch = jest.fn();
15
-
16
- jest.mock('react-redux', () => ({
17
- ...jest.requireActual('react-redux'),
18
- useDispatch: () => mockDispatch,
19
- useSelector: () => 'vi',
20
- connect: () => {
21
- return (component) => component;
22
- },
23
- }));
24
-
25
14
  jest.mock('../../../iot/RemoteControl/HomeAssistant', () => ({
26
15
  ...jest.requireActual('../../../iot/RemoteControl/HomeAssistant'),
27
16
  homeAssistantConnect: jest.fn(async () => ({
@@ -22,7 +22,6 @@ import PreventAccess from '../../../commons/PreventAccess';
22
22
  import Routes from '../../../utils/Route';
23
23
  import { storeData } from '../../../utils/Storage';
24
24
 
25
- const mockDispatch = jest.fn();
26
25
  jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
27
26
  const wrapComponent = (route, account) => (
28
27
  <SCProvider initState={mockSCStore({})}>
@@ -30,17 +29,6 @@ const wrapComponent = (route, account) => (
30
29
  </SCProvider>
31
30
  );
32
31
 
33
- jest.mock('react-redux', () => {
34
- return {
35
- ...jest.requireActual('react-redux'),
36
- useDispatch: mockDispatch, // fix problem of re-render continuously
37
- useSelector: () => 'vi',
38
- connect: () => {
39
- return (component) => component;
40
- },
41
- };
42
- });
43
-
44
32
  const mockConnectHomeAssistant = jest.fn();
45
33
  jest.mock('../../../hooks/IoT', () => {
46
34
  return {
@@ -27,12 +27,6 @@ jest.mock('@react-navigation/native', () => {
27
27
  };
28
28
  });
29
29
 
30
- const mockedDispatch = jest.fn();
31
- jest.mock('react-redux', () => ({
32
- useSelector: jest.fn(),
33
- useDispatch: () => mockedDispatch,
34
- }));
35
-
36
30
  jest.mock('../../../hooks/Common', () => {
37
31
  return {
38
32
  useIsOwnerOfUnit: () => ({ isOwner: true }),
@@ -179,7 +173,6 @@ describe('Test Manage Unit', () => {
179
173
  await act(async () => {
180
174
  await bottomButton.props.onPress();
181
175
  });
182
- expect(mockedDispatch).not.toBeCalled();
183
176
  });
184
177
 
185
178
  it('rename Unit success', async () => {
@@ -201,7 +194,6 @@ describe('Test Manage Unit', () => {
201
194
  await alertActions[0].props.rightButtonClick();
202
195
  });
203
196
 
204
- expect(mockedDispatch).not.toBeCalled();
205
197
  expect(spyToast).toBeCalled();
206
198
  spyToast.mockReset();
207
199
  spyToast.mockRestore();
@@ -1,17 +1,17 @@
1
1
  import React, { memo, useMemo, useEffect, useState } from 'react';
2
- import { View, StyleSheet } from 'react-native';
2
+ import { StyleSheet } from 'react-native';
3
3
  import { useTranslations } from '../../../../hooks/Common/useTranslations';
4
4
  import moment from 'moment';
5
+
5
6
  import { API, Colors } from '../../../../configs';
6
7
  import Text from '../../../../commons/Text';
7
8
  import { Section, Today } from '../../../../commons';
8
9
  import ListQualityIndicator from '../../../../commons/Device/WaterQualitySensor/ListQualityIndicator';
9
10
  import PMSensorIndicator from '../../../../commons/Device/PMSensor/PMSensorIndicator';
10
- import ConfigHistoryChart from '../../../../commons/UnitSummary/ConfigHistoryChart';
11
11
  import HistoryChart from '../../../../commons/Device/HistoryChart';
12
12
  import { AccessibilityLabel } from '../../../../configs/Constants';
13
-
14
13
  import { axiosGet } from '../../../../utils/Apis/axios';
14
+ import VisualChart from '../../../Device/components/VisualChart';
15
15
 
16
16
  const PowerConsumption = memo(({ summaryDetail }) => {
17
17
  const t = useTranslations();
@@ -141,9 +141,7 @@ const PowerConsumption = memo(({ summaryDetail }) => {
141
141
  accessibilityLabel={AccessibilityLabel.LIST_QUALITY_INDICATOR_PC}
142
142
  />
143
143
  {showBoxHistory && (
144
- <View>
145
- <ConfigHistoryChart configs={configs} />
146
- </View>
144
+ <VisualChart item={{ configuration: { configs } }} />
147
145
  )}
148
146
  </Section>
149
147
 
@@ -6,11 +6,6 @@ import Text from '../../../commons/Text';
6
6
  import { SCProvider } from '../../../context';
7
7
  import { mockSCStore } from '../../../context/mockStore';
8
8
 
9
- jest.mock('react-redux', () => ({
10
- ...jest.requireActual('react-redux'),
11
- useSelector: jest.fn(),
12
- }));
13
-
14
9
  jest.mock('react', () => ({
15
10
  ...jest.requireActual('react'),
16
11
  useLayoutEffect: jest.fn(),
@@ -1005,7 +1005,7 @@ export default {
1005
1005
  tap_to_run: 'Tap to run',
1006
1006
  how_to_start: 'How to start',
1007
1007
  'set_up {name}': 'Setup {name}',
1008
- action: 'Action',
1008
+ action: 'action',
1009
1009
  power: 'Power',
1010
1010
  actions_list: 'Actions list',
1011
1011
  delette_action: 'Delete action?',
@@ -1421,5 +1421,7 @@ export default {
1421
1421
  'View action log is incomplete. Please visit app.e-ra.io to complete your operation.',
1422
1422
  no_permission_smart_script_for_multi_unit:
1423
1423
  'Smart script for Multi Unit is incomplete. Please visit app.e-ra.io to complete your operation.',
1424
+ you_can_only_add_more: 'You can only add more {number}',
1425
+ actions: 'actions',
1424
1426
  value_must_be_6_digits_or_less: 'Value must be 6 digits or less',
1425
1427
  };
@@ -1018,7 +1018,7 @@ export default {
1018
1018
  tap_to_run: 'Nhấn để chạy',
1019
1019
  how_to_start: 'Cách khởi động',
1020
1020
  'set_up {name}': 'Thiết lập {name}',
1021
- action: 'Hành động',
1021
+ action: 'hành động',
1022
1022
  power: 'Nguồn điện',
1023
1023
  actions_list: 'Dánh sách hành động',
1024
1024
  delette_action: 'Xoá hành động ?',
@@ -1431,5 +1431,7 @@ export default {
1431
1431
  'Xem lịch sử hoạt động chưa hoàn tất. Hãy truy cập app.e-ra.io để hoàn thiện thao tác của bạn.',
1432
1432
  no_permission_smart_script_for_multi_unit:
1433
1433
  'Kịch bản thông minh cho nhiều địa điểm chưa hoàn tất. Hãy truy cập app.e-ra.io để hoàn thiện thao tác của bạn.',
1434
+ you_can_only_add_more: 'Bạn chỉ có thể thêm {number}',
1435
+ actions: 'hành động',
1434
1436
  value_must_be_6_digits_or_less: 'Giá trị phải nhỏ hơn 6 chữ số',
1435
1437
  };
@@ -145,7 +145,6 @@ const Routes = {
145
145
  SmartAccountConnecting: 'SmartAccountConnecting',
146
146
  EmergencySetting: 'EmergencySetting',
147
147
  FirstWarning: 'FirstWarning',
148
- ConnectRouterGuide: 'ConnectRouterGuide',
149
148
  ZigbeeDeviceConnectGuide: 'ZigbeeDeviceConnectGuide',
150
149
  ConfirmUnitDeletion: 'ConfirmUnitDeletion',
151
150
  SmartAccount: 'SmartAccount',
@@ -1,49 +0,0 @@
1
- import React, { useCallback } from 'react';
2
- import { View } from 'react-native';
3
- import { useNavigation } from '@react-navigation/native';
4
- import { useTranslations } from '../../../hooks/Common/useTranslations';
5
- import { HeaderCustom } from '../../../commons/Header';
6
- import { ViewButtonBottom } from '../../../commons';
7
- import RouterConnectIcon from '../../../../assets/images/AddNewDevice/router-connect-icon.svg';
8
- import Routes from '../../../utils/Route';
9
- import { Colors } from '../../../configs';
10
- import Text from '../../../commons/Text';
11
- import styles from './ConnectRouterGuideStyles';
12
-
13
- const ConnectRouterGuide = ({ route }) => {
14
- const t = useTranslations();
15
- const { navigate, goBack } = useNavigation();
16
-
17
- const onRight = useCallback(() => {
18
- navigate(Routes.SelectZigbeeGateway, {
19
- ...route?.params,
20
- });
21
- }, [navigate, route]);
22
-
23
- return (
24
- <View style={styles.container}>
25
- <HeaderCustom isShowSeparator />
26
- <View style={styles.contentContainer}>
27
- <View style={styles.guideContent}>
28
- <RouterConnectIcon width={94} height={94} />
29
- <Text type="H4" semibold style={styles.txtContent}>
30
- {t('connect_to_router')}
31
- </Text>
32
- <Text style={styles.txtContent}>{t('connect_router_content')}</Text>
33
- <Text semibold color={Colors.Gray7} style={styles.txtContent}>
34
- {t('read_device_manual_guide')}
35
- </Text>
36
- </View>
37
- </View>
38
- <ViewButtonBottom
39
- leftTitle={t('cancel')}
40
- onLeftClick={goBack}
41
- rightTitle={t('text_next')}
42
- onRightClick={onRight}
43
- styleButtonLeftText={styles.buttonLeftText}
44
- />
45
- </View>
46
- );
47
- };
48
-
49
- export default ConnectRouterGuide;