@eohjsc/react-native-smart-city 0.3.48 → 0.3.50

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 (196) hide show
  1. package/package.json +4 -4
  2. package/src/Images/DevMode/file_copy.svg +3 -0
  3. package/src/Images/DevMode/inforCode.png +0 -0
  4. package/src/Images/DevMode/inforCode@2x.png +0 -0
  5. package/src/Images/DevMode/inforCode@3x.png +0 -0
  6. package/src/commons/Action/__test__/ItemQuickAction.test.js +0 -7
  7. package/src/commons/ActionGroup/OnOffTemplate/index.js +6 -8
  8. package/src/commons/ActionGroup/SliderRangeTemplate.js +7 -2
  9. package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +1 -8
  10. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +99 -1
  11. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +28 -11
  12. package/src/commons/ActionTemplate/__test__/CurtainAction.test.js +64 -0
  13. package/src/commons/ActionTemplate/__test__/OnOffSmartLockAction.test.js +54 -0
  14. package/src/commons/ActionTemplate/__test__/index.test.js +0 -7
  15. package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +3 -3
  16. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +1 -1
  17. package/src/commons/Dashboard/MyUnit/index.js +30 -4
  18. package/src/commons/DevMode/Styles/ItemStyles.js +1 -1
  19. package/src/commons/Device/HorizontalBarChart.js +0 -1
  20. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +4 -1
  21. package/src/commons/FourButtonFilterHistory/__test__/FourButtonFilterHistory.test.js +0 -7
  22. package/src/commons/Header/HeaderCustom.js +13 -6
  23. package/src/commons/MediaPlayer/__test__/index.test.js +0 -7
  24. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +0 -1
  25. package/src/commons/MenuActionMore/index.js +4 -1
  26. package/src/commons/NavBar/index.js +1 -1
  27. package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +1 -1
  28. package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +0 -7
  29. package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +0 -7
  30. package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +0 -7
  31. package/src/commons/Processing/styles.js +0 -2
  32. package/src/commons/RowItem/index.js +6 -1
  33. package/src/commons/SelectUnit/index.js +4 -1
  34. package/src/commons/Sharing/WrapHeaderScrollable.js +5 -4
  35. package/src/commons/StatusBox/styles.js +8 -3
  36. package/src/commons/SubUnit/__test__/Favorites.test.js +0 -7
  37. package/src/commons/SubUnit/__test__/ShortDetail.test.js +0 -7
  38. package/src/commons/Tabbar/__test__/index.test.js +0 -7
  39. package/src/commons/Unit/__test__/HeaderUnit.test.js +0 -5
  40. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +9 -9
  41. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +41 -39
  42. package/src/configs/API.js +28 -0
  43. package/src/configs/AccessibilityLabel.js +13 -0
  44. package/src/configs/Colors.js +4 -0
  45. package/src/configs/Constants.js +8 -0
  46. package/src/configs/Images.js +1 -0
  47. package/src/configs/SCConfig.js +3 -0
  48. package/src/context/actionType.ts +8 -1
  49. package/src/context/mockStore.ts +8 -2
  50. package/src/context/reducer.ts +27 -4
  51. package/src/hooks/IoT/__test__/useWatchConfigs.test.js +46 -0
  52. package/src/hooks/IoT/useBluetoothConnection.js +78 -4
  53. package/src/hooks/IoT/useBluetoothDeviceConnected.js +1 -1
  54. package/src/iot/RemoteControl/Bluetooth.js +0 -16
  55. package/src/iot/RemoteControl/__test__/Bluetooth.test.js +0 -25
  56. package/src/navigations/AddDeviceStack.js +0 -5
  57. package/src/navigations/Main.js +39 -0
  58. package/src/navigations/UnitStack.js +23 -9
  59. package/src/screens/AQIGuide/index.js +2 -2
  60. package/src/screens/ActivityLog/__test__/FilterPopup.test.js +0 -7
  61. package/src/screens/ActivityLog/__test__/ItemLog.test.js +0 -7
  62. package/src/screens/ActivityLog/__test__/index.test.js +0 -7
  63. package/src/screens/ActivityLog/styles/itemLogStyles.js +1 -0
  64. package/src/screens/AddLocationMaps/__test__/index.test.js +0 -7
  65. package/src/screens/AddNewAction/SelectAction.js +22 -18
  66. package/src/screens/AddNewAction/__test__/SelectAction.test.js +35 -16
  67. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +0 -7
  68. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +1 -5
  69. package/src/screens/AddNewGateway/ConnectingDevice.js +25 -3
  70. package/src/screens/AddNewGateway/ConnectingWifiGuide.js +1 -1
  71. package/src/screens/AddNewGateway/ConnectingWifiGuideStyles.js +10 -0
  72. package/src/screens/AddNewGateway/ConnectingZigbeeDevice.js +5 -6
  73. package/src/screens/AddNewGateway/ShareWifiPassword.js +2 -1
  74. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +0 -4
  75. package/src/screens/AddNewGateway/__test__/ConnectingModbusDevice.test.js +0 -4
  76. package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +2 -5
  77. package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +29 -6
  78. package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +0 -7
  79. package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +0 -4
  80. package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +0 -4
  81. package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +0 -4
  82. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +0 -7
  83. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +0 -1
  84. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +0 -7
  85. package/src/screens/Device/__test__/detail.test.js +1 -1
  86. package/src/screens/Device/detail.js +12 -6
  87. package/src/screens/Device/hooks/useDisconnectedDevice.js +26 -7
  88. package/src/screens/EmergencyContacts/__test__/hooks.test.js +79 -0
  89. package/src/screens/Gateway/DetailConfigActionModbus/__test__/index.test.js +138 -0
  90. package/src/screens/Gateway/DetailConfigActionModbus/index.js +180 -0
  91. package/src/screens/Gateway/DetailConfigActionModbus/styles.js +9 -0
  92. package/src/screens/Gateway/DetailConfigActionZigbee/__test__/index.test.js +73 -0
  93. package/src/screens/Gateway/DetailConfigActionZigbee/index.js +62 -0
  94. package/src/screens/Gateway/DetailConfigActionZigbee/styles.js +9 -0
  95. package/src/screens/Gateway/DeviceGatewayInfo/__test__/index.test.js +73 -0
  96. package/src/screens/Gateway/DeviceGatewayInfo/index.js +96 -0
  97. package/src/screens/Gateway/DeviceGatewayInfo/styles.js +9 -0
  98. package/src/screens/Gateway/DeviceModbusDetail/__test__/index.test.js +393 -0
  99. package/src/screens/Gateway/DeviceModbusDetail/index.js +176 -0
  100. package/src/screens/Gateway/DeviceModbusDetail/styles.js +12 -0
  101. package/src/screens/Gateway/DeviceZigbeeDetail/__test__/index.test.js +265 -0
  102. package/src/screens/Gateway/DeviceZigbeeDetail/index.js +148 -0
  103. package/src/screens/Gateway/DeviceZigbeeDetail/styles.js +12 -0
  104. package/src/screens/Gateway/GatewayConnectionMethods/__test__/index.test.js +37 -0
  105. package/src/screens/Gateway/GatewayConnectionMethods/index.js +73 -0
  106. package/src/screens/Gateway/GatewayConnectionMethods/styles.js +45 -0
  107. package/src/screens/Gateway/GatewayDetail/__test__/index.test.js +298 -0
  108. package/src/screens/Gateway/GatewayDetail/index.js +148 -0
  109. package/src/screens/Gateway/GatewayDetail/styles.js +12 -0
  110. package/src/screens/Gateway/GatewayInfo/__test__/index.test.js +137 -0
  111. package/src/screens/Gateway/GatewayInfo/index.js +115 -0
  112. package/src/screens/Gateway/GatewayInfo/styles.js +9 -0
  113. package/src/screens/Gateway/__test__/index.test.js +58 -0
  114. package/src/screens/Gateway/components/Detail/__test__/index.test.js +46 -0
  115. package/src/screens/Gateway/components/Detail/index.js +62 -0
  116. package/src/screens/Gateway/components/Detail/styles.js +27 -0
  117. package/src/screens/Gateway/components/DetailActionModbus/__test__/index.test.js +49 -0
  118. package/src/screens/Gateway/components/DetailActionModbus/index.js +52 -0
  119. package/src/screens/Gateway/components/DetailActionModbus/styles.js +32 -0
  120. package/src/screens/Gateway/components/DetailConfigAction/__test__/index.test.js +59 -0
  121. package/src/screens/Gateway/components/DetailConfigAction/index.js +69 -0
  122. package/src/screens/Gateway/components/DetailConfigAction/styles.js +21 -0
  123. package/src/screens/Gateway/components/GatewayItem/__test__/index.test.js +1 -1
  124. package/src/screens/Gateway/components/GatewayItem/styles.js +4 -33
  125. package/src/screens/Gateway/components/Information/__test__/index.test.js +70 -0
  126. package/src/screens/Gateway/components/Information/index.js +116 -0
  127. package/src/screens/Gateway/components/Information/styles.js +59 -0
  128. package/src/screens/Gateway/components/RowItem/__test__/index.test.js +67 -0
  129. package/src/screens/Gateway/components/RowItem/index.js +65 -0
  130. package/src/screens/Gateway/components/RowItem/styles.js +25 -0
  131. package/src/screens/Gateway/components/TabPaneCT/__test__/index.test.js +98 -0
  132. package/src/screens/Gateway/components/TabPaneCT/index.js +134 -0
  133. package/src/screens/Gateway/components/TabPaneCT/styles.js +58 -0
  134. package/src/screens/Gateway/hooks/__test__/index.test.js +93 -0
  135. package/src/screens/Gateway/hooks/useGateway.js +110 -16
  136. package/src/screens/Gateway/index.js +19 -3
  137. package/src/screens/Gateway/styles.js +6 -8
  138. package/src/screens/Gateway/utils/index.js +16 -0
  139. package/src/screens/GuestInfo/__test__/index.test.js +0 -7
  140. package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +0 -7
  141. package/src/screens/HanetCamera/__test__/Detail.test.js +0 -7
  142. package/src/screens/HanetCamera/__test__/ManageAccess.test.js +0 -7
  143. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +0 -7
  144. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +0 -6
  145. package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +0 -7
  146. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +0 -7
  147. package/src/screens/Notification/__test__/Notification.test.js +0 -7
  148. package/src/screens/Notification/__test__/NotificationItem.test.js +1 -0
  149. package/src/screens/Notification/components/NotificationItem.js +16 -1
  150. package/src/screens/Notification/index.js +1 -0
  151. package/src/screens/Notification/styles/indexStyles.js +3 -0
  152. package/src/screens/PlayBackCamera/__test__/index.test.js +0 -1
  153. package/src/screens/ScriptDetail/__test__/index.test.js +0 -7
  154. package/src/screens/SelectUnit/__test__/index.test.js +0 -1
  155. package/src/screens/SetSchedule/__test__/index.test.js +0 -7
  156. package/src/screens/Sharing/Components/__test__/DeviceItem.test.js +0 -7
  157. package/src/screens/Sharing/Components/__test__/ItemChangeRole.test.js +0 -7
  158. package/src/screens/Sharing/Components/__test__/TitleCheckBox.test.js +0 -7
  159. package/src/screens/Sharing/SelectPermission.js +2 -2
  160. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +0 -6
  161. package/src/screens/Sharing/hooks/__test__/index.test.js +80 -0
  162. package/src/screens/SmartAccount/ListDevice/__test__/DeviceItem.test.js +0 -7
  163. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +26 -7
  164. package/src/screens/SmartAccount/SuccessfullyConnected/index.js +29 -11
  165. package/src/screens/SmartIr/__test__/ButtonsBottom.test.js +0 -6
  166. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +1 -6
  167. package/src/screens/SmartIr/__test__/SelectBrand.test.js +1 -6
  168. package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +1 -6
  169. package/src/screens/SubUnit/AddSubUnit.js +1 -0
  170. package/src/screens/SubUnit/ManageSubUnit.js +4 -1
  171. package/src/screens/SubUnit/hooks/__test__/useEmergencyContacts.test.js +34 -0
  172. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +0 -7
  173. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +1 -8
  174. package/src/screens/Template/__test__/GatewayList.test.js +1 -1
  175. package/src/screens/Template/__test__/Information.test.js +1 -1
  176. package/src/screens/Unit/Detail.js +24 -18
  177. package/src/screens/Unit/__test__/AddMenu.test.js +0 -7
  178. package/src/screens/Unit/__test__/CheckSendEmail.test.js +1 -1
  179. package/src/screens/Unit/__test__/ChooseLocation.test.js +0 -7
  180. package/src/screens/Unit/__test__/Detail.test.js +63 -26
  181. package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +0 -7
  182. package/src/screens/Unit/__test__/SelectAddress.test.js +0 -7
  183. package/src/screens/Unit/__test__/SmartAccount.test.js +0 -7
  184. package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -7
  185. package/src/screens/Unit/__test__/Summaries.test.js +0 -7
  186. package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +4 -3
  187. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -2
  188. package/src/utils/Apis/axios.js +52 -36
  189. package/src/utils/I18n/translations/en.json +32 -0
  190. package/src/utils/I18n/translations/vi.json +33 -1
  191. package/src/utils/Route/index.js +8 -0
  192. package/src/utils/Storage.js +0 -4
  193. package/src/utils/Utils.js +1 -1
  194. package/src/utils/__test__/Utils.test.js +27 -3
  195. package/src/screens/AddNewDevice/ConnectingDevices.js +0 -62
  196. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +0 -110
@@ -9,7 +9,6 @@ const mockSetState = jest.fn();
9
9
  jest.mock('react', () => {
10
10
  return {
11
11
  ...jest.requireActual('react'),
12
- memo: (x) => x,
13
12
  useState: jest.fn((init) => [init, mockSetState]),
14
13
  };
15
14
  });
@@ -70,7 +70,10 @@ const MenuActionMore = memo(
70
70
  }`}
71
71
  disabled={isDisable}
72
72
  >
73
- <Text style={[styles.modalHeaderText, item?.textStyle]}>
73
+ <Text
74
+ accessibilityLabel={AccessibilityLabel.TEXT_SUB_UNIT}
75
+ style={[styles.modalHeaderText, item?.textStyle]}
76
+ >
74
77
  {item?.text}
75
78
  </Text>
76
79
  </TouchableOpacity>
@@ -51,7 +51,7 @@ const NavBar = memo(
51
51
  childRef={childRef}
52
52
  onItemClick={onSnapToItem}
53
53
  isTextCenter={false}
54
- accessibilityLabel={AccessibilityLabel.NAVBAR_MENU_ACTION_MORE}
54
+ idLabelPopover={AccessibilityLabel.NAVBAR_MENU_ACTION_MORE}
55
55
  wrapStyle={styles.wrapStyle}
56
56
  idLabelScrollView={idLabelScrollView}
57
57
  idLabelItem={idLabelItem}
@@ -120,7 +120,7 @@ const OptionsDropdownActionTemplate = ({ device, data, onSelectAction }) => {
120
120
  <Text
121
121
  type="H4"
122
122
  bold
123
- color={activeAction >= 0 ? Colors.Primary : Colors.Disabled}
123
+ color={activeAction >= 0 ? Colors.Primary : Colors.TextGray}
124
124
  style={styles.textButton}
125
125
  >
126
126
  {t('done')}
@@ -8,13 +8,6 @@ import { TouchableOpacity } from 'react-native';
8
8
  import Text from '../../Text';
9
9
  import { AccessibilityLabel } from '../../../configs/Constants';
10
10
 
11
- jest.mock('react', () => {
12
- return {
13
- ...jest.requireActual('react'),
14
- memo: (x) => x,
15
- };
16
- });
17
-
18
11
  const mockOnSelectAction = jest.fn();
19
12
 
20
13
  const wrapComponent = (data) => (
@@ -8,13 +8,6 @@ import { RadioCircle } from '../..';
8
8
  import { TouchableOpacity } from 'react-native';
9
9
  import { AccessibilityLabel } from '../../../configs/Constants';
10
10
 
11
- jest.mock('react', () => {
12
- return {
13
- ...jest.requireActual('react'),
14
- memo: (x) => x,
15
- };
16
- });
17
-
18
11
  const mockOnSelectAction = jest.fn();
19
12
 
20
13
  const wrapComponent = (data) => (
@@ -7,13 +7,6 @@ import StatesGridActionTemplate from '../StatesGridActionTemplate';
7
7
  import { TouchableOpacity } from 'react-native';
8
8
  import { AccessibilityLabel } from '../../../configs/Constants';
9
9
 
10
- jest.mock('react', () => {
11
- return {
12
- ...jest.requireActual('react'),
13
- memo: (x) => x,
14
- };
15
- });
16
-
17
10
  const mockOnSelectAction = jest.fn();
18
11
 
19
12
  const wrapComponent = (data) => (
@@ -1,10 +1,8 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
  import { Colors, Constants } from '../../configs';
3
- import { getStatusBarHeight } from 'react-native-iphone-x-helper';
4
3
 
5
4
  export default StyleSheet.create({
6
5
  wrap: {
7
- paddingTop: getStatusBarHeight(true),
8
6
  backgroundColor: Colors.White,
9
7
  width: '100%',
10
8
  height: '100%',
@@ -5,6 +5,7 @@ import { Colors } from '../../configs';
5
5
  import Text from '../Text';
6
6
  import styles from './styles';
7
7
  import { CircleView } from '../CircleView';
8
+ import AccessibilityLabel from '../../configs/AccessibilityLabel';
8
9
 
9
10
  const arrColor = [
10
11
  Colors.GeekBlue3,
@@ -49,7 +50,11 @@ export const RowItem = memo(
49
50
  </View>
50
51
  )}
51
52
  <View style={styles.columeFlex}>
52
- <Text numberOfLines={1} style={styles.titleName}>
53
+ <Text
54
+ numberOfLines={1}
55
+ style={styles.titleName}
56
+ accessibilityLabel={AccessibilityLabel.TEXT_SUB_UNIT}
57
+ >
53
58
  {text}
54
59
  </Text>
55
60
  {!!isShowSubText && (
@@ -67,7 +67,10 @@ const SelectUnit = ({ title, subTitle, onPressNext }) => {
67
67
  })();
68
68
  }, []);
69
69
  return (
70
- <View style={styles.container}>
70
+ <View
71
+ style={styles.container}
72
+ accessibilityLabel={AccessibilityLabel.SELECT_UNIT}
73
+ >
71
74
  <HeaderCustom title={title} isShowSeparator />
72
75
  <Text style={styles.subtitle}>{subTitle}</Text>
73
76
  <View style={styles.contentContainer}>
@@ -5,9 +5,10 @@ import {
5
5
  Animated,
6
6
  View,
7
7
  Platform,
8
+ SafeAreaView,
8
9
  } from 'react-native';
9
10
  import { ActivityIndicator } from '@ant-design/react-native';
10
- import { getStatusBarHeight, isIphoneX } from 'react-native-iphone-x-helper';
11
+ import { isIphoneX } from 'react-native-iphone-x-helper';
11
12
 
12
13
  import { Colors, Theme } from '../../configs';
13
14
  import HeaderAni, { heightHeader } from '../../commons/HeaderAni';
@@ -49,7 +50,8 @@ const WrapHeaderScrollable = ({
49
50
  );
50
51
 
51
52
  return (
52
- <View style={[styles.container, headerAniStyle]}>
53
+ // NOTE: We have problem if don't use SafeAreaView in here. Hinh will remove it later
54
+ <SafeAreaView style={[styles.container, headerAniStyle]}>
53
55
  <HeaderAni
54
56
  scrollY={animatedScrollYValue}
55
57
  contentHeight={contentHeight}
@@ -103,7 +105,7 @@ const WrapHeaderScrollable = ({
103
105
  </View>
104
106
  )}
105
107
  </Animated.ScrollView>
106
- </View>
108
+ </SafeAreaView>
107
109
  );
108
110
  };
109
111
 
@@ -112,7 +114,6 @@ export default memo(WrapHeaderScrollable);
112
114
  const styles = StyleSheet.create({
113
115
  container: {
114
116
  flex: 1,
115
- paddingTop: getStatusBarHeight() + 10,
116
117
  },
117
118
  scrollView: {
118
119
  flex: 1,
@@ -3,7 +3,7 @@ import { Colors } from '../../configs';
3
3
 
4
4
  export default StyleSheet.create({
5
5
  viewStatus: {
6
- width: 65,
6
+ width: 70,
7
7
  paddingHorizontal: 8,
8
8
  paddingVertical: 4,
9
9
  borderRadius: 54,
@@ -13,7 +13,7 @@ export default StyleSheet.create({
13
13
  },
14
14
  textStatus: {
15
15
  fontStyle: 'normal',
16
- fontWeight: 600,
16
+ fontWeight: 'bold',
17
17
  letterSpacing: 0.04,
18
18
  fontSize: 12,
19
19
  lineHeight: 16,
@@ -21,7 +21,12 @@ export default StyleSheet.create({
21
21
  textAlign: 'center',
22
22
  },
23
23
  textOnline: {
24
- fontStyle: 'bold',
24
+ letterSpacing: 0.04,
25
+ fontSize: 12,
26
+ lineHeight: 16,
27
+ fontStyle: 'normal',
28
+ fontWeight: 'bold',
29
+ color: Colors.Green11,
25
30
  },
26
31
  viewOnline: {
27
32
  backgroundColor: Colors.LightGreen,
@@ -13,13 +13,6 @@ const wrapComponent = (props) => (
13
13
  </SCProvider>
14
14
  );
15
15
 
16
- jest.mock('react', () => {
17
- return {
18
- ...jest.requireActual('react'),
19
- memo: (x) => x,
20
- };
21
- });
22
-
23
16
  const mockNavigate = jest.fn();
24
17
  jest.mock('@react-navigation/native', () => {
25
18
  return {
@@ -16,13 +16,6 @@ const wrapComponent = (props) => (
16
16
  </SCProvider>
17
17
  );
18
18
 
19
- jest.mock('react', () => {
20
- return {
21
- ...jest.requireActual('react'),
22
- memo: (x) => x,
23
- };
24
- });
25
-
26
19
  jest.mock('react-native-permissions', () => {
27
20
  return mock;
28
21
  });
@@ -23,13 +23,6 @@ jest.mock('@react-navigation/native', () => {
23
23
  };
24
24
  });
25
25
 
26
- jest.mock('react', () => {
27
- return {
28
- ...jest.requireActual('react'),
29
- memo: (x) => x,
30
- };
31
- });
32
-
33
26
  describe('Test HanetCameraDetail', () => {
34
27
  Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
35
28
  let tree, props;
@@ -14,11 +14,6 @@ jest.mock('@react-navigation/native', () => {
14
14
  };
15
15
  });
16
16
 
17
- jest.mock('react', () => ({
18
- ...jest.requireActual('react'),
19
- memo: (x) => x,
20
- }));
21
-
22
17
  describe('Test HeaderUnit', () => {
23
18
  afterEach(() => {
24
19
  mockedGoBack.mockClear();
@@ -10,13 +10,6 @@ import { SCProvider } from '../../../../context';
10
10
  import API from '../../../../configs/API';
11
11
  import { getPusher } from '../../../../utils/Pusher';
12
12
 
13
- jest.mock('react', () => {
14
- return {
15
- ...jest.requireActual('react'),
16
- memo: (x) => x,
17
- };
18
- });
19
-
20
13
  const mock = new MockAdapter(api.axiosInstance);
21
14
 
22
15
  const wrapComponent = (configs = []) => (
@@ -73,6 +66,7 @@ describe('Test HistoryChart', () => {
73
66
  const configs = [{ id: 1 }];
74
67
  await act(async () => {
75
68
  tree = await create(wrapComponent(configs));
69
+ jest.runAllTimers();
76
70
  });
77
71
  await assertChartData([]);
78
72
  });
@@ -98,6 +92,7 @@ describe('Test HistoryChart', () => {
98
92
  const configs = [{ id: 1 }];
99
93
  await act(async () => {
100
94
  tree = await create(wrapComponent(configs));
95
+ jest.runAllTimers();
101
96
  });
102
97
  await assertChartData([{ x: 1, y: 2 }]);
103
98
  });
@@ -123,6 +118,7 @@ describe('Test HistoryChart', () => {
123
118
  const configs = [{ id: 1 }];
124
119
  await act(async () => {
125
120
  tree = await create(wrapComponent(configs));
121
+ jest.runAllTimers();
126
122
  });
127
123
  await assertChartData([{ x: 1, y: 2 }]);
128
124
  });
@@ -148,6 +144,7 @@ describe('Test HistoryChart', () => {
148
144
  const configs = [{ id: 1 }];
149
145
  await act(async () => {
150
146
  tree = await create(wrapComponent(configs));
147
+ jest.runAllTimers();
151
148
  });
152
149
  await assertChartData([
153
150
  { x: 1, y: 2 },
@@ -178,6 +175,7 @@ describe('Test HistoryChart', () => {
178
175
  const configs = [{ id: 1 }];
179
176
  await act(async () => {
180
177
  tree = await create(wrapComponent(configs));
178
+ jest.runAllTimers();
181
179
  });
182
180
  await assertChartData([
183
181
  { x: 1, y: 2 },
@@ -190,7 +188,6 @@ describe('Test HistoryChart', () => {
190
188
  const cacheUrl = 'https://s3.eoh.io/xxx.json';
191
189
  const response = {
192
190
  data: {
193
- channel: 'cache-xxx',
194
191
  configs: [
195
192
  {
196
193
  id: 1,
@@ -199,6 +196,7 @@ describe('Test HistoryChart', () => {
199
196
  middle: {
200
197
  ready: [],
201
198
  not_ready: [{ date: '2022-03-03', url: cacheUrl }],
199
+ channel: 'cache-xxx',
202
200
  },
203
201
  },
204
202
  ],
@@ -209,6 +207,7 @@ describe('Test HistoryChart', () => {
209
207
  const configs = [{ id: 1 }];
210
208
  await act(async () => {
211
209
  tree = await create(wrapComponent(configs));
210
+ jest.runAllTimers();
212
211
  });
213
212
  await assertChartData([
214
213
  { x: 1, y: 2 },
@@ -235,7 +234,6 @@ describe('Test HistoryChart', () => {
235
234
  const cacheUrl4 = 'https://s3.eoh.io/xxx4.json';
236
235
  const response = {
237
236
  data: {
238
- channel: 'cache-xxx',
239
237
  configs: [
240
238
  {
241
239
  id: 1,
@@ -250,6 +248,7 @@ describe('Test HistoryChart', () => {
250
248
  { date: '2022-03-03', url: cacheUrl2 },
251
249
  { date: '2022-03-05', url: cacheUrl4 },
252
250
  ],
251
+ channel: 'cache-xxx',
253
252
  },
254
253
  },
255
254
  ],
@@ -263,6 +262,7 @@ describe('Test HistoryChart', () => {
263
262
  const configs = [{ id: 1 }];
264
263
  await act(async () => {
265
264
  tree = await create(wrapComponent(configs));
265
+ jest.runAllTimers();
266
266
  });
267
267
  await assertChartData([
268
268
  { x: 1, y: 2 },
@@ -61,46 +61,44 @@ export const updateConfigChart = async (
61
61
  })
62
62
  );
63
63
 
64
- if (data.channel) {
65
- const channel = getPusher().subscribe(data.channel);
66
- // eslint-disable-next-line no-shadow
67
- channel.bind('caching-value-log-process', async ({ success }) => {
68
- await Promise.all(
69
- data.configs.map(async (config) => {
70
- if (config.middle.not_ready.length) {
71
- await Promise.all(
72
- config.middle.not_ready.map(async (item) => {
73
- item.data = await fetchDataS3(item.url);
74
- })
75
- );
76
- }
77
- const middleDataByDay = [
78
- ...config.middle.not_ready,
79
- ...config.middle.ready,
80
- ];
81
-
82
- // sort
83
- middleDataByDay.sort((a, b) => (a.date > b.date ? 1 : -1)); // small to large
84
- const middleData = middleDataByDay.map((x) => x.data).flat();
85
-
86
- data_by_id[config.id] = [
87
- ...config.head,
88
- ...middleData,
89
- ...config.tail,
90
- ];
91
- })
92
- );
64
+ data.configs.map((config) => {
65
+ if (config.middle.not_ready.length > 0) {
66
+ const channel = getPusher().subscribe(config.middle.channel);
67
+ channel.bind('caching-value-log-process', async ({ success }) => {
68
+ await Promise.all(
69
+ config.middle.not_ready.map((item) =>
70
+ (async () => {
71
+ item.data = await fetchDataS3(item.url);
72
+ })()
73
+ )
74
+ );
75
+ const middleDataByDay = [
76
+ ...config.middle.not_ready,
77
+ ...config.middle.ready,
78
+ ];
93
79
 
94
- setChartData(
95
- configuration.map((config) => {
96
- config.data = data_by_id[config.id];
97
- return config;
98
- })
99
- );
100
- });
101
- }
80
+ middleDataByDay.sort((a, b) => (a.date > b.date ? 1 : -1)); // small to large
81
+ const middleData = middleDataByDay.map((x) => x.data).flat();
82
+ data_by_id[config.id] = [...config.head, ...middleData, ...config.tail];
83
+ setChartData((chartData) => {
84
+ const index = chartData.map((c) => c.id).indexOf(config.id);
85
+ chartData[index].data = data_by_id[config.id];
86
+ return [...chartData];
87
+ });
88
+ });
89
+ }
90
+ });
102
91
  };
103
92
 
93
+ const areEqual = ({ configs: oldConfigs }, { configs: newConfigs }) => {
94
+ return (
95
+ JSON.stringify(oldConfigs.map((config) => config.id).sort()) ===
96
+ JSON.stringify(newConfigs.map((config) => config.id).sort())
97
+ );
98
+ };
99
+
100
+ let timeoutId;
101
+
104
102
  const ConfigHistoryChart = memo(({ configs }) => {
105
103
  const [chartData, setChartData] = useState(configs);
106
104
  const [startDate, setStartDate] = useState(
@@ -128,7 +126,11 @@ const ConfigHistoryChart = memo(({ configs }) => {
128
126
  });
129
127
  updateConfigChart(success, data, configuration, setChartData);
130
128
  };
131
- fetchData();
129
+
130
+ timeoutId = setTimeout(fetchData, 200);
131
+ return () => {
132
+ clearTimeout(timeoutId);
133
+ };
132
134
  }, [startDate, endDate, configs]);
133
135
 
134
136
  if (!chartData.length) {
@@ -143,6 +145,6 @@ const ConfigHistoryChart = memo(({ configs }) => {
143
145
  setEndDate={setEndDate}
144
146
  />
145
147
  );
146
- });
148
+ }, areEqual);
147
149
 
148
150
  export default ConfigHistoryChart;
@@ -215,6 +215,34 @@ const API = {
215
215
  LIST: () => '/chip_manager/developer_mode_chips/',
216
216
  DETAIL: (id) => `/chip_manager/developer_mode_chips/${id}/`,
217
217
  },
218
+ ZIGBEE: {
219
+ SEARCH_DEVICE: (id) => `/iot/modules/zigbee/chips/${id}/search_device/`,
220
+ DEVICE_CONFIGURATION: (id, deviceId) =>
221
+ `/iot/modules/zigbee/chips/${id}/sensors/${deviceId}/configuration/`,
222
+ CONFIGURATION: (id) => `/iot/modules/zigbee/chips/${id}/configuration/`,
223
+ DEVICE: (gatewayId) =>
224
+ `/iot/modules/zigbee/gateways/${gatewayId}/devices/`,
225
+ DEVICE_DETAIL: (gatewayId, deviceId) =>
226
+ `/iot/modules/zigbee/gateways/${gatewayId}/devices/${deviceId}/`,
227
+ CONFIG_MAP: (gatewayId, deviceId) =>
228
+ `/iot/modules/zigbee/gateways/${gatewayId}/devices/${deviceId}/config_maps/`,
229
+ ACTION: (gatewayId, deviceId) =>
230
+ `/iot/modules/zigbee/gateways/${gatewayId}/devices/${deviceId}/zigbee_actions/`,
231
+ },
232
+ MODBUS: {
233
+ DEVICE: (gatewayId) =>
234
+ `/iot/modules/modbus/gateways/${gatewayId}/devices/`,
235
+ DEVICE_DETAIL: (gatewayId, deviceId) =>
236
+ `/iot/modules/modbus/gateways/${gatewayId}/devices/${deviceId}/`,
237
+ REGISTER: (gatewayId, deviceId) =>
238
+ `/iot/modules/modbus/gateways/${gatewayId}/devices/${deviceId}/registers/`,
239
+ ACTION: (gatewayId, deviceId) =>
240
+ `/iot/modules/modbus/gateways/${gatewayId}/devices/${deviceId}/actions/`,
241
+ ACTION_DETAIL: (gatewayId, deviceId, actionId) =>
242
+ `/iot/modules/modbus/gateways/${gatewayId}/devices/${deviceId}/actions/${actionId}/`,
243
+ ACTION_ITEM_DETAIL: (actionId, actionItemId) =>
244
+ `/iot/modules/modbus/actions/${actionId}/items/${actionItemId}/`,
245
+ },
218
246
  },
219
247
  };
220
248
 
@@ -262,6 +262,7 @@ export default {
262
262
  ADD_SUB_UNIT_NAME_FIELD: 'ADD_SUB_UNIT_NAME_FIELD',
263
263
  ADD_SUB_UNIT_BUTTON_CHOOSE_PHOTO: 'ADD_SUB_UNIT_BUTTON_CHOOSE_PHOTO',
264
264
  ADD_SUB_UNIT_BUTTON_CHOOSE_LOCATION: 'ADD_SUB_UNIT_BUTTON_CHOOSE_LOCATION',
265
+ TITLE_SUB_UNIT: 'TITLE_SUB_UNIT',
265
266
 
266
267
  SCANNING_RESPONSE_TITLE: 'SCANNING_RESPONSE_TITLE',
267
268
  SCANNING_RESPONSE_DESCRIPTION: 'SCANNING_RESPONSE_DESCRIPTION',
@@ -342,6 +343,7 @@ export default {
342
343
  MANAGE_SUB_UNIT_NAME: 'MANAGE_SUB_UNIT_NAME',
343
344
  MANAGE_SUB_UNIT_REMOVE_BUTTON: 'MANAGE_SUB_UNIT_REMOVE_BUTTON',
344
345
  MANAGE_SUB_UNIT_SELECT_FILE_BUTTON: 'MANAGE_SUB_UNIT_SELECT_FILE_BUTTON',
346
+ MANAGE_SUB_UNIT: 'MANAGE_SUB_UNIT',
345
347
 
346
348
  BUTTON_POPUP_RESOLVED: 'BUTTON_POPUP_RESOLVED',
347
349
  BUTTON_POPUP_RESOLVED_TITLE: 'BUTTON_POPUP_RESOLVED_TITLE',
@@ -415,11 +417,13 @@ export default {
415
417
  SELECT_SUBUNIT_NAME: 'SELECT_SUBUNIT_NAME',
416
418
  SELECT_SUBUNIT_RADIO_BUTTON: 'SELECT_SUBUNIT_RADIO_BUTTON',
417
419
  SELECT_SUBUNIT_SELECT: 'SELECT_SUBUNIT_SELECT',
420
+ TEXT_SUB_UNIT: 'TEXT_SUB_UNIT',
418
421
 
419
422
  // Select unit
420
423
  SELECT_UNIT_NAME: 'SELECT_UNIT_NAME',
421
424
  SELECT_UNIT_RADIO_BUTTON: 'SELECT_UNIT_RADIO_BUTTON',
422
425
  SELECT_UNIT_SELECT: 'SELECT_UNIT_SELECT',
426
+ SELECT_UNIT: 'SELECT_UNIT',
423
427
  SELECT_MEMBER_UNIT: 'SELECT_MEMBER_UNIT',
424
428
 
425
429
  // select wifi
@@ -649,8 +653,17 @@ export default {
649
653
  BUTTON_REMOVE_EDIT_ACTION_LIST: 'BUTTON_REMOVE_EDIT_ACTION_LIST',
650
654
  // GATEWAY
651
655
  LIST_GATEWAY: 'LIST_GATEWAY',
656
+ GATEWAY_INFO_ALERT: 'GATEWAY_INFO_ALERT',
657
+ GATEWAY_INFO_BUTTON_GOTO_CONNECTION_METHODS:
658
+ 'GATEWAY_INFO_BUTTON_GOTO_CONNECTION_METHODS',
659
+ GATEWAY_INFO_BUTTON_DELETE_GATEWAY: 'GATEWAY_INFO_BUTTON_DELETE_GATEWAY',
660
+ MENU_POPPER_MORE: 'MENU_POPPER_MORE',
661
+ GATEWAY_CONNECTION_METHODS_TEXT: 'GATEWAY_CONNECTION_METHODS_TEXT',
652
662
  //Notification
653
663
  CUSTOM_TEXT: 'CUSTOM_TEXT',
654
664
  //ButtonWrapper
655
665
  BUTTON_WRAPPER: 'BUTTON_WRAPPER',
666
+ //devmod
667
+ TAB_PANE_CT_FLATLIST: 'TAB_PANE_CT_FLATLIST',
668
+ ROW_ITEM_DEVMOD: 'ROW_ITEM_DEVMOD',
656
669
  };
@@ -61,6 +61,7 @@ export const Colors = {
61
61
  Gray18: '#9B9A9B',
62
62
  Gray19: '#E5E5E5',
63
63
  Gray20: '#808080',
64
+ Gray21: '#F2F2F2',
64
65
 
65
66
  // Range Green
66
67
  Green1: '#F6FFED',
@@ -70,6 +71,7 @@ export const Colors = {
70
71
  Green8: '#D9F7BE',
71
72
  Green9: '#389E0D',
72
73
  Green10: '#237804',
74
+ Green11: '#008040',
73
75
 
74
76
  //Yellow
75
77
  Yellow6: '#FADB14',
@@ -112,6 +114,8 @@ export const Colors = {
112
114
  Blue11: '#096DD9',
113
115
  Blue12: '#0050B3',
114
116
  Blue13: '#E2F0F8',
117
+ Blue14: '#D9ECFF',
118
+ Blue15: '#99CCFF',
115
119
 
116
120
  //Range Volcano:
117
121
  Volcano3: '#FFBB96',
@@ -84,6 +84,12 @@ export const DEVICE_TYPE = {
84
84
  WIFI_DEVICE: 'WIFI_DEVICE',
85
85
  MODBUS: 'MODBUS',
86
86
  };
87
+ export const PERMISSION_TYPE = {
88
+ ACTION: 'ACTION',
89
+ CONFIG: 'CONFIG',
90
+ CONFIG_WRITE: 'CONFIG_WRITE',
91
+ CONFIG_READ: 'CONFIG_READ',
92
+ };
87
93
 
88
94
  const marginItem = 12;
89
95
  const marginHorizontal = 16;
@@ -248,6 +254,7 @@ export const NOTIFICATION_TYPES = {
248
254
  FIRE: 'FIRE',
249
255
  SOS: 'SOS',
250
256
  FILTER_WATER: 'FILTER_WATER',
257
+ LOW_BATTERY: 'LOW_BATTERY',
251
258
  };
252
259
 
253
260
  export const ACTIVITY_LOG_TYPES = {
@@ -270,6 +277,7 @@ export const PROBLEM_CODE = {
270
277
  UNKNOWN_ERROR: 'UNKNOWN_ERROR',
271
278
  CANCEL_ERROR: 'CANCEL_ERROR',
272
279
  ADDRESS_CHANGING: 'Please wait 30s for changing address.',
280
+ READ_CONFIG_PERMISSION: 'read_config_permission_error',
273
281
  };
274
282
 
275
283
  export const DATE_TIME_FORMAT = {
@@ -24,4 +24,5 @@ export default {
24
24
  removeCircle: require('../Images/DevMode/remove_circle.png'),
25
25
  dienquang: require('../Images/SmartAccount/DienQuang.png'),
26
26
  lg: require('../Images/SmartAccount/LG.png'),
27
+ inforCode: require('../Images/DevMode/inforCode.png'),
27
28
  };
@@ -86,6 +86,7 @@ LocaleConfig.locales.en = {
86
86
  };
87
87
 
88
88
  const SCDefaultConfig = {
89
+ ENV: 'PRODUCTION',
89
90
  apiRoot: 'https://backend.eoh.io/api',
90
91
  GOOGLE_MAP_API_KEY: 'AIzaSyCF1Q-WFXCnfAHhOeXRF9WK7eT-TtxO9ss',
91
92
  LG_CLIENT_ID: '2b85aee334f046848341547894bb7c4e',
@@ -100,6 +101,7 @@ const SCDefaultConfig = {
100
101
 
101
102
  export class SCConfig {
102
103
  static apiRoot = SCDefaultConfig.apiRoot;
104
+ static ENV = SCDefaultConfig.ENV;
103
105
  static GOOGLE_MAP_API_KEY = SCDefaultConfig.GOOGLE_MAP_API_KEY;
104
106
  static LG_CLIENT_ID = SCDefaultConfig.LG_CLIENT_ID;
105
107
  static LG_REDIRECT_URI_APP = SCDefaultConfig.LG_REDIRECT_URI_APP;
@@ -115,6 +117,7 @@ export class SCConfig {
115
117
  export const initSCConfig = (config) => {
116
118
  api.setBaseURL(config.apiRoot ?? SCDefaultConfig.apiRoot);
117
119
  LocaleConfig.defaultLocale = config.language ?? SCConfig.language;
120
+ SCConfig.ENV = config.ENV ?? SCConfig.ENV;
118
121
  SCConfig.language = config.language ?? SCConfig.language;
119
122
  SCConfig.apiRoot = config.apiRoot ?? SCDefaultConfig.apiRoot;
120
123
  SCConfig.GOOGLE_MAP_API_KEY =
@@ -18,6 +18,8 @@ export const Action = {
18
18
  STAR_SCRIPTS: 'STAR_SCRIPTS',
19
19
  UNSTAR_SCRIPTS: 'UNSTAR_SCRIPTS',
20
20
  SET_BLUETOOTH_CONNECTED_DEVICE: 'SET_BLUETOOTH_CONNECTED_DEVICE',
21
+ SET_BLUETOOTH_PERM_REQUESTED: 'SET_BLUETOOTH_PERM_REQUESTED',
22
+ SET_BLUETOOTH_PERM_GRANTED: 'SET_BLUETOOTH_PERM_GRANTED',
21
23
  SET_HOME_ASSISTANT_CONNECTIONS: 'SET_HOME_ASSISTANT_CONNECTIONS',
22
24
  CHANGE_HOME_ASSISTANT_CONN_STATE: 'CHANGE_HOME_ASSISTANT_CONN_STATE',
23
25
  SET_LG_THINQ_CONNECTED: 'SET_LG_THINQ_CONNECTED',
@@ -87,7 +89,6 @@ export type AppType = {
87
89
  isFirstOpenCamera: boolean;
88
90
  isLavidaSource: boolean;
89
91
  isConnectWifiGateway: boolean;
90
- isBluetoothEnabled: boolean;
91
92
  isNetworkConnected: boolean;
92
93
  camera_opened: any[];
93
94
  notificationData: any;
@@ -115,3 +116,9 @@ export type DevModeType = {
115
116
  isEditingTemplate: boolean;
116
117
  isInEditTemplateScreen: boolean;
117
118
  };
119
+
120
+ export type BluetoothType = {
121
+ isEnabled: boolean;
122
+ permissionsGranted: boolean;
123
+ permissionsRequested: boolean;
124
+ };