@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
@@ -30,13 +30,6 @@ jest.mock('@react-navigation/native', () => {
30
30
  };
31
31
  });
32
32
 
33
- jest.mock('react', () => {
34
- return {
35
- ...jest.requireActual('react'),
36
- memo: (x) => x,
37
- };
38
- });
39
-
40
33
  describe('Test SmartAccountItem', () => {
41
34
  let tree;
42
35
  it('test render SmartAccountItem', async () => {
@@ -18,13 +18,6 @@ const wrapComponent = (props) => (
18
18
  </SCProvider>
19
19
  );
20
20
 
21
- jest.mock('react', () => {
22
- return {
23
- ...jest.requireActual('react'),
24
- memo: (x) => x,
25
- };
26
- });
27
-
28
21
  const mockedNavigate = jest.fn();
29
22
  jest.mock('@react-navigation/native', () => {
30
23
  return {
@@ -11,7 +11,7 @@ export const useUnitConnectRemoteDevices = (unit) => {
11
11
  (state) => state.app.isNetworkConnected
12
12
  );
13
13
  const isBluetoothEnabled = useSCContextSelector((state) => {
14
- return state.app.isBluetoothEnabled;
14
+ return state.bluetooth.isEnabled;
15
15
  });
16
16
  const lqthinqUnitConnected = useSCContextSelector(
17
17
  (state) => state.iot.lgthinq.unitConnected
@@ -20,7 +20,8 @@ export const useUnitConnectRemoteDevices = (unit) => {
20
20
 
21
21
  const { connectHomeAssistant } = useHomeAssistantConnection();
22
22
 
23
- const { bluetoothScanDevices } = useBluetoothConnection();
23
+ const { permissionsGranted: bluetoothPermGranted, bluetoothScanDevices } =
24
+ useBluetoothConnection();
24
25
 
25
26
  let lgThinqConnected = false;
26
27
 
@@ -46,7 +47,7 @@ export const useUnitConnectRemoteDevices = (unit) => {
46
47
  bluetoothScanDevices(unit.remote_control_options.bluetooth);
47
48
  }
48
49
  // eslint-disable-next-line react-hooks/exhaustive-deps
49
- }, [unit, isBluetoothEnabled]);
50
+ }, [unit, isBluetoothEnabled, bluetoothPermGranted]);
50
51
 
51
52
  useEffect(() => {
52
53
  if (unit?.remote_control_options?.googlehome && isNetworkConnected) {
@@ -77,7 +77,7 @@ describe('test RunningDevices', () => {
77
77
  });
78
78
  const instance = tree.root;
79
79
  const texts = instance.findAllByType(ItemDevice);
80
- expect(texts.length).toEqual(0);
80
+ expect(texts.length).toEqual(1);
81
81
 
82
82
  const button = instance.findAllByType(TouchableOpacity);
83
83
  await act(async () => {
@@ -116,7 +116,7 @@ describe('test RunningDevices', () => {
116
116
  });
117
117
  const instance = tree.root;
118
118
  const texts = instance.findAllByType(ItemDevice);
119
- expect(texts.length).toEqual(0);
119
+ expect(texts.length).toEqual(1);
120
120
 
121
121
  const button = instance.findAllByType(TouchableOpacity);
122
122
  await act(async () => {
@@ -36,6 +36,29 @@ if (__DEV__ && process.env.NODE_ENV !== 'test') {
36
36
  });
37
37
  }
38
38
 
39
+ const shouldHideError = async (message) => {
40
+ if (
41
+ SCConfig.ENV === 'PRODUCTION' &&
42
+ message.includes(
43
+ getTranslate(SCConfig.language, PROBLEM_CODE.READ_CONFIG_PERMISSION)
44
+ )
45
+ ) {
46
+ return true;
47
+ }
48
+
49
+ if (message.includes(PROBLEM_CODE.ADDRESS_CHANGING)) {
50
+ return true;
51
+ }
52
+
53
+ if (message === 'Network Error') {
54
+ const netState = await NetInfo.fetch();
55
+ if (!netState.isConnected) {
56
+ return true;
57
+ }
58
+ }
59
+ return false;
60
+ };
61
+
39
62
  const parseErrorResponse = async (error) => {
40
63
  let message;
41
64
  let data = {};
@@ -58,18 +81,8 @@ const parseErrorResponse = async (error) => {
58
81
  }
59
82
 
60
83
  if (typeof message === 'string') {
61
- let hideError = false;
84
+ const hideError = await shouldHideError(message);
62
85
 
63
- if (message.includes(PROBLEM_CODE.ADDRESS_CHANGING)) {
64
- hideError = true;
65
- }
66
-
67
- if (message === 'Network Error') {
68
- const netState = await NetInfo.fetch();
69
- if (!netState.isConnected) {
70
- hideError = true;
71
- }
72
- }
73
86
  if (!hideError) {
74
87
  switch (error.problem) {
75
88
  case PROBLEM_CODE.SERVER_ERROR:
@@ -94,6 +107,11 @@ const parseErrorResponse = async (error) => {
94
107
  };
95
108
  };
96
109
 
110
+ const axiosCacheHash = async (URL) => {
111
+ const cacheKey = `@CACHE_REQUEST_HASH_${URL}`;
112
+ return await getData(cacheKey);
113
+ };
114
+
97
115
  export async function axiosCache(URL, resp_status) {
98
116
  const cacheKey = `@CACHE_REQUEST_${URL}`;
99
117
  const cachedData = await getData(cacheKey);
@@ -109,16 +127,24 @@ export async function axiosCache(URL, resp_status) {
109
127
  };
110
128
  }
111
129
 
112
- export async function fetchWithCache(url, config = {}, updateMethod) {
130
+ const updateByCache = async (url, updateMethod) => {
113
131
  const cacheResponse = await axiosCache(url);
114
132
  try {
115
133
  if (cacheResponse) {
116
134
  updateMethod(cacheResponse);
117
135
  }
118
136
  // eslint-disable-next-line no-empty
119
- } catch {}
137
+ } catch (e) {}
138
+ };
139
+
140
+ export async function fetchWithCache(url, config = {}, updateMethod) {
141
+ /*
142
+ @important remember to ask backend to cache this too
143
+ */
144
+ await updateByCache(url, updateMethod); // Bang - purposely call without await
145
+
120
146
  const response = await axiosGet(url, config, true);
121
- if (!response.cache) {
147
+ if (!response.cache && response.resp_status !== 304) {
122
148
  updateMethod(response);
123
149
  }
124
150
  }
@@ -126,25 +152,17 @@ export async function fetchWithCache(url, config = {}, updateMethod) {
126
152
  export async function axiosGet(URL, config = {}, cache = false) {
127
153
  let response;
128
154
  try {
129
- response = await api.get(URL, config.params, config);
130
- } catch (error) {
131
155
  if (cache) {
132
- if (error.message === 'Network Error') {
133
- return (
134
- (await axiosCache(URL, 500)) || (await parseErrorResponse(error))
135
- );
136
- }
137
- if (!error?.response || error?.response?.status >= 500) {
138
- return (
139
- (await axiosCache(URL, error?.response?.status)) ||
140
- (await parseErrorResponse(error))
141
- );
142
- }
156
+ const cacheHash = await axiosCacheHash(URL);
157
+ config.headers = config.headers || {};
158
+ config.headers.CACHE_HASH = cacheHash;
143
159
  }
160
+ response = await api.get(URL, config.params, config);
161
+ } catch (error) {
144
162
  return await parseErrorResponse(error);
145
163
  }
146
164
  const { data, problem } = response;
147
- if (problem) {
165
+ if (['SERVER_ERROR', 'NETWORK_ERROR'].includes(problem)) {
148
166
  if (cache) {
149
167
  return (
150
168
  (await axiosCache(URL, 500)) || (await parseErrorResponse(response))
@@ -155,6 +173,11 @@ export async function axiosGet(URL, config = {}, cache = false) {
155
173
  if (response.status === 200) {
156
174
  if (cache) {
157
175
  await storeData(`@CACHE_REQUEST_${URL}`, JSON.stringify(data));
176
+ response.headers?.CACHE_HASH &&
177
+ (await storeData(
178
+ `@CACHE_REQUEST_HASH_${URL}`,
179
+ response.headers?.CACHE_HASH
180
+ ));
158
181
  }
159
182
  return {
160
183
  success: true,
@@ -187,14 +210,7 @@ async function axiosCall(method, ...args) {
187
210
  data,
188
211
  };
189
212
  }
190
- await parseErrorResponse(response);
191
-
192
- return {
193
- success: false,
194
- resp_status: response.status,
195
- data,
196
- problem,
197
- };
213
+ return await parseErrorResponse(response);
198
214
  }
199
215
 
200
216
  export async function axiosPost(...options) {
@@ -261,6 +261,8 @@
261
261
  "camera_rationale_message": "EoH only uses your camera to take photo",
262
262
  "photo_rationale_title": "Photo Permission Required",
263
263
  "photo_rationale_message": "EoH only uses your photo to upload",
264
+ "bluetooth_rationale_title": "Bluetooth Permission Required",
265
+ "bluetooth_rationale_message": "EoH only uses Bluetooth to scan and control devices",
264
266
  "recommendations": "Recommendations",
265
267
  "Open windows for more fresh air": "Open windows for more fresh air",
266
268
  "notify_new_version_title": "Update available",
@@ -675,6 +677,7 @@
675
677
  "text_notification_content_fire": "There is a fire at **unit_name**, Please move out of the house immediately and call the rescue team.",
676
678
  "text_notification_content_active_sos": "SOS button is activating at **unit_name**, Please check it NOW.",
677
679
  "text_notification_content_replace_water_filter": "Filter **config_name** of **device_name** in **station_name** has less than 10h remaining. Check and replace now.",
680
+ "text_notification_content_low_battery": "Battery of **device_name** in **unit_name**: **station_name** has less than 20%. Check and replace now.",
678
681
  "text_notification_content_remove_unit_to_owner": "Unit **unit_name** has been removed successfully.",
679
682
  "text_notification_content_remove_unit_to_member": "Unit **unit_name** has been removed by **unit_owner_name**. You cannot access to this unit anymore.",
680
683
  "text_notification_content_remove_member": "You were removed from **unit_name** by **unit_owner_name**. You cannot access to this unit anymore.",
@@ -1050,6 +1053,31 @@
1050
1053
  "need_add_gateway_before_add_device": "You need to add a new Gateway before adding the device.",
1051
1054
  "fail_to_discover_device_wifi": "Fail to discover device wifi",
1052
1055
  "try_to_turn_on_device_or_try_again": "Try to turn on device or Try again",
1056
+ "go_to_eoh_web_to_see_firmware": "Go to EoH web to see firmware configuration",
1057
+ "general_information":"General information",
1058
+ "connection_methods": "Connection methods",
1059
+ "delete_gateway":"Delete gateway",
1060
+ "connection_time":"Connection time",
1061
+ "device_id":"Device id",
1062
+ "auth_token":"Auth token",
1063
+ "activate_date":"Activate date",
1064
+ "warranty_expiration_date":"Warranty expiration date",
1065
+ "firmware_version":"Firmware version",
1066
+ "visit_eoh_web_to_set_up_other_connection": "Visit EoH Web to set up other connection options.",
1067
+ "delete_successfully":"Delete successfully!",
1068
+ "message_delete_gateway": "Are you sure you want to delete gateway \"{name}\" ?",
1069
+ "baud_speed": "Baud speed",
1070
+ "zigbee_method": "Zigbee method",
1071
+ "modbus_method": "Modbus method",
1072
+ "delete_device": "Delete device",
1073
+ "device_information": "Device information",
1074
+ "config_name": "Config name",
1075
+ "action_name": "Action name",
1076
+ "control_payload": "Control payload",
1077
+ "key": "Key",
1078
+ "config": "Config",
1079
+ "config_write": "Config write",
1080
+ "config_read": "Config read",
1053
1081
  "click_on_box_to_rename_device": "Click on the box to rename your device",
1054
1082
  "cannot_connect_to_device_wifi": "Cannot connect to device's wifi",
1055
1083
  "try_turn_on_device_or_try_again": "Try turn on device or try again",
@@ -1064,5 +1092,9 @@
1064
1092
  "wrong_wifi_password": "Wrong wifi's password",
1065
1093
  "fail_add_modbus_device": "Fail to add modbus device",
1066
1094
  "fail_add_zigbee_device": "Fail to add zigbee device",
1095
+ "no_zigbee_device_join_timeout": "No zigbee device join network after 2 minutes",
1096
+ "read_config_permission_error": "You don't have permission to read this config",
1097
+ "continue_to_wait": "Continue to wait?",
1098
+ "it_has_been_5_minutes": "It has been 5 minutes...",
1067
1099
  "click_here_to_setup_device": "Click here to setup device"
1068
1100
  }
@@ -296,6 +296,8 @@
296
296
  "camera_rationale_message": "EoH chỉ sử dụng máy ảnh của bạn",
297
297
  "photo_rationale_title": "Yêu cầu cho phép truy cập ảnh",
298
298
  "photo_rationale_message": "EoH chỉ sử dụng thư viện ảnh để upload",
299
+ "bluetooth_rationale_title": "Yêu cầu cho phép sử dụng Bluetooth",
300
+ "bluetooth_rationale_message": "EoH sử dụng Bluetooth để quét và điều khiển thiết bị",
299
301
  "recommendations": "Đề xuất",
300
302
  "Open windows for more fresh air": "Mở cửa sổ để đưa không khí sạch vào nhà",
301
303
  "notify_new_version_title": "Có bản cập nhật!",
@@ -690,6 +692,7 @@
690
692
  "text_notification_content_fire": "Có đám cháy tại **unit_name**, Vui lòng di chuyển ra khỏi nhà ngay lập tức và gọi cho đội cứu hộ.",
691
693
  "text_notification_content_active_sos": "Nút SOS đang kích hoạt tại **unit_name**. Vui lòng kiểm tra nó NGAY BÂY GIỜ.",
692
694
  "text_notification_content_replace_water_filter": "Lõi lọc **config_name** của **device_name** thuộc **unit_name**: **station_name** còn ít hơn 10 giờ lọc. Vui lòng kiểm tra và thay lõi lọc mới.",
695
+ "text_notification_content_low_battery": "Thời lượng pin của **device_name** thuộc **unit_name**: **station_name** còn ít hơn 20%. Vui lòng kiểm tra và thay đổi.",
693
696
  "text_notification_content_remove_unit_to_owner": "Địa điểm **unit_name** vừa được xoá thành công.",
694
697
  "text_notification_content_remove_unit_to_member": "Địa điểm **unit_name** vừa được xoá bởi **unit_owner_name**. Bạn không thể truy cập vào địa điểm này được nữa.",
695
698
  "text_notification_content_remove_member": "Bạn vừa được xoá khỏi **unit_name** bởi **unit_owner_name**. Bạn không thể truy cập vào địa điểm này được nữa.",
@@ -1020,7 +1023,7 @@
1020
1023
  "previous": "Trước",
1021
1024
  "invalid_qr_code": "Mã QR không hợp lệ",
1022
1025
  "invalid_qr_code_warning": "Không thể thêm thiết bị bằng mã QR này",
1023
- "retry": "Thử lại",
1026
+ "retry": "Thử lại",
1024
1027
  "hold_and_hover_description": "Giữ và di chuột để sắp xếp lại mô-đun",
1025
1028
  "dien_quang_smart": "Điện Quang",
1026
1029
  "add_new_smart_account": "Thêm mới tài khoản thông minh",
@@ -1048,6 +1051,31 @@
1048
1051
  "need_add_gateway_before_add_device": "Bạn cần thêm mới 1 Gateway trước khi thêm thiết bị.",
1049
1052
  "fail_to_discover_device_wifi": "Không phát hiện được wifi của thiết bị",
1050
1053
  "try_to_turn_on_device_or_try_again": "Thử bật thiết bị hoặc Thử lại",
1054
+ "go_to_eoh_web_to_see_firmware": "Vào web EoH để xem cấu hình firmware",
1055
+ "general_information":"Thông tin chung",
1056
+ "connection_methods": "Các phương thức kết nối",
1057
+ "delete_gateway":"Xoá cửa ngõ",
1058
+ "connection_time":"Thời gian kết nối",
1059
+ "device_id":"ID thiết bị",
1060
+ "auth_token":"Mã xác thực",
1061
+ "activate_date":"Ngày kích hoạt",
1062
+ "warranty_expiration_date":"Ngày hết hạn bảo hành",
1063
+ "firmware_version":"Phiên bản phần mềm",
1064
+ "visit_eoh_web_to_set_up_other_connection": "Truy cập EoH Web để thiết lập các tùy chọn kết nối khác.",
1065
+ "delete_successfully":"Xoá thành công!",
1066
+ "message_delete_gateway": "Bạn có chắc chắn muốn xóa cổng \"{name}\" không?",
1067
+ "baud_speed": "Tốc độ Baud",
1068
+ "zigbee_method": "Phương thức Zigbee",
1069
+ "modbus_method": "Phương thức Modbus",
1070
+ "delete_device": "Xoá thiết bị",
1071
+ "device_information": "Thông tin thiết bị",
1072
+ "config_name": "Tên cấu hình",
1073
+ "action_name": "Tên hành động",
1074
+ "control_payload": "Điểu khiển khối hàng",
1075
+ "key": "Chìa khoá",
1076
+ "config": "Cấu hình",
1077
+ "config_write": "Cấu hình ghi",
1078
+ "config_read": "Cấu hình đọc",
1051
1079
  "click_on_box_to_rename_device": "Nhấp vào ô để đổi tên thiết bị của bạn",
1052
1080
  "cannot_connect_to_device_wifi": "Không thể kết nối với wifi của thiết bị",
1053
1081
  "try_turn_on_device_or_try_again": "Hãy thử bật thiết bị hoặc thử lại",
@@ -1062,5 +1090,9 @@
1062
1090
  "wrong_wifi_password": "Sai mật khẩu wifi",
1063
1091
  "fail_add_modbus_device": "Không thêm được thiết bị modbus",
1064
1092
  "fail_add_zigbee_device": "Không thêm được thiết bị zigbee",
1093
+ "no_zigbee_device_join_timeout": "Không có thiết bị zigbee nào được thêm vào sau 2 phút",
1094
+ "read_config_permission_error": "Bạn không có quyền đọc cấu hình này",
1095
+ "continue_to_wait": "Bạn có muốn đợi tiếp?",
1096
+ "it_has_been_5_minutes": "Đã 5 phút trôi qua...",
1065
1097
  "click_here_to_setup_device": "Chọn thiết bị thêm vào phòng"
1066
1098
  }
@@ -161,6 +161,14 @@ const Routes = {
161
161
  TemplateDetail: 'TemplateDetail',
162
162
  Gateway: 'Gateway',
163
163
  GatewayDetail: 'GatewayDetail',
164
+ GatewayInfo: 'GatewayInfo',
165
+ DeviceGatewayInfo: 'DeviceGatewayInfo',
166
+ GatewayConnectionMethods: 'GatewayConnectionMethods',
167
+ DeviceZigbeeDetail: 'DeviceZigbeeDetail',
168
+ DeviceModbusDetail: 'DeviceModbusDetail',
169
+ DetailConfigActionZigbee: 'DetailConfigActionZigbee',
170
+ DetailConfigActionModbus: 'DetailConfigActionModbus',
171
+ DetailChildConfigActionModbus: 'DetailChildConfigActionModbus',
164
172
  Smart: 'Smart',
165
173
  TemplateStack: 'TemplateStack',
166
174
  GatewayStack: 'GatewayStack',
@@ -13,7 +13,3 @@ export const storeData = async (key, value) => {
13
13
  export const getData = async (key) => {
14
14
  return await AsyncStorage.getItem(`${key}`);
15
15
  };
16
-
17
- export const deleteData = async (key) => {
18
- return await AsyncStorage.removeItem(key);
19
- };
@@ -108,7 +108,7 @@ export const removeFromString = (str, index) => {
108
108
  return str.substr(0, index) + str.substr(index + 1);
109
109
  };
110
110
 
111
- export const object_Ids = (data) => {
111
+ export const objectIds = (data) => {
112
112
  let stationIds = [];
113
113
  let deviceIds = [];
114
114
  let actionIds = [];
@@ -17,7 +17,7 @@ import {
17
17
  standardizeCameraScreenSize,
18
18
  openMapDirection,
19
19
  ToastBottomHelper,
20
- object_Ids,
20
+ objectIds,
21
21
  notImplemented,
22
22
  } from '../Utils';
23
23
 
@@ -125,8 +125,8 @@ describe('Test utils', () => {
125
125
  });
126
126
  });
127
127
 
128
- it('test object_Ids', async () => {
129
- const data = await object_Ids([{ id: 1, device: [], actions: [] }]);
128
+ it('test objectIds', async () => {
129
+ const data = await objectIds([{ id: 1, device: [], actions: [] }]);
130
130
  expect(data).toEqual({
131
131
  stationIds: [1],
132
132
  deviceIds: [],
@@ -134,6 +134,30 @@ describe('Test utils', () => {
134
134
  configIds: [],
135
135
  });
136
136
  });
137
+ it('test objectIds with devices', async () => {
138
+ const data = await objectIds([
139
+ {
140
+ id: 1,
141
+ devices: [
142
+ {
143
+ id: 2,
144
+ actions: [{ id: 3 }],
145
+ read_configs: [
146
+ {
147
+ id: 4,
148
+ },
149
+ ],
150
+ },
151
+ ],
152
+ },
153
+ ]);
154
+ expect(data).toEqual({
155
+ stationIds: [1],
156
+ deviceIds: [2],
157
+ actionIds: [3],
158
+ configIds: [4],
159
+ });
160
+ });
137
161
 
138
162
  it('test notImplemented', async () => {
139
163
  const mockTranslate = jest.fn();
@@ -1,62 +0,0 @@
1
- import React, { memo, useEffect } from 'react';
2
- import { View, StyleSheet } from 'react-native';
3
- import { getStatusBarHeight } from 'react-native-iphone-x-helper';
4
-
5
- import { API, Colors } from '../../configs';
6
- import { axiosGet } from '../../utils/Apis/axios';
7
- import Text from '../../commons/Text';
8
- import { useTranslations } from '../../hooks/Common/useTranslations';
9
- import { useNavigation } from '@react-navigation/native';
10
- import Routes from '../../utils/Route';
11
-
12
- const ConnectingDevices = memo(({ route }) => {
13
- const t = useTranslations();
14
- const { navigate } = useNavigation();
15
- const { new_sensor } = route?.params || {};
16
-
17
- useEffect(() => {
18
- const checkSensorConnected = setInterval(async () => {
19
- const { success } = await axiosGet(
20
- API.DEVICE.CHECK_CONNECTION(new_sensor?.id),
21
- {},
22
- true
23
- );
24
- if (success) {
25
- navigate(Routes.ConnectDevices, route.params);
26
- }
27
- }, 3000);
28
- return () => clearInterval(checkSensorConnected);
29
- }, [navigate, new_sensor?.id, route.params]);
30
-
31
- return (
32
- <View style={styles.wrap}>
33
- <Text semibold size={20} color={Colors.Black} style={styles.txtHeader}>
34
- {t('connecting_your_device')}
35
- </Text>
36
- <Text size={14} color={Colors.Gray8} style={styles.txtNote}>
37
- {t('dont_turn_off_the_device_or_close_this_app')}
38
- </Text>
39
- </View>
40
- );
41
- });
42
-
43
- export default ConnectingDevices;
44
-
45
- const styles = StyleSheet.create({
46
- wrap: {
47
- flex: 1,
48
- backgroundColor: Colors.Gray2,
49
- paddingTop: getStatusBarHeight(true),
50
- },
51
- txtHeader: {
52
- marginTop: 16,
53
- marginLeft: 16,
54
- marginBottom: 8,
55
- lineHeight: 28,
56
- },
57
- txtNote: {
58
- marginHorizontal: 16,
59
- marginBottom: 8,
60
- lineHeight: 22,
61
- },
62
- });
@@ -1,110 +0,0 @@
1
- import React from 'react';
2
- import { act, create } from 'react-test-renderer';
3
- import MockAdapter from 'axios-mock-adapter';
4
-
5
- import { API } from '../../../configs';
6
- import ConnectingDevices from '../ConnectingDevices';
7
- import Text from '../../../commons/Text';
8
- import Routes from '../../../utils/Route';
9
- import { SCProvider } from '../../../context';
10
- import { mockSCStore } from '../../../context/mockStore';
11
- import { getTranslate } from '../../../utils/I18n';
12
- import api from '../../../utils/Apis/axios';
13
-
14
- const mock = new MockAdapter(api.axiosInstance);
15
-
16
- const mockedNavigate = jest.fn();
17
- jest.mock('@react-navigation/native', () => {
18
- return {
19
- ...jest.requireActual('@react-navigation/native'),
20
- useNavigation: () => ({
21
- navigate: mockedNavigate,
22
- }),
23
- };
24
- });
25
-
26
- const wrapComponent = (route) => (
27
- <SCProvider initState={mockSCStore({})}>
28
- <ConnectingDevices route={route} />
29
- </SCProvider>
30
- );
31
-
32
- describe('Test ConnectingDevices', () => {
33
- let tree;
34
- let route;
35
-
36
- afterEach(() => {
37
- mockedNavigate.mockClear();
38
- });
39
-
40
- beforeEach(() => {
41
- route = {
42
- params: {
43
- new_sensor: {
44
- id: 1,
45
- },
46
- },
47
- };
48
- });
49
-
50
- it('create', async () => {
51
- await act(async () => {
52
- tree = await create(wrapComponent(route));
53
- });
54
- const instance = tree.root;
55
- const texts = instance.findAllByType(Text);
56
- expect(texts).toHaveLength(4);
57
- expect(texts[0].props.children).toEqual(
58
- getTranslate('en', 'connecting_your_device')
59
- );
60
- expect(texts[1].props.children).toEqual(
61
- getTranslate('en', 'dont_turn_off_the_device_or_close_this_app')
62
- );
63
- });
64
-
65
- it('create with out new sensor', async () => {
66
- await act(async () => {
67
- tree = await create(wrapComponent({}));
68
- });
69
- const instance = tree.root;
70
- const texts = instance.findAllByType(Text);
71
- expect(texts).toHaveLength(4);
72
- expect(texts[0].props.children).toEqual(
73
- getTranslate('en', 'connecting_your_device')
74
- );
75
- expect(texts[1].props.children).toEqual(
76
- getTranslate('en', 'dont_turn_off_the_device_or_close_this_app')
77
- );
78
- tree.unmount();
79
- });
80
-
81
- it('call setInterval api success', async () => {
82
- jest.useFakeTimers();
83
- mock.onGet(API.DEVICE.CHECK_CONNECTION(1)).reply(200);
84
- await act(async () => {
85
- tree = await create(wrapComponent(route));
86
- });
87
- await act(async () => {
88
- await jest.runOnlyPendingTimers();
89
- });
90
- expect(setInterval).toHaveBeenCalled();
91
- expect(mockedNavigate).toHaveBeenCalledWith(Routes.ConnectDevices, {
92
- new_sensor: { id: 1 },
93
- });
94
- });
95
-
96
- it('call setInterval api fail', async () => {
97
- jest.useFakeTimers();
98
- mock.onGet(API.DEVICE.CHECK_CONNECTION(1)).reply(400);
99
- await act(async () => {
100
- tree = await create(wrapComponent(route));
101
- });
102
- await act(async () => {
103
- await jest.runOnlyPendingTimers();
104
- });
105
- expect(setInterval).toHaveBeenCalled();
106
- expect(mockedNavigate).toHaveBeenCalledWith(Routes.ConnectDevices, {
107
- new_sensor: { id: 1 },
108
- });
109
- });
110
- });