@eohjsc/react-native-smart-city 0.3.91 → 0.3.93

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 (237) hide show
  1. package/package.json +5 -1
  2. package/src/Images/Common/reorder.svg +3 -0
  3. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/AutoLockStyles.js +1 -1
  4. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +3 -1
  5. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +3 -3
  6. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +3 -10
  7. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +1 -0
  8. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/SetupGeneratePasscodeStyles.js +1 -1
  9. package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +13 -5
  10. package/src/commons/ActionGroup/SliderRangeTemplate.js +100 -69
  11. package/src/commons/ActionGroup/SliderRangeTemplateStyles.js +27 -27
  12. package/src/commons/ActionGroup/StatesGridActionTemplate.js +4 -1
  13. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +4 -1
  14. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +56 -0
  15. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +2 -2
  16. package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +45 -8
  17. package/src/commons/ActionGroup/__test__/index.test.js +0 -19
  18. package/src/commons/ActionGroup/index.js +0 -3
  19. package/src/commons/ActionTemplate/CurtainAction.js +3 -3
  20. package/src/commons/ActionTemplate/CurtainActionStyles.js +1 -1
  21. package/src/commons/ActionTemplate/OnOffButtonAction.js +2 -2
  22. package/src/commons/ActionTemplate/OnOffButtonActionStyles.js +1 -1
  23. package/src/commons/ActionTemplate/OnOffSimpleAction.js +2 -2
  24. package/src/commons/ActionTemplate/OnOffSimpleActionStyles.js +1 -1
  25. package/src/commons/ActionTemplate/OnOffSmartLockAction.js +2 -2
  26. package/src/commons/ActionTemplate/OnOffSmartLockActionStyles.js +1 -1
  27. package/src/commons/ActionTemplate/OneButtonAction.js +1 -1
  28. package/src/commons/ActionTemplate/OneButtonActionStyles.js +1 -1
  29. package/src/commons/ActionTemplate/ThreeButtonAction.js +3 -3
  30. package/src/commons/ActionTemplate/ThreeButtonActionStyles.js +1 -1
  31. package/src/commons/AlertAction/index.js +5 -0
  32. package/src/commons/Auth/AccountList.js +1 -1
  33. package/src/commons/Auth/__test__/OtpInputList.test.js +13 -17
  34. package/src/commons/Automate/ItemAutomate.js +10 -4
  35. package/src/commons/Automate/__test__/ItemAutomate.test.js +11 -11
  36. package/src/commons/BottomButtonView/index.js +22 -4
  37. package/src/commons/Button/index.js +5 -0
  38. package/src/commons/Device/ConnectedViewHeader.js +0 -1
  39. package/src/commons/Device/DeviceAlertStatus.js +2 -1
  40. package/src/commons/Device/Emergency/EmergencyDetail.js +4 -2
  41. package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +4 -2
  42. package/src/commons/Device/ProgressBar/index.js +7 -11
  43. package/src/commons/Device/ProgressBar/styles.js +9 -4
  44. package/src/commons/Device/WindSpeed/Anemometer/index.js +3 -1
  45. package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +14 -1
  46. package/src/commons/Device/WindSpeed/LinearChart/index.js +4 -2
  47. package/src/commons/FlatListDnD/__test__/index.test.js +49 -0
  48. package/src/commons/FlatListDnD/index.js +37 -0
  49. package/src/commons/FlatListDnD/styles.js +12 -0
  50. package/src/commons/Form/__test__/TextInput.test.js +1 -1
  51. package/src/commons/Header/HeaderCustom.js +10 -19
  52. package/src/commons/HorizontalPicker/index.js +65 -38
  53. package/src/commons/IconComponent/index.js +3 -2
  54. package/src/commons/MediaPlayer/__test__/index.test.js +8 -3
  55. package/src/commons/MediaPlayer/index.js +11 -7
  56. package/src/commons/MenuActionMore/index.js +6 -4
  57. package/src/commons/Modal/ModalBottom.js +2 -3
  58. package/src/commons/Modal/ModalCustom.js +2 -3
  59. package/src/commons/NavBar/index.js +48 -50
  60. package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +1 -1
  61. package/src/commons/OneTapTemplate/NumberUpDownActionTemplateStyles.js +1 -1
  62. package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +1 -1
  63. package/src/commons/OneTapTemplate/OptionsDropdownActionTemplateStyles.js +1 -1
  64. package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +1 -1
  65. package/src/commons/OneTapTemplate/StatesGridActionTemplateStyles.js +1 -1
  66. package/src/commons/PreventAccess/index.js +1 -1
  67. package/src/commons/Sharing/StationDevicePermissions.js +4 -4
  68. package/src/commons/Sharing/WrapHeaderScrollable.js +5 -5
  69. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +2 -2
  70. package/src/commons/SubUnit/OneTap/ItemOneTap.js +12 -59
  71. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +16 -20
  72. package/src/commons/SubUnit/OneTap/index.js +20 -7
  73. package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +4 -0
  74. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +1 -1
  75. package/src/commons/ViewButtonBottom/index.js +32 -4
  76. package/src/configs/API.js +9 -0
  77. package/src/configs/AccessibilityLabel.js +2 -0
  78. package/src/configs/BLE.js +1 -0
  79. package/src/configs/Colors.js +1 -1
  80. package/src/configs/Constants.js +12 -18
  81. package/src/context/actionType.ts +2 -1
  82. package/src/context/mockStore.ts +1 -0
  83. package/src/context/reducer.ts +12 -1
  84. package/src/hooks/Common/__test__/useStatusbar.test.js +5 -5
  85. package/src/hooks/Common/index.js +0 -2
  86. package/src/hooks/Common/useKeyboardShow.js +4 -4
  87. package/src/hooks/Common/useStatusBar.js +2 -2
  88. package/src/hooks/Common/useTitleHeader.js +5 -7
  89. package/src/hooks/Explore/useKeyboardAnimated.js +10 -4
  90. package/src/hooks/IoT/__test__/useRemoteControl.test.js +11 -0
  91. package/src/hooks/IoT/useBluetoothConnection.js +20 -29
  92. package/src/hooks/index.js +1 -2
  93. package/src/hooks/useMqtt.js +95 -0
  94. package/src/iot/Monitor.js +2 -1
  95. package/src/iot/RemoteControl/Bluetooth.js +56 -19
  96. package/src/iot/RemoteControl/__test__/Bluetooth.test.js +140 -0
  97. package/src/iot/mqtt.js +233 -0
  98. package/src/navigations/UnitStack.js +44 -12
  99. package/src/screens/AddLocationMaps/index.js +18 -16
  100. package/src/screens/AddLocationMaps/indexStyle.js +3 -0
  101. package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +1 -2
  102. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +5 -17
  103. package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +5 -13
  104. package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +9 -11
  105. package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -14
  106. package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -14
  107. package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +3 -2
  108. package/src/screens/AddNewGateway/index.js +1 -1
  109. package/src/screens/AllCamera/index.js +2 -3
  110. package/src/screens/AllGateway/DetailConfigActionZigbee/__test__/index.test.js +0 -18
  111. package/src/screens/AllGateway/DetailConfigActionZigbee/index.js +1 -1
  112. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +5 -2
  113. package/src/screens/AllGateway/hooks/__test__/index.test.js +1 -1
  114. package/src/screens/{AddNewAction → Automate/AddNewAction}/ChooseAction.js +78 -119
  115. package/src/screens/{AddNewAction → Automate/AddNewAction}/ChooseConfig.js +45 -73
  116. package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/LoadingSelectAction.js +1 -1
  117. package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/SelectDevices.js +3 -3
  118. package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/DeviceStyles.js +5 -1
  119. package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/__test__/index.test.js +3 -3
  120. package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/index.js +5 -4
  121. package/src/screens/{AddNewAction → Automate/AddNewAction}/NewActionWrapper.js +5 -7
  122. package/src/screens/{AddNewAction → Automate/AddNewAction}/SelectControlDevices.js +11 -49
  123. package/src/screens/{AddNewAction → Automate/AddNewAction}/SelectMonitorDevices.js +10 -42
  124. package/src/screens/{AddNewAction → Automate/AddNewAction}/SetupConfigCondition.js +52 -101
  125. package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SelectActionStyles.js +1 -1
  126. package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SelectSensorDevicesStyles.js +1 -1
  127. package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SetupSensorStyles.js +4 -2
  128. package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/ChooseAction.test.js +10 -11
  129. package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/ChooseConfig.test.js +26 -27
  130. package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/SelectControlDevices.test.js +9 -9
  131. package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/SelectMonitorDevices.test.js +5 -5
  132. package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/SetupSensor.test.js +52 -16
  133. package/src/screens/Automate/AddNewAutoSmart/AddAutomationTypeSmart.js +25 -0
  134. package/src/screens/Automate/AddNewAutoSmart/AddTypeSmart.js +78 -0
  135. package/src/screens/Automate/AddNewAutoSmart/AddUnknownTypeSmart.js +29 -0
  136. package/src/screens/{AddNewAutoSmart → Automate/AddNewAutoSmart}/__test__/AddNewAutoSmart.test.js +18 -41
  137. package/src/screens/{AddNewAutoSmart → Automate/AddNewAutoSmart}/styles/AddNewAutoSmartStyles.js +1 -1
  138. package/src/screens/Automate/Components/InputName.js +64 -0
  139. package/src/screens/{AddNewOneTap/AddNewOneTapStyles.js → Automate/Components/InputNameStyles.js} +3 -3
  140. package/src/screens/{EditActionsList → Automate/EditActionsList}/Styles/indexStyles.js +5 -1
  141. package/src/screens/{EditActionsList → Automate/EditActionsList}/__tests__/index.test.js +17 -31
  142. package/src/screens/{EditActionsList → Automate/EditActionsList}/index.js +49 -51
  143. package/src/screens/Automate/MultiUnits.js +69 -67
  144. package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +134 -0
  145. package/src/screens/Automate/OneTap/index.js +16 -0
  146. package/src/screens/Automate/Scenario/ScenarioName.js +15 -0
  147. package/src/screens/{AddNewOneTap → Automate/Scenario}/__test__/AddNewOneTap.test.js +27 -45
  148. package/src/screens/Automate/ScriptDetail/Components/DeleteScript.js +45 -0
  149. package/src/screens/Automate/ScriptDetail/Components/RenameScript.js +58 -0
  150. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/Styles/indexStyles.js +1 -1
  151. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/__test__/index.test.js +110 -74
  152. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/__test__/useStarredScript.test.js +7 -6
  153. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/hooks/useStarredScript.js +4 -4
  154. package/src/screens/Automate/ScriptDetail/index.js +360 -0
  155. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/utils.js +32 -31
  156. package/src/screens/{SetSchedule → Automate/SetSchedule}/__test__/SelectWeekday.test.js +2 -2
  157. package/src/screens/{SetSchedule → Automate/SetSchedule}/__test__/index.test.js +21 -46
  158. package/src/screens/{SetSchedule → Automate/SetSchedule}/components/RepeatOptionsPopup.js +4 -4
  159. package/src/screens/{SetSchedule → Automate/SetSchedule}/components/RowItem.js +2 -2
  160. package/src/screens/{SetSchedule → Automate/SetSchedule}/components/SelectWeekday.js +3 -3
  161. package/src/screens/Automate/SetSchedule/index.js +140 -0
  162. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/RepeatOptionsPopupStyles.js +1 -1
  163. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/RowItemStyles.js +1 -1
  164. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/SelectWeekdayStyles.js +1 -1
  165. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/indexStyles.js +1 -1
  166. package/src/screens/Automate/ValueChange/ValueChangeName.js +16 -0
  167. package/src/screens/Automate/__test__/MultiUnits.test.js +77 -121
  168. package/src/screens/Automate/__test__/index.test.js +3 -10
  169. package/src/screens/Automate/constants.js +0 -0
  170. package/src/screens/Automate/index.js +12 -23
  171. package/src/screens/ChangePosition/__test__/index.test.js +75 -0
  172. package/src/screens/ChangePosition/index.js +112 -0
  173. package/src/screens/ChangePosition/styles.js +87 -0
  174. package/src/screens/Device/__test__/detail.test.js +203 -258
  175. package/src/screens/Device/__test__/mqttDetail.test.js +599 -0
  176. package/src/screens/Device/__test__/sensorDisplayItem.test.js +4 -0
  177. package/src/screens/Device/components/SensorDisplayItem.js +3 -8
  178. package/src/screens/Device/components/VisualChart.js +55 -8
  179. package/src/screens/Device/detail.js +78 -30
  180. package/src/screens/Device/hooks/__test__/useEmergencyButton.test.js +35 -13
  181. package/src/screens/Device/hooks/useDeviceWatchConfigControl.js +13 -3
  182. package/src/screens/Device/hooks/useEvaluateValue.js +20 -2
  183. package/src/screens/Device/styles.js +7 -0
  184. package/src/screens/GuestInfo/components/__test__/AccessScheduleSheet.test.js +52 -0
  185. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +18 -13
  186. package/src/screens/Notification/__test__/Notification.test.js +1 -1
  187. package/src/screens/PlayBackCamera/index.js +2 -3
  188. package/src/screens/SelectUnit/__test__/index.test.js +8 -13
  189. package/src/screens/SharedUnit/index.js +5 -4
  190. package/src/screens/Sharing/SelectUser.js +2 -2
  191. package/src/screens/Sharing/__test__/MemberList.test.js +9 -15
  192. package/src/screens/Sharing/__test__/MemberList2.test.js +10 -16
  193. package/src/screens/Sharing/__test__/SelectUser.test.js +8 -4
  194. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +1 -1
  195. package/src/screens/SmartAccount/__test__/SmartAccount.test.js +8 -4
  196. package/src/screens/SmartAccount/index.js +9 -9
  197. package/src/screens/SmartAccount/style.js +8 -7
  198. package/src/screens/SubUnit/ManageSubUnit.js +4 -4
  199. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +9 -28
  200. package/src/screens/TDSGuide/index.js +1 -1
  201. package/src/screens/Template/GatewayList.js +4 -1
  202. package/src/screens/Template/__test__/detail.test.js +14 -20
  203. package/src/screens/Template/detail.js +1 -0
  204. package/src/screens/UVIndexGuide/index.js +2 -2
  205. package/src/screens/Unit/Detail.js +10 -24
  206. package/src/screens/Unit/SelectAddToFavorites.js +1 -1
  207. package/src/screens/Unit/Summaries.js +6 -17
  208. package/src/screens/Unit/__test__/ChooseLocation.test.js +8 -13
  209. package/src/screens/Unit/__test__/Detail.test.js +3 -1
  210. package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +1 -1
  211. package/src/screens/Unit/__test__/SmartAccount.test.js +8 -14
  212. package/src/screens/Unit/__test__/Summaries.test.js +2 -2
  213. package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +4 -0
  214. package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +6 -11
  215. package/src/screens/WaterQualityGuide/index.js +10 -5
  216. package/src/utils/FactoryGateway.js +525 -0
  217. package/src/utils/I18n/translations/en.json +28 -19
  218. package/src/utils/I18n/translations/vi.json +26 -20
  219. package/src/utils/Route/index.js +5 -1
  220. package/src/utils/Utils.js +40 -0
  221. package/src/utils/__test__/Utils.test.js +6 -0
  222. package/src/commons/ActionGroup/CurtainButtonTemplate.js +0 -130
  223. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +0 -109
  224. package/src/commons/Auth/SocialButton.js +0 -54
  225. package/src/commons/Auth/__test__/SocialButton.test.js +0 -46
  226. package/src/commons/Device/SensorConnectedStatus.js +0 -56
  227. package/src/commons/Device/__test__/SensorConnectedStatus.test.js +0 -29
  228. package/src/commons/Sharing/__test__/StationDevicePermission.test.js +0 -85
  229. package/src/hooks/__test__/useInitDeepLink.test.js +0 -28
  230. package/src/hooks/useInitDeepLink.js +0 -25
  231. package/src/screens/AddNewAutoSmart/index.js +0 -149
  232. package/src/screens/AddNewOneTap/index.js +0 -156
  233. package/src/screens/ScriptDetail/hooks/index.js +0 -136
  234. package/src/screens/ScriptDetail/index.js +0 -446
  235. package/src/screens/SetSchedule/index.js +0 -200
  236. /package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/index.js +0 -0
  237. /package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/LoadingSelectAction.test.js +0 -0
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { View } from 'react-native';
3
3
  import ContentLoader, { Rect } from 'react-content-loader/native';
4
- import { Constants } from '../../../configs';
4
+ import { Constants } from '../../../../configs';
5
5
 
6
6
  const LoadingSelectAction = ({ style }) => (
7
7
  <View style={style}>
@@ -1,10 +1,10 @@
1
1
  import { View } from 'react-native';
2
2
  import styles from '../Styles/SelectSensorDevicesStyles';
3
- import Text from '../../../commons/Text';
4
- import NavBar from '../../../commons/NavBar';
3
+ import Text from '../../../../commons/Text';
4
+ import NavBar from '../../../../commons/NavBar';
5
5
  import Device from '../Device';
6
6
  import React, { useCallback, useState } from 'react';
7
- import { useTranslations } from '../../../hooks/Common/useTranslations';
7
+ import { useTranslations } from '../../../../hooks/Common/useTranslations';
8
8
  import NewActionWrapper from '../NewActionWrapper';
9
9
 
10
10
  const SelectDevices = ({
@@ -1,5 +1,5 @@
1
1
  import { StyleSheet } from 'react-native';
2
- import { Colors, Constants } from '../../../configs';
2
+ import { Colors, Constants } from '../../../../configs';
3
3
 
4
4
  const marginItem = 12;
5
5
  const marginHorizontal = 16;
@@ -40,4 +40,8 @@ export default StyleSheet.create({
40
40
  height: 40,
41
41
  resizeMode: 'contain',
42
42
  },
43
+ antIconStyle: {
44
+ width: 40,
45
+ height: 40,
46
+ },
43
47
  });
@@ -2,9 +2,9 @@ import React from 'react';
2
2
  import renderer, { act } from 'react-test-renderer';
3
3
  import { TouchableWithoutFeedback } from 'react-native';
4
4
 
5
- import Device from '..';
6
- import { SCProvider } from '../../../../context';
7
- import { mockSCStore } from '../../../../context/mockStore';
5
+ import Device from '../index';
6
+ import { SCProvider } from '../../../../../context';
7
+ import { mockSCStore } from '../../../../../context/mockStore';
8
8
 
9
9
  const wrapComponent = (svgMain, sensor, title, isSelectDevice, onPress) => (
10
10
  <SCProvider initState={mockSCStore({})}>
@@ -1,9 +1,9 @@
1
1
  import React, { memo } from 'react';
2
2
  import { TouchableWithoutFeedback, View } from 'react-native';
3
- import { Colors } from '../../../configs';
4
- import Text from '../../../commons/Text';
5
- import IconComponent from '../../../commons/IconComponent';
6
- import { AccessibilityLabel } from '../../../configs/Constants';
3
+ import { Colors } from '../../../../configs';
4
+ import Text from '../../../../commons/Text';
5
+ import IconComponent from '../../../../commons/IconComponent';
6
+ import { AccessibilityLabel } from '../../../../configs/Constants';
7
7
  import styles from './DeviceStyles';
8
8
 
9
9
  const Device = memo(({ svgMain, sensor, title, isSelectDevice, onPress }) => {
@@ -23,6 +23,7 @@ const Device = memo(({ svgMain, sensor, title, isSelectDevice, onPress }) => {
23
23
  <IconComponent
24
24
  icon={sensor?.icon_kit || svgMain}
25
25
  style={styles.iconSensor}
26
+ antIconStyle={styles.antIconStyle}
26
27
  />
27
28
  </View>
28
29
  <Text numberOfLines={1} semibold type="Body" color={Colors.Gray9}>
@@ -2,16 +2,14 @@ import React, { useCallback, useMemo } from 'react';
2
2
  import { TouchableOpacity, View } from 'react-native';
3
3
 
4
4
  import styles from './Styles/SelectActionStyles';
5
- import { useTranslations } from '../../hooks/Common/useTranslations';
6
- import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
5
+ import WrapHeaderScrollable from '../../../commons/Sharing/WrapHeaderScrollable';
7
6
  import { Icon } from '@ant-design/react-native';
8
- import { Colors } from '../../configs';
7
+ import { Colors } from '../../../configs';
9
8
  import { useNavigation, useRoute } from '@react-navigation/native';
10
- import BottomButtonView from '../../commons/BottomButtonView';
11
- import { AccessibilityLabel } from '../../configs/Constants';
9
+ import BottomButtonView from '../../../commons/BottomButtonView';
10
+ import { AccessibilityLabel } from '../../../configs/Constants';
12
11
 
13
12
  const NewActionWrapper = ({ name, children, canNext, onNext, nextTitle }) => {
14
- const t = useTranslations();
15
13
  const { navigate } = useNavigation();
16
14
  const { params = {} } = useRoute();
17
15
  const { closeScreen } = params;
@@ -36,7 +34,7 @@ const NewActionWrapper = ({ name, children, canNext, onNext, nextTitle }) => {
36
34
  return (
37
35
  <View style={styles.wrap}>
38
36
  <WrapHeaderScrollable
39
- title={t('set_up {name}', { name })}
37
+ title={name}
40
38
  headerAniStyle={styles.headerAniStyle}
41
39
  rightComponent={rightComponent}
42
40
  >
@@ -1,25 +1,14 @@
1
1
  import React, { useCallback, useEffect, useState } from 'react';
2
2
  import { useNavigation } from '@react-navigation/native';
3
- import { fetchWithCache } from '../../utils/Apis/axios';
4
- import { API } from '../../configs';
5
- import Routes from '../../utils/Route';
3
+ import { fetchWithCache } from '../../../utils/Apis/axios';
4
+ import { API } from '../../../configs';
5
+ import Routes from '../../../utils/Route';
6
6
  import SelectDevices from './Components/SelectDevices';
7
- import { useTranslations } from '../../hooks/Common/useTranslations';
7
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
8
8
 
9
9
  const SelectControlDevices = ({ route }) => {
10
10
  const t = useTranslations();
11
- const {
12
- unit,
13
- automateId,
14
- automate = {},
15
- type,
16
- scriptName,
17
- isAutomateTab,
18
- isCreateNewAction,
19
- isMultiUnits,
20
- oldType,
21
- closeScreen,
22
- } = route?.params || {};
11
+ const { unitId, closeScreen, automateId } = route?.params || {};
23
12
 
24
13
  const [stations, setStations] = useState([]);
25
14
  const [listStation, setListStation] = useState([]);
@@ -29,7 +18,7 @@ const SelectControlDevices = ({ route }) => {
29
18
  const [loading, setLoading] = useState(true);
30
19
 
31
20
  const fetchDetails = useCallback(async () => {
32
- await fetchWithCache(API.UNIT.DEVICE_CONTROL(unit.id), {}, (response) => {
21
+ await fetchWithCache(API.UNIT.DEVICE_CONTROL(unitId), {}, (response) => {
33
22
  const { success, data } = response;
34
23
  if (success) {
35
24
  const newData = data.filter((item) => item.sensors.length > 0);
@@ -44,48 +33,22 @@ const SelectControlDevices = ({ route }) => {
44
33
  }
45
34
  });
46
35
  setLoading(false);
47
- }, [unit]);
36
+ }, [unitId]);
48
37
 
49
38
  useEffect(() => {
50
39
  fetchDetails();
51
40
  }, [fetchDetails]);
52
41
 
53
42
  const onPressContinue = useCallback(
54
- (selectedDevice, indexStation) => {
43
+ (selectedDevice) => {
55
44
  navigate(Routes.ChooseAction, {
56
- unit,
45
+ unitId,
46
+ automateId,
57
47
  device: selectedDevice,
58
- automateId: automateId,
59
- automate: {
60
- ...automate,
61
- sensor_id: selectedDevice?.id
62
- ? selectedDevice.id
63
- : automate.sensor_id,
64
- },
65
- stationName: stations[indexStation]?.name,
66
- type,
67
- scriptName,
68
- isAutomateTab,
69
- isCreateNewAction,
70
- isMultiUnits,
71
- oldType,
72
48
  closeScreen,
73
49
  });
74
50
  },
75
- [
76
- navigate,
77
- unit,
78
- automateId,
79
- automate,
80
- stations,
81
- type,
82
- scriptName,
83
- isAutomateTab,
84
- isCreateNewAction,
85
- isMultiUnits,
86
- oldType,
87
- closeScreen,
88
- ]
51
+ [navigate, unitId, automateId, closeScreen]
89
52
  );
90
53
 
91
54
  if (loading) {
@@ -95,7 +58,6 @@ const SelectControlDevices = ({ route }) => {
95
58
  return (
96
59
  <SelectDevices
97
60
  onPressContinue={onPressContinue}
98
- automateId={automateId}
99
61
  listStation={listStation}
100
62
  listMenuItem={listMenuItem}
101
63
  stations={stations}
@@ -1,27 +1,16 @@
1
1
  import React, { useCallback, useEffect, useState } from 'react';
2
2
  import { useNavigation } from '@react-navigation/native';
3
3
 
4
- import { useTranslations } from '../../hooks/Common/useTranslations';
5
- import { fetchWithCache } from '../../utils/Apis/axios';
6
- import { API } from '../../configs';
7
- import Routes from '../../utils/Route';
4
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
5
+ import { fetchWithCache } from '../../../utils/Apis/axios';
6
+ import { API } from '../../../configs';
7
+ import Routes from '../../../utils/Route';
8
8
  import SelectDevices from './Components/SelectDevices';
9
- import { AUTOMATE_TYPE } from '../../configs/Constants';
9
+ import { AUTOMATE_TYPE } from '../../../configs/Constants';
10
10
 
11
11
  const SelectMonitorDevices = ({ route }) => {
12
12
  const t = useTranslations();
13
- const {
14
- unit,
15
- automateId,
16
- automate = {},
17
- type,
18
- scriptName,
19
- isAutomateTab,
20
- isCreateNewAction,
21
- isMultiUnits,
22
- oldType,
23
- closeScreen,
24
- } = route?.params || {};
13
+ const { automate = {}, isCreateNewAction, closeScreen } = route?.params || {};
25
14
 
26
15
  const [stations, setStations] = useState([]);
27
16
  const [listStation, setListStation] = useState([]);
@@ -33,11 +22,11 @@ const SelectMonitorDevices = ({ route }) => {
33
22
 
34
23
  const fetchDetails = useCallback(async () => {
35
24
  const configs = { params: {} };
36
- if (type === AUTOMATE_TYPE.EVENT) {
25
+ if (automate?.type === AUTOMATE_TYPE.EVENT) {
37
26
  configs.params.type = 'event';
38
27
  }
39
28
  await fetchWithCache(
40
- API.UNIT.DEVICE_SENSOR(unit.id),
29
+ API.UNIT.DEVICE_SENSOR(automate?.unit),
41
30
  configs,
42
31
  (response) => {
43
32
  const { success, data } = response;
@@ -56,7 +45,7 @@ const SelectMonitorDevices = ({ route }) => {
56
45
  }
57
46
  );
58
47
  setLoading(false);
59
- }, [type, unit.id]);
48
+ }, [automate?.type, automate?.unit]);
60
49
 
61
50
  useEffect(() => {
62
51
  if (!automate?.sensor_id) {
@@ -86,9 +75,7 @@ const SelectMonitorDevices = ({ route }) => {
86
75
  const onPressContinue = useCallback(
87
76
  (selectedDevice, indexStation) => {
88
77
  navigate(Routes.ChooseConfig, {
89
- unit,
90
78
  device: selectedDevice,
91
- automateId: automateId,
92
79
  automate: {
93
80
  ...automate,
94
81
  sensor_id: selectedDevice?.id
@@ -96,29 +83,11 @@ const SelectMonitorDevices = ({ route }) => {
96
83
  : automate.sensor_id,
97
84
  },
98
85
  stationName: stations[indexStation]?.name,
99
- type,
100
- scriptName,
101
- isAutomateTab,
102
86
  isCreateNewAction,
103
- isMultiUnits,
104
- oldType,
105
87
  closeScreen,
106
88
  });
107
89
  },
108
- [
109
- navigate,
110
- unit,
111
- automateId,
112
- automate,
113
- stations,
114
- type,
115
- scriptName,
116
- isAutomateTab,
117
- isCreateNewAction,
118
- isMultiUnits,
119
- oldType,
120
- closeScreen,
121
- ]
90
+ [navigate, automate, stations, isCreateNewAction, closeScreen]
122
91
  );
123
92
 
124
93
  if (loading) {
@@ -128,7 +97,6 @@ const SelectMonitorDevices = ({ route }) => {
128
97
  return (
129
98
  <SelectDevices
130
99
  onPressContinue={onPressContinue}
131
- automateId={automateId}
132
100
  listStation={listStation}
133
101
  listMenuItem={listMenuItem}
134
102
  stations={stations}
@@ -3,35 +3,26 @@ import { Image, TouchableOpacity, View } from 'react-native';
3
3
  import { useNavigation, useRoute } from '@react-navigation/native';
4
4
 
5
5
  import styles from './Styles/SetupSensorStyles';
6
- import { Colors, Images } from '../../configs';
7
- import { useTranslations } from '../../hooks/Common/useTranslations';
8
- import { ModalCustom } from '../../commons/Modal';
9
- import Text from '../../commons/Text';
10
- import { HorizontalPicker } from '../../commons';
11
- import { useStatusBarPreview } from '../../hooks/Common/useStatusBar';
12
- import Routes from '../../utils/Route';
13
- import { getAutomationData } from '../ScriptDetail/utils';
6
+ import { Colors, Images } from '../../../configs';
7
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
8
+ import { ModalCustom } from '../../../commons/Modal';
9
+ import Text from '../../../commons/Text';
10
+ import { setStatusBarPreview } from '../../../hooks/Common/useStatusBar';
11
+ import Routes from '../../../utils/Route';
14
12
  import NewActionWrapper from './NewActionWrapper';
13
+ import _TextInput from '../../../commons/Form/TextInput';
14
+ import { ToastBottomHelper } from '../../../utils/Utils';
15
15
 
16
16
  const SetupConfigCondition = () => {
17
17
  const t = useTranslations();
18
18
 
19
19
  const { navigate } = useNavigation();
20
20
  const { params = {} } = useRoute();
21
- const { item, sensorData, type, automate } = params;
21
+ const { item, defaultCondition = {} } = params;
22
22
 
23
- const hasLimit = useMemo(() => !!item?.range_max, [item]);
24
23
  const [isShowModal, setIsShowModal] = useState(false);
25
- const [itemActiveModal, setItemActiveModal] = useState(null);
26
- const [value, setValue] = useState(null);
27
- const [minimum] = useState(hasLimit ? parseInt(item?.range_min, 10) : 0);
28
- const [maximum, setMaximum] = useState(
29
- value === 0
30
- ? 100
31
- : hasLimit
32
- ? (parseInt(item?.range_max, 10) - minimum) * 10 + minimum
33
- : (parseInt(item?.value, 10) + 20 - minimum) * 10 + minimum
34
- );
24
+ const [itemActiveModal, setItemActiveModal] = useState(defaultCondition);
25
+ const [value, setValue] = useState(defaultCondition?.value || '');
35
26
 
36
27
  const hasNoValueEvaluation = !item?.evaluate_configuration;
37
28
 
@@ -63,35 +54,6 @@ const SetupConfigCondition = () => {
63
54
  return [];
64
55
  }, [item.evaluate_configuration, item.id, t]);
65
56
 
66
- useEffect(() => {
67
- let defaultCondition = null;
68
- if (sensorData) {
69
- const index = sensorData.findIndex((i) => i?.id === item?.id);
70
- if (index !== -1 && sensorData[index].condition) {
71
- defaultCondition = sensorData[index];
72
- }
73
- }
74
-
75
- if (automate && !defaultCondition) {
76
- const automationData = getAutomationData(type, automate);
77
-
78
- const index = conditionOptions.findIndex(
79
- (i) =>
80
- i.condition === automationData?.condition &&
81
- i.value === automationData?.value
82
- );
83
- if (index !== -1) {
84
- defaultCondition = conditionOptions[index];
85
- }
86
- }
87
-
88
- if (!defaultCondition) {
89
- defaultCondition = conditionOptions[0];
90
- }
91
-
92
- setItemActiveModal(defaultCondition);
93
- }, [conditionOptions, item, sensorData, automate, type]);
94
-
95
57
  const onOpenModal = useCallback(() => {
96
58
  setIsShowModal(true);
97
59
  }, []);
@@ -101,67 +63,48 @@ const SetupConfigCondition = () => {
101
63
  }, []);
102
64
 
103
65
  const onChooseCondition = (selectedItem) => () => {
104
- setItemActiveModal(selectedItem);
66
+ setItemActiveModal((prev) => ({ ...prev, ...selectedItem }));
105
67
  onCloseModal();
106
68
  };
107
69
 
108
- const onChangeValue = useCallback(
109
- (newValue) => {
110
- setValue(
111
- (parseFloat(newValue / 128) + parseFloat(minimum)).toFixed(
112
- item?.decimal_behind || 1
113
- )
114
- );
115
- },
116
- // eslint-disable-next-line react-hooks/exhaustive-deps
117
- [value]
118
- );
119
-
120
70
  const onSave = useCallback(() => {
121
- const dataTemp = [...sensorData];
122
- const index = dataTemp.findIndex((i) => i?.id === item?.id);
123
- dataTemp.splice(index, 1, { ...item, ...itemActiveModal });
71
+ const conditionValue = parseFloat(itemActiveModal?.value);
72
+ if (isNaN(conditionValue)) {
73
+ ToastBottomHelper.error(t('value_must_be_a_number'));
74
+ return;
75
+ }
76
+
77
+ if (['<', '>', '='].includes(itemActiveModal?.condition)) {
78
+ if (item.range_min !== null && conditionValue < item.range_min) {
79
+ ToastBottomHelper.error(
80
+ t('value_must_be_greater_than_min', { min: item.range_min })
81
+ );
82
+ return;
83
+ }
84
+ if (item.range_max !== null && conditionValue > item.range_max) {
85
+ ToastBottomHelper.error(
86
+ t('value_must_be_less_than_max', { max: item.range_max })
87
+ );
88
+ return;
89
+ }
90
+ }
91
+
124
92
  navigate({
125
93
  name: Routes.ChooseConfig,
126
94
  merge: true,
127
95
  params: {
128
- newSensorData: dataTemp,
96
+ newCondition: {
97
+ ...itemActiveModal,
98
+ config: item.id,
99
+ },
129
100
  },
130
101
  });
131
- }, [sensorData, item, itemActiveModal, navigate]);
132
-
133
- const renderScroll = useMemo(() => {
134
- return (
135
- <HorizontalPicker
136
- minimum={minimum}
137
- maximum={maximum}
138
- segmentSpacing={8}
139
- segmentWidth={8}
140
- step={10}
141
- normalHeight={4}
142
- normalWidth={4}
143
- stepHeight={12}
144
- stepWidth={12}
145
- stepColor={Colors.Gray6}
146
- normalColor={Colors.Gray6}
147
- onChangeValue={onChangeValue}
148
- value={value - minimum}
149
- />
150
- );
151
- // eslint-disable-next-line react-hooks/exhaustive-deps
152
- }, [minimum, maximum, value]);
102
+ }, [item.id, item.range_max, item.range_min, itemActiveModal, navigate, t]);
153
103
 
154
104
  useEffect(() => {
155
105
  !hasNoValueEvaluation && setValue(1);
156
106
  }, [hasNoValueEvaluation]);
157
107
 
158
- useEffect(() => {
159
- if (!hasLimit && maximum - 150 <= value * 10) {
160
- setMaximum(maximum + 200);
161
- }
162
- // eslint-disable-next-line react-hooks/exhaustive-deps
163
- }, [value]);
164
-
165
108
  useEffect(() => {
166
109
  if (item?.title) {
167
110
  const itemTemp = conditionOptions.find((i) => i.title === item.title);
@@ -171,19 +114,23 @@ const SetupConfigCondition = () => {
171
114
  }, [item]);
172
115
 
173
116
  useEffect(() => {
174
- // eslint-disable-next-line react-hooks/rules-of-hooks
175
- useStatusBarPreview(
117
+ setStatusBarPreview(
176
118
  isShowModal ? Colors.BlackTransparent4 : Colors.TextTransparent
177
119
  );
178
120
  }, [isShowModal]);
179
121
 
122
+ const onChangeValue = useCallback((newValue) => {
123
+ setValue(newValue);
124
+ setItemActiveModal((prev) => ({ ...prev, value: newValue }));
125
+ }, []);
126
+
180
127
  return (
181
128
  <>
182
129
  <NewActionWrapper
183
130
  name={t('set_up {name}', { name: item?.name })}
184
131
  nextTitle={t('save')}
185
132
  onNext={onSave}
186
- canNext={true}
133
+ canNext={itemActiveModal?.condition}
187
134
  >
188
135
  <TouchableOpacity
189
136
  onPress={onOpenModal}
@@ -204,14 +151,18 @@ const SetupConfigCondition = () => {
204
151
  </Text>
205
152
  <View style={[styles.flexRow, styles.center]}>
206
153
  <View>
207
- <Text style={styles.value}>{value}</Text>
208
- <View style={styles.underline} />
154
+ <_TextInput
155
+ textInputStyle={styles.value}
156
+ wrapStyle={styles.wrapValue}
157
+ value={value}
158
+ keyboardType={'numeric'}
159
+ onChange={onChangeValue}
160
+ />
209
161
  </View>
210
162
  <Text type="H2" style={styles.unit}>
211
163
  {item?.unit}
212
164
  </Text>
213
165
  </View>
214
- {renderScroll}
215
166
  </>
216
167
  )}
217
168
  </NewActionWrapper>
@@ -1,6 +1,6 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
  import { getBottomSpace } from 'react-native-iphone-x-helper';
3
- import { Colors, Constants, Theme } from '../../../configs';
3
+ import { Colors, Constants, Theme } from '../../../../configs';
4
4
 
5
5
  export default StyleSheet.create({
6
6
  ...Theme,
@@ -1,6 +1,6 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
  import { getBottomSpace } from 'react-native-iphone-x-helper';
3
- import { Colors, Constants } from '../../../configs';
3
+ import { Colors, Constants } from '../../../../configs';
4
4
 
5
5
  export default StyleSheet.create({
6
6
  wrap: {
@@ -1,5 +1,5 @@
1
1
  import { StyleSheet } from 'react-native';
2
- import { Theme, Colors } from '../../../configs';
2
+ import { Theme, Colors } from '../../../../configs';
3
3
 
4
4
  export default StyleSheet.create({
5
5
  ...Theme,
@@ -46,8 +46,10 @@ export default StyleSheet.create({
46
46
  fontSize: 48,
47
47
  fontWeight: 'bold',
48
48
  textAlign: 'center',
49
- marginLeft: 15,
49
+ borderBottomWidth: 1,
50
+ borderBottomColor: Colors.Black,
50
51
  },
52
+ wrapValue: { marginTop: 0, margin: 0 },
51
53
  unit: {
52
54
  marginTop: -30,
53
55
  },
@@ -3,14 +3,14 @@ import renderer, { act } from 'react-test-renderer';
3
3
  import MockAdapter from 'axios-mock-adapter';
4
4
 
5
5
  import ChooseAction from '../ChooseAction';
6
- import { SCProvider } from '../../../context';
7
- import { mockSCStore } from '../../../context/mockStore';
8
- import BottomButtonView from '../../../commons/BottomButtonView';
9
- import { AccessibilityLabel, DEVICE_TYPE } from '../../../configs/Constants';
10
- import api from '../../../utils/Apis/axios';
11
- import { API } from '../../../configs';
6
+ import { SCProvider } from '../../../../context';
7
+ import { mockSCStore } from '../../../../context/mockStore';
8
+ import BottomButtonView from '../../../../commons/BottomButtonView';
9
+ import { AccessibilityLabel, DEVICE_TYPE } from '../../../../configs/Constants';
10
+ import api from '../../../../utils/Apis/axios';
11
+ import { API } from '../../../../configs';
12
12
  import { TouchableOpacity } from 'react-native';
13
- import SelectActionCard from '../../../commons/SelectActionCard';
13
+ import SelectActionCard from '../../../../commons/SelectActionCard';
14
14
  import { useNavigation } from '@react-navigation/native';
15
15
 
16
16
  const mock = new MockAdapter(api.axiosInstance);
@@ -68,9 +68,9 @@ describe('Test ChooseAction', () => {
68
68
 
69
69
  it('test fetchData', async () => {
70
70
  const response = [
71
- { template: 'on_off_button_action_template' },
72
- { template: 'one_button_action_template' },
73
- { template: 'three_button_action_template' },
71
+ { template: 'on_off_button_action_template', id: 1, configuration: {} },
72
+ { template: 'one_button_action_template', id: 2, configuration: {} },
73
+ { template: 'three_button_action_template', id: 3, configuration: {} },
74
74
  ];
75
75
  mock.onGet(API.DEVICE.DISPLAY_ACTIONS(1)).reply(200, response);
76
76
  await act(async () => {
@@ -291,7 +291,6 @@ describe('Test ChooseAction', () => {
291
291
  data: { config_id: config5, config_value: 1 },
292
292
  },
293
293
  ],
294
- unit: 1,
295
294
  })
296
295
  );
297
296
  });