@eohjsc/react-native-smart-city 0.3.90 → 0.3.92

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 (312) hide show
  1. package/package.json +1 -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__/NumberUpDownTemplate.test.js +1 -1
  14. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +4 -1
  15. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +56 -0
  16. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +2 -2
  17. package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +45 -8
  18. package/src/commons/ActionGroup/__test__/index.test.js +0 -19
  19. package/src/commons/ActionGroup/index.js +0 -3
  20. package/src/commons/ActionTemplate/CurtainAction.js +5 -5
  21. package/src/commons/ActionTemplate/CurtainActionStyles.js +1 -1
  22. package/src/commons/ActionTemplate/OnOffButtonAction.js +4 -4
  23. package/src/commons/ActionTemplate/OnOffButtonActionStyles.js +1 -1
  24. package/src/commons/ActionTemplate/OnOffSimpleAction.js +4 -4
  25. package/src/commons/ActionTemplate/OnOffSimpleActionStyles.js +1 -1
  26. package/src/commons/ActionTemplate/OnOffSmartLockAction.js +4 -4
  27. package/src/commons/ActionTemplate/OnOffSmartLockActionStyles.js +1 -1
  28. package/src/commons/ActionTemplate/OneButtonAction.js +3 -3
  29. package/src/commons/ActionTemplate/OneButtonActionStyles.js +1 -1
  30. package/src/commons/ActionTemplate/ThreeButtonAction.js +5 -5
  31. package/src/commons/ActionTemplate/ThreeButtonActionStyles.js +1 -1
  32. package/src/commons/ActionTemplate/__test__/CurtainAction.test.js +1 -1
  33. package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +1 -1
  34. package/src/commons/ActionTemplate/__test__/OnOffSimpleAction.test.js +1 -1
  35. package/src/commons/ActionTemplate/__test__/OnOffSmartLockAction.test.js +1 -1
  36. package/src/commons/ActionTemplate/__test__/OneButtonAction.test.js +1 -1
  37. package/src/commons/ActionTemplate/__test__/ThreeButtonAction.test.js +1 -1
  38. package/src/commons/ActionTemplate/__test__/index.test.js +21 -70
  39. package/src/commons/ActionTemplate/index.js +19 -55
  40. package/src/commons/Alert/__test__/Alert.test.js +1 -1
  41. package/src/commons/Auth/AccountList.js +1 -1
  42. package/src/commons/Auth/__test__/OtpInputList.test.js +17 -19
  43. package/src/commons/Automate/ItemAutomate.js +10 -4
  44. package/src/commons/Automate/__test__/ItemAutomate.test.js +11 -11
  45. package/src/commons/BackDefault/__test__/BackDefault.test.js +1 -1
  46. package/src/commons/Button/__test__/Button.test.js +1 -1
  47. package/src/commons/ButtonPopup/__test__/ButtonPopup.test.js +1 -1
  48. package/src/commons/Calendar/__test__/Calendar.test.js +1 -1
  49. package/src/commons/ChartLoading/__test__/ChartLoading.test.js +1 -1
  50. package/src/commons/CircleButton/__test__/CircleButton.test.js +1 -1
  51. package/src/commons/CircleView/__test__/CircleView.test.js +1 -1
  52. package/src/commons/DateTimeRangeChange/__test__/DateTimeButton.test.js +4 -2
  53. package/src/commons/DateTimeRangeChange/index.js +31 -48
  54. package/src/commons/Device/DeviceAlertStatus.js +2 -1
  55. package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +2 -2
  56. package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +1 -1
  57. package/src/commons/Device/FlatListItems.js +1 -1
  58. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +2 -2
  59. package/src/commons/Device/HistoryChart.js +6 -49
  60. package/src/commons/Device/LinearChart/LinearChart.test.js +1 -1
  61. package/src/commons/Device/ProgressBar/__test__/ProgressBar.test.js +1 -1
  62. package/src/commons/Device/ProgressBar/index.js +5 -11
  63. package/src/commons/Device/ProgressBar/styles.js +11 -3
  64. package/src/commons/Device/RainningSensor/__test__/CurrentRainSensor.test.js +5 -5
  65. package/src/commons/Device/SonosSpeaker/__test__/SonosSpeaker.test.js +3 -3
  66. package/src/commons/Device/WindDirection/Compass/Compass.test.js +2 -2
  67. package/src/commons/Device/WindSpeed/Anemometer/index.js +2 -0
  68. package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +14 -1
  69. package/src/commons/Device/WindSpeed/LinearChart/index.js +5 -3
  70. package/src/commons/Device/__test__/DeviceAlertStatus.test.js +3 -3
  71. package/src/commons/Device/__test__/DisconnectedView.test.js +2 -2
  72. package/src/commons/Device/__test__/FlatListItems.test.js +1 -1
  73. package/src/commons/Device/__test__/SensorConnectedStatus.test.js +1 -1
  74. package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +1 -1
  75. package/src/commons/FlatListDnD/__test__/index.test.js +49 -0
  76. package/src/commons/FlatListDnD/index.js +37 -0
  77. package/src/commons/FlatListDnD/styles.js +12 -0
  78. package/src/commons/Form/__test__/CurrencyInput.test.js +2 -2
  79. package/src/commons/Form/__test__/TextInput.test.js +3 -3
  80. package/src/commons/Form/__test__/TextInputPassword.test.js +2 -2
  81. package/src/commons/FullLoading/__test__/index.test.js +2 -2
  82. package/src/commons/Header/HeaderCustom.js +2 -1
  83. package/src/commons/HorizontalPicker/index.js +65 -38
  84. package/src/commons/IconComponent/index.js +3 -2
  85. package/src/commons/ImageButton/__test__/ImageButton.test.js +1 -1
  86. package/src/commons/MediaPlayer/__test__/index.test.js +8 -3
  87. package/src/commons/MediaPlayer/index.js +11 -7
  88. package/src/commons/MenuActionMore/index.js +6 -4
  89. package/src/commons/Modal/ModalBottom.js +2 -3
  90. package/src/commons/Modal/ModalCustom.js +2 -3
  91. package/src/commons/NavBar/index.js +48 -50
  92. package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +3 -3
  93. package/src/commons/OneTapTemplate/NumberUpDownActionTemplateStyles.js +1 -1
  94. package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +5 -5
  95. package/src/commons/OneTapTemplate/OptionsDropdownActionTemplateStyles.js +1 -1
  96. package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +5 -5
  97. package/src/commons/OneTapTemplate/StatesGridActionTemplateStyles.js +1 -1
  98. package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +2 -2
  99. package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +1 -1
  100. package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +2 -2
  101. package/src/commons/PreventAccess/index.js +1 -1
  102. package/src/commons/RowItem/__test__/RowItem.test.js +1 -1
  103. package/src/commons/RowUser/__test__/RowUser.test.js +1 -1
  104. package/src/commons/Section/Section.test.js +2 -2
  105. package/src/commons/SelectSubUnit/__test__/SelectSubUnit.test.js +1 -1
  106. package/src/commons/SelectUnit/__test__/SelectUnit.test.js +3 -3
  107. package/src/commons/Sharing/StationDevicePermissions.js +4 -4
  108. package/src/commons/Sharing/WrapHeaderScrollable.js +5 -5
  109. package/src/commons/Sharing/__test__/ButtonRemoveMember.test.js +1 -1
  110. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +3 -3
  111. package/src/commons/Sharing/__test__/MemberList.test.js +6 -4
  112. package/src/commons/Sharing/__test__/RowMember.test.js +2 -2
  113. package/src/commons/Sharing/__test__/WrapHeaderScrollable.test.js +4 -2
  114. package/src/commons/SubUnit/OneTap/ItemOneTap.js +7 -11
  115. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +13 -16
  116. package/src/commons/SubUnit/OneTap/index.js +22 -7
  117. package/src/commons/TextButton/__test__/TextButton.test.js +2 -2
  118. package/src/commons/Today/__test__/Today.test.js +1 -1
  119. package/src/commons/TouchableScale/__test__/TouchableScale.test.js +1 -1
  120. package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +4 -0
  121. package/src/commons/UnitSummary/AirQuality/index.js +2 -2
  122. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +1 -1
  123. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +0 -6
  124. package/src/commons/UnitSummary/__test__/TotalPowerBox.test.js +1 -1
  125. package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +1 -1
  126. package/src/commons/ViewButtonBottom/__test__/ViewButtonBottom.test.js +1 -1
  127. package/src/configs/API.js +14 -31
  128. package/src/configs/AccessibilityLabel.js +1 -0
  129. package/src/configs/Colors.js +1 -1
  130. package/src/configs/Constants.js +14 -48
  131. package/src/context/reducer.ts +3 -1
  132. package/src/hoc/__test__/withRemoteControl.test.js +1 -1
  133. package/src/hooks/Common/__test__/useStatusbar.test.js +5 -5
  134. package/src/hooks/Common/index.js +0 -2
  135. package/src/hooks/Common/useKeyboardShow.js +4 -4
  136. package/src/hooks/Common/useStatusBar.js +2 -2
  137. package/src/hooks/Common/useTitleHeader.js +5 -7
  138. package/src/hooks/IoT/__test__/useRemoteControl.test.js +11 -0
  139. package/src/hooks/IoT/useBluetoothConnection.js +6 -3
  140. package/src/hooks/index.js +1 -2
  141. package/src/navigations/UnitStack.js +51 -17
  142. package/src/screens/ActivityLog/FilterPopup.js +4 -4
  143. package/src/screens/ActivityLog/__test__/FilterPopup.test.js +2 -2
  144. package/src/screens/ActivityLog/__test__/index.test.js +2 -2
  145. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +3 -3
  146. package/src/screens/AddCommon/__test__/SelectUnit.test.js +5 -5
  147. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +9 -33
  148. package/src/screens/AddNewAutoSmart/index.js +33 -89
  149. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectRouterGuide.test.js +1 -1
  150. package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +1 -1
  151. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +1 -1
  152. package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +1 -2
  153. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +5 -17
  154. package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +1 -1
  155. package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +2 -2
  156. package/src/screens/AddNewGateway/__test__/ScanModbusQR.test.js +3 -3
  157. package/src/screens/AddNewGateway/__test__/ScanWifiDeviceQR.test.js +2 -2
  158. package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +8 -16
  159. package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +10 -12
  160. package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -14
  161. package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -14
  162. package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +1 -1
  163. package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +3 -2
  164. package/src/screens/AddNewGateway/index.js +1 -1
  165. package/src/screens/AllCamera/__test__/index.test.js +18 -57
  166. package/src/screens/AllCamera/index.js +100 -33
  167. package/src/screens/AllGateway/DetailConfigActionZigbee/__test__/index.test.js +0 -18
  168. package/src/screens/AllGateway/DetailConfigActionZigbee/index.js +1 -1
  169. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +5 -2
  170. package/src/screens/AllGateway/hooks/__test__/index.test.js +1 -1
  171. package/src/screens/Automate/AddNewAction/ChooseAction.js +139 -0
  172. package/src/screens/Automate/AddNewAction/ChooseConfig.js +179 -0
  173. package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/LoadingSelectAction.js +1 -1
  174. package/src/screens/Automate/AddNewAction/Components/SelectDevices.js +75 -0
  175. package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/DeviceStyles.js +5 -1
  176. package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/__test__/index.test.js +4 -4
  177. package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/index.js +5 -4
  178. package/src/screens/Automate/AddNewAction/NewActionWrapper.js +56 -0
  179. package/src/screens/Automate/AddNewAction/SelectControlDevices.js +69 -0
  180. package/src/screens/Automate/AddNewAction/SelectMonitorDevices.js +110 -0
  181. package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +196 -0
  182. package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SelectActionStyles.js +1 -1
  183. package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SelectSensorDevicesStyles.js +1 -1
  184. package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SetupSensorStyles.js +5 -3
  185. package/src/screens/{AddNewAction/__test__/SelectAction.test.js → Automate/AddNewAction/__test__/ChooseAction.test.js} +101 -122
  186. package/src/screens/Automate/AddNewAction/__test__/ChooseConfig.test.js +210 -0
  187. package/src/screens/Automate/AddNewAction/__test__/SelectControlDevices.test.js +130 -0
  188. package/src/screens/Automate/AddNewAction/__test__/SelectMonitorDevices.test.js +92 -0
  189. package/src/screens/Automate/AddNewAction/__test__/SetupSensor.test.js +131 -0
  190. package/src/screens/Automate/Components/InputName.js +64 -0
  191. package/src/screens/{AddNewOneTap/AddNewOneTapStyles.js → Automate/Components/InputNameStyles.js} +2 -2
  192. package/src/screens/{EditActionsList → Automate/EditActionsList}/Styles/indexStyles.js +5 -1
  193. package/src/screens/{EditActionsList → Automate/EditActionsList}/__tests__/index.test.js +20 -12
  194. package/src/screens/{EditActionsList → Automate/EditActionsList}/index.js +18 -19
  195. package/src/screens/Automate/MultiUnits.js +70 -68
  196. package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +134 -0
  197. package/src/screens/Automate/OneTap/index.js +16 -0
  198. package/src/screens/Automate/Scenario/ScenarioName.js +15 -0
  199. package/src/screens/{AddNewOneTap → Automate/Scenario}/__test__/AddNewOneTap.test.js +27 -45
  200. package/src/screens/Automate/ScriptDetail/Components/DeleteScript.js +45 -0
  201. package/src/screens/Automate/ScriptDetail/Components/RenameScript.js +58 -0
  202. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/Styles/indexStyles.js +1 -1
  203. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/__test__/index.test.js +67 -76
  204. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/__test__/useStarredScript.test.js +7 -6
  205. package/src/screens/{ScriptDetail → Automate/ScriptDetail}/hooks/useStarredScript.js +4 -4
  206. package/src/screens/Automate/ScriptDetail/index.js +346 -0
  207. package/src/screens/Automate/ScriptDetail/utils.js +113 -0
  208. package/src/screens/{SetSchedule → Automate/SetSchedule}/__test__/SelectWeekday.test.js +2 -2
  209. package/src/screens/{SetSchedule → Automate/SetSchedule}/__test__/index.test.js +21 -46
  210. package/src/screens/{SetSchedule → Automate/SetSchedule}/components/RepeatOptionsPopup.js +4 -4
  211. package/src/screens/{SetSchedule → Automate/SetSchedule}/components/RowItem.js +2 -2
  212. package/src/screens/{SetSchedule → Automate/SetSchedule}/components/SelectWeekday.js +3 -3
  213. package/src/screens/Automate/SetSchedule/index.js +140 -0
  214. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/RepeatOptionsPopupStyles.js +1 -1
  215. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/RowItemStyles.js +1 -1
  216. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/SelectWeekdayStyles.js +1 -1
  217. package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/indexStyles.js +1 -1
  218. package/src/screens/Automate/ValueChange/ValueChangeName.js +16 -0
  219. package/src/screens/Automate/__test__/MultiUnits.test.js +78 -122
  220. package/src/screens/Automate/__test__/index.test.js +21 -47
  221. package/src/screens/Automate/constants.js +0 -0
  222. package/src/screens/Automate/index.js +18 -24
  223. package/src/screens/ChangePosition/__test__/index.test.js +75 -0
  224. package/src/screens/ChangePosition/index.js +112 -0
  225. package/src/screens/ChangePosition/styles.js +87 -0
  226. package/src/screens/Device/__test__/DetailHistoryChart.test.js +2 -2
  227. package/src/screens/Device/__test__/EmergencyCountdown.test.js +4 -2
  228. package/src/screens/Device/__test__/detail.test.js +202 -257
  229. package/src/screens/Device/__test__/sensorDisplayItem.test.js +14 -10
  230. package/src/screens/Device/components/ChartWrapper.js +3 -3
  231. package/src/screens/Device/components/SensorDisplayItem.js +2 -1
  232. package/src/screens/Device/components/VisualChart.js +56 -9
  233. package/src/screens/Device/components/__test__/VisualChart.test.js +1 -1
  234. package/src/screens/Device/detail.js +14 -0
  235. package/src/screens/Device/hooks/__test__/useEmergencyButton.test.js +35 -13
  236. package/src/screens/Device/hooks/useEvaluateValue.js +28 -2
  237. package/src/screens/Device/styles.js +7 -0
  238. package/src/screens/DeviceInfo/__test__/index.test.js +16 -18
  239. package/src/screens/DeviceInfo/index.js +6 -5
  240. package/src/screens/GuestInfo/components/__test__/AccessScheduleSheet.test.js +52 -0
  241. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +18 -13
  242. package/src/screens/Notification/__test__/Notification.test.js +64 -73
  243. package/src/screens/Notification/index.js +14 -14
  244. package/src/screens/PlayBackCamera/index.js +2 -3
  245. package/src/screens/SelectUnit/__test__/index.test.js +0 -5
  246. package/src/screens/SelectUnit/index.js +1 -2
  247. package/src/screens/SharedUnit/index.js +5 -4
  248. package/src/screens/Sharing/Components/TitleCheckBox.js +2 -2
  249. package/src/screens/Sharing/SelectUser.js +2 -2
  250. package/src/screens/Sharing/__test__/MemberList.test.js +9 -15
  251. package/src/screens/Sharing/__test__/MemberList2.test.js +10 -16
  252. package/src/screens/Sharing/__test__/SelectUser.test.js +8 -4
  253. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +1 -1
  254. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +3 -3
  255. package/src/screens/SmartAccount/__test__/Connecting.test.js +1 -1
  256. package/src/screens/SmartAccount/__test__/SmartAccount.test.js +3 -3
  257. package/src/screens/SmartAccount/index.js +1 -0
  258. package/src/screens/SmartIr/__test__/ButtonsBottom.test.js +1 -1
  259. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +5 -5
  260. package/src/screens/SmartIr/__test__/SelectBrand.test.js +2 -2
  261. package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +2 -2
  262. package/src/screens/SmartIr/__test__/SmartIr.test.js +2 -2
  263. package/src/screens/SubUnit/ManageSubUnit.js +4 -4
  264. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +9 -28
  265. package/src/screens/TDSGuide/index.js +1 -1
  266. package/src/screens/Template/GatewayList.js +4 -1
  267. package/src/screens/Template/__test__/detail.test.js +24 -22
  268. package/src/screens/Template/detail.js +1 -0
  269. package/src/screens/UVIndexGuide/index.js +2 -2
  270. package/src/screens/Unit/Detail.js +6 -5
  271. package/src/screens/Unit/SelectAddToFavorites.js +1 -1
  272. package/src/screens/Unit/__test__/ChooseLocation.test.js +8 -13
  273. package/src/screens/Unit/__test__/Detail.test.js +10 -14
  274. package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +1 -1
  275. package/src/screens/Unit/__test__/SmartAccount.test.js +8 -14
  276. package/src/screens/Unit/components/__test__/Header.test.js +4 -4
  277. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +1 -1
  278. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +14 -6
  279. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +1 -1
  280. package/src/screens/UnitSummary/components/Temperature/index.js +2 -2
  281. package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +4 -0
  282. package/src/screens/UnitSummary/components/UvIndex/index.js +2 -2
  283. package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +6 -11
  284. package/src/screens/UnitSummary/components/WaterQuality/index.js +2 -2
  285. package/src/screens/UnitSummary/components/__test__/TotalPowerBox.test.js +1 -1
  286. package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +1 -1
  287. package/src/screens/UnitSummary/components/__test__/index.test.js +2 -2
  288. package/src/screens/WaterQualityGuide/index.js +10 -5
  289. package/src/utils/Apis/axios.js +3 -0
  290. package/src/utils/I18n/translations/en.json +24 -18
  291. package/src/utils/I18n/translations/vi.json +22 -18
  292. package/src/utils/Route/index.js +9 -3
  293. package/src/utils/Utils.js +29 -0
  294. package/src/utils/__test__/Utils.test.js +6 -0
  295. package/src/commons/ActionGroup/CurtainButtonTemplate.js +0 -130
  296. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +0 -109
  297. package/src/commons/Auth/SocialButton.js +0 -54
  298. package/src/commons/Auth/__test__/SocialButton.test.js +0 -44
  299. package/src/commons/Sharing/__test__/StationDevicePermission.test.js +0 -85
  300. package/src/hooks/__test__/useInitDeepLink.test.js +0 -28
  301. package/src/hooks/useInitDeepLink.js +0 -25
  302. package/src/screens/AddNewAction/SelectAction.js +0 -570
  303. package/src/screens/AddNewAction/SelectSensorDevices.js +0 -236
  304. package/src/screens/AddNewAction/SetupSensor.js +0 -263
  305. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +0 -181
  306. package/src/screens/AddNewAction/__test__/SetupSensor.test.js +0 -114
  307. package/src/screens/AddNewOneTap/index.js +0 -147
  308. package/src/screens/ScriptDetail/hooks/index.js +0 -136
  309. package/src/screens/ScriptDetail/index.js +0 -525
  310. package/src/screens/SetSchedule/index.js +0 -200
  311. /package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/index.js +0 -0
  312. /package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/LoadingSelectAction.test.js +0 -0
@@ -1,16 +1,15 @@
1
1
  import React, { memo, useContext, useEffect } from 'react';
2
- import { View } from 'react-native';
2
+ import { AppState, View } from 'react-native';
3
3
  import { IconOutline } from '@ant-design/icons-react-native';
4
4
  import { createStackNavigator } from '@react-navigation/stack';
5
5
  import { BleManager } from 'react-native-ble-plx';
6
6
  import NetInfo from '@react-native-community/netinfo';
7
- import { AppState } from 'react-native';
8
7
  import { get } from 'lodash';
9
8
 
10
9
  import Text from '../commons/Text';
11
10
  import { useTranslations } from '../hooks/Common/useTranslations';
12
11
  import { unwatchAllConfigs } from '../iot/Monitor';
13
- import { Colors, Device } from '../configs';
12
+ import { API, Colors, Device } from '../configs';
14
13
  import Route from '../utils/Route';
15
14
  import ActivityLogScreen from '../screens/ActivityLog';
16
15
  import { screenOptions } from './utils';
@@ -19,6 +18,7 @@ import { Action } from '../context/actionType';
19
18
 
20
19
  import AQIGuide from '../screens/AQIGuide';
21
20
  import DeviceDetail from '../screens/Device/detail';
21
+ import ChangePosition from '../screens/ChangePosition';
22
22
  import SharingMemberList from '../screens/Sharing/MemberList';
23
23
  import ManageSubUnit from '../screens/SubUnit/ManageSubUnit';
24
24
  import SelectAddress from '../screens/Unit/SelectAddress';
@@ -32,21 +32,20 @@ import UVIndexGuide from '../screens/UVIndexGuide';
32
32
  import TDSGuide from '../screens/TDSGuide';
33
33
  import WaterQualityGuide from '../screens/WaterQualityGuide';
34
34
  import DeviceInfo from '../screens/DeviceInfo';
35
- import AddNewOneTap from '../screens/AddNewOneTap';
35
+ import AddNewOneTap from '../screens/Automate/OneTap';
36
36
  import AddNewAutoSmart from '../screens/AddNewAutoSmart';
37
37
  import PlaybackCamera from '../screens/PlayBackCamera';
38
38
  import AllCamera from '../screens/AllCamera';
39
39
  import ManageAccessScreen from '../screens/ManageAccess';
40
40
  import MoveToAnotherSubUnit from '../screens/MoveToAnotherSubUnit';
41
41
  import GuestInfo from '../screens/GuestInfo';
42
- import ScriptDetail from '../screens/ScriptDetail';
43
- import EditActionsList from '../screens/EditActionsList';
42
+ import ScriptDetail from '../screens/Automate/ScriptDetail';
43
+ import EditActionsList from '../screens/Automate/EditActionsList';
44
44
  import SelectUnit from '../screens/SelectUnit';
45
- import SetSchedule from '../screens/SetSchedule';
46
- import SelectSensorDevices from '../screens/AddNewAction/SelectSensorDevices';
47
- import SelectAction from '../screens/AddNewAction/SelectAction';
45
+ import SetSchedule from '../screens/Automate/SetSchedule';
46
+ import SelectMonitorDevices from '../screens/Automate/AddNewAction/SelectMonitorDevices';
48
47
  import EditSubUnit from '../screens/SubUnit/EditSubUnit';
49
- import SetUpSensor from '../screens/AddNewAction/SetupSensor';
48
+ import SetupConfigCondition from '../screens/Automate/AddNewAction/SetupConfigCondition';
50
49
  import EditDevice from '../screens/Device/EditDevice/index';
51
50
  import EmergencySetting from '../screens/EmergencySetting';
52
51
  import ConfirmUnitDeletion from '../screens/ConfirmUnitDeletion';
@@ -56,12 +55,16 @@ import AllGateway from '../screens/AllGateway';
56
55
  import SelectAddToFavorites from '../screens/Unit/SelectAddToFavorites';
57
56
  import { HanetCameraStack } from './HanetCameraStack';
58
57
  import { axiosGet, fetchWithCache } from '../utils/Apis/axios';
59
- import { API } from '../configs';
60
58
  import SideMenuDetail from '../screens/SideMenuDetail';
61
59
  import { styles } from './UnitStackStyles';
62
60
  import { useBluetoothConnection } from '../hooks/IoT';
63
61
  import { realScanBluetoothDevices } from '../iot/RemoteControl/Bluetooth';
64
62
  import { ToastBottomHelper } from '../utils/Utils';
63
+ import ChooseConfig from '../screens/Automate/AddNewAction/ChooseConfig';
64
+ import SelectControlDevices from '../screens/Automate/AddNewAction/SelectControlDevices';
65
+ import ChooseAction from '../screens/Automate/AddNewAction/ChooseAction';
66
+ import ScenarioName from '../screens/Automate/Scenario/ScenarioName';
67
+ import ValueChangeName from '../screens/Automate/ValueChange/ValueChangeName';
65
68
 
66
69
  const Stack = createStackNavigator();
67
70
 
@@ -269,6 +272,13 @@ export const UnitStack = memo((props) => {
269
272
  headerShown: false,
270
273
  }}
271
274
  />
275
+ <Stack.Screen
276
+ name={Route.ChangePosition}
277
+ component={ChangePosition}
278
+ options={{
279
+ headerShown: false,
280
+ }}
281
+ />
272
282
  <Stack.Screen
273
283
  name={Route.HanetCameraStack}
274
284
  component={HanetCameraStack}
@@ -395,6 +405,20 @@ export const UnitStack = memo((props) => {
395
405
  headerShown: false,
396
406
  }}
397
407
  />
408
+ <Stack.Screen
409
+ name={Route.ScenarioName}
410
+ component={ScenarioName}
411
+ options={{
412
+ headerShown: false,
413
+ }}
414
+ />
415
+ <Stack.Screen
416
+ name={Route.ValueChangeName}
417
+ component={ValueChangeName}
418
+ options={{
419
+ headerShown: false,
420
+ }}
421
+ />
398
422
  <Stack.Screen
399
423
  name={Route.ScriptDetail}
400
424
  component={ScriptDetail}
@@ -410,8 +434,13 @@ export const UnitStack = memo((props) => {
410
434
  }}
411
435
  />
412
436
  <Stack.Screen
413
- name={Route.SelectSensorDevices}
414
- component={SelectSensorDevices}
437
+ name={Route.SelectMonitorDevices}
438
+ component={SelectMonitorDevices}
439
+ options={{ headerShown: false }}
440
+ />
441
+ <Stack.Screen
442
+ name={Route.SelectControlDevices}
443
+ component={SelectControlDevices}
415
444
  options={{ headerShown: false }}
416
445
  />
417
446
  <Stack.Screen
@@ -420,13 +449,18 @@ export const UnitStack = memo((props) => {
420
449
  options={{ headerShown: false }}
421
450
  />
422
451
  <Stack.Screen
423
- name={Route.SetUpSensor}
424
- component={SetUpSensor}
452
+ name={Route.SetupConfigCondition}
453
+ component={SetupConfigCondition}
454
+ options={{ headerShown: false }}
455
+ />
456
+ <Stack.Screen
457
+ name={Route.ChooseConfig}
458
+ component={ChooseConfig}
425
459
  options={{ headerShown: false }}
426
460
  />
427
461
  <Stack.Screen
428
- name={Route.SelectAction}
429
- component={SelectAction}
462
+ name={Route.ChooseAction}
463
+ component={ChooseAction}
430
464
  options={{ headerShown: false }}
431
465
  />
432
466
  <Stack.Screen
@@ -78,7 +78,7 @@ const FilterPopup = ({
78
78
  [selectedUsers, setSelectedUsers]
79
79
  );
80
80
 
81
- const onPickStartDate = useCallback(() => {
81
+ const selectStart = useCallback(() => {
82
82
  onHide();
83
83
  acquireLockShowing();
84
84
  setStateDatePicker((state) => ({
@@ -88,7 +88,7 @@ const FilterPopup = ({
88
88
  }));
89
89
  }, [onHide, acquireLockShowing]);
90
90
 
91
- const onPickEndDate = useCallback(() => {
91
+ const selectEnd = useCallback(() => {
92
92
  onHide();
93
93
  acquireLockShowing();
94
94
  setStateDatePicker((state) => ({
@@ -208,8 +208,8 @@ const FilterPopup = ({
208
208
  <DateTimeRangeChange
209
209
  startTime={stateDatePicker.startDate}
210
210
  endTime={stateDatePicker.endDate}
211
- onStart={onPickStartDate}
212
- onEnd={onPickEndDate}
211
+ selectStart={selectStart}
212
+ selectEnd={selectEnd}
213
213
  formatType="date"
214
214
  inline={true}
215
215
  />
@@ -133,10 +133,10 @@ it('test date picker pick valid and invalid date', async () => {
133
133
  const _pickDateAndTest = async (timeChange) => {
134
134
  await act(async () => {
135
135
  if (timeChange === 'start') {
136
- await dateTimeRangeChange.props.onStart();
136
+ await dateTimeRangeChange.props.selectStart();
137
137
  await datePicker.props.onConfirm(moment(dateFrom));
138
138
  } else {
139
- await dateTimeRangeChange.props.onEnd();
139
+ await dateTimeRangeChange.props.selectEnd();
140
140
  await datePicker.props.onConfirm(moment(dateTo));
141
141
  }
142
142
  });
@@ -118,7 +118,7 @@ describe('Test Activity log', () => {
118
118
 
119
119
  // pick start date
120
120
  await act(async () => {
121
- await dateTimeRangeChange.props.onStart();
121
+ await dateTimeRangeChange.props.selectStart();
122
122
  await filterPopup[0].props.onModalHide();
123
123
  });
124
124
  expect(filterPopup[0].props.isVisible).toBeFalsy();
@@ -136,7 +136,7 @@ describe('Test Activity log', () => {
136
136
  expect(filterPopup[0].props.isVisible).toBeTruthy();
137
137
  // pick end date
138
138
  await act(async () => {
139
- await dateTimeRangeChange.props.onEnd();
139
+ await dateTimeRangeChange.props.selectEnd();
140
140
  await filterPopup[0].props.onModalHide();
141
141
  });
142
142
  expect(filterPopup[0].props.isVisible).toBeFalsy();
@@ -44,7 +44,7 @@ describe('Test SelectSubUnit', () => {
44
44
  it('test ViewButtonBottom onRightClick', async () => {
45
45
  const route = { params: { addType: 'AddHassiDevice' } };
46
46
  await act(async () => {
47
- tree = renderer.create(wrapComponent(route));
47
+ tree = await renderer.create(wrapComponent(route));
48
48
  });
49
49
  const instance = tree.root;
50
50
  const viewButtonBottom = instance.findByType(ViewButtonBottom);
@@ -72,7 +72,7 @@ describe('Test SelectSubUnit container', () => {
72
72
  test(`create SelectSubUnit ${type} container`, async () => {
73
73
  const route = { params: { addType: type } };
74
74
  await act(async () => {
75
- tree = renderer.create(wrapComponent(route));
75
+ tree = await renderer.create(wrapComponent(route));
76
76
  });
77
77
  const instance = tree.root;
78
78
  const button = instance.findAllByType(TouchableOpacity);
@@ -88,7 +88,7 @@ describe('Test SelectSubUnit container', () => {
88
88
  ]);
89
89
 
90
90
  await act(async () => {
91
- tree = renderer.create(wrapComponent(route));
91
+ tree = await renderer.create(wrapComponent(route));
92
92
  });
93
93
 
94
94
  const instance = tree.root;
@@ -55,7 +55,7 @@ describe('Test SelectUnit container', () => {
55
55
  test(`create SelectUnit ${type} container`, async () => {
56
56
  const route = { params: { addType: type } };
57
57
  await act(async () => {
58
- tree = renderer.create(wrapComponent(route));
58
+ tree = await renderer.create(wrapComponent(route));
59
59
  });
60
60
  const instance = tree.root;
61
61
  const button = instance.findAllByType(TouchableOpacity);
@@ -89,7 +89,7 @@ describe('Test SelectUnit container', () => {
89
89
  };
90
90
  mock.onGet(API.SHARE.UNITS()).reply(200, response.data);
91
91
  await act(async () => {
92
- tree = renderer.create(wrapComponent(route));
92
+ tree = await renderer.create(wrapComponent(route));
93
93
  });
94
94
 
95
95
  const instance = tree.root;
@@ -165,7 +165,7 @@ describe('test single SelectUnit', () => {
165
165
  };
166
166
  mock.onGet(API.SHARE.UNITS()).reply(200, response.data);
167
167
  await act(async () => {
168
- tree = renderer.create(wrapComponent(route));
168
+ tree = await renderer.create(wrapComponent(route));
169
169
  });
170
170
  const instance = tree.root;
171
171
  const unitName = instance.findAll(
@@ -201,7 +201,7 @@ describe('test single SelectUnit', () => {
201
201
  const route = { params: { addType: 'AddSubUnit' } };
202
202
  mock.onGet(500);
203
203
  await act(async () => {
204
- tree = renderer.create(wrapComponent(route));
204
+ tree = await renderer.create(wrapComponent(route));
205
205
  });
206
206
 
207
207
  const instance = tree.root;
@@ -224,7 +224,7 @@ describe('test single SelectUnit', () => {
224
224
  it('click goBack', async () => {
225
225
  const route = { params: { addType: 'AddSubUnit' } };
226
226
  await act(async () => {
227
- tree = renderer.create(wrapComponent(route));
227
+ tree = await renderer.create(wrapComponent(route));
228
228
  });
229
229
 
230
230
  const instance = tree.root;
@@ -3,10 +3,11 @@ import { act, create } from 'react-test-renderer';
3
3
  import AddNewAutoSmart from '..';
4
4
  import { SCProvider } from '../../../context';
5
5
  import { mockSCStore } from '../../../context/mockStore';
6
- import { AUTOMATE_TYPE, AccessibilityLabel } from '../../../configs/Constants';
6
+ import { AccessibilityLabel } from '../../../configs/Constants';
7
7
  import ItemAutomate from '../../../commons/Automate/ItemAutomate';
8
8
  import Routes from '../../../utils/Route';
9
9
  import { TouchableOpacity } from 'react-native';
10
+ import { useNavigation } from '@react-navigation/native';
10
11
 
11
12
  const wrapComponent = (route) => (
12
13
  <SCProvider initState={mockSCStore({})}>
@@ -14,16 +15,6 @@ const wrapComponent = (route) => (
14
15
  </SCProvider>
15
16
  );
16
17
 
17
- const mockNavigate = jest.fn();
18
- jest.mock('@react-navigation/native', () => {
19
- return {
20
- ...jest.requireActual('@react-navigation/native'),
21
- useNavigation: () => ({
22
- navigate: mockNavigate,
23
- }),
24
- };
25
- });
26
-
27
18
  jest.mock('react-redux', () => {
28
19
  return {
29
20
  ...jest.requireActual('react-redux'),
@@ -35,10 +26,10 @@ describe('test AddNewAutoSmart', () => {
35
26
  let tree;
36
27
  let route = {
37
28
  params: {
38
- type: AUTOMATE_TYPE.VALUE_CHANGE,
39
- unit: { id: 1 },
29
+ automate: { unit: 1 },
40
30
  },
41
31
  };
32
+ const mockNavigate = useNavigation().navigate;
42
33
 
43
34
  beforeEach(() => {
44
35
  mockNavigate.mockClear();
@@ -69,17 +60,9 @@ describe('test AddNewAutoSmart', () => {
69
60
  await bottomButton.props.onPress();
70
61
  });
71
62
 
72
- expect(mockNavigate).toBeCalledWith(Routes.SelectSensorDevices, {
73
- automate: {},
74
- automateId: undefined,
75
- title: 'select_sensor',
76
- oldType: 'value_change',
77
- scriptName: undefined,
78
- unit: { id: 1 },
79
- isAutomateTab: undefined,
80
- isMultiUnits: undefined,
81
- routeName: 'SelectSensorDevices',
82
- type: 'value_change',
63
+ expect(mockNavigate).toBeCalledWith(Routes.SelectMonitorDevices, {
64
+ automate: { unit: 1, type: 'value_change' },
65
+ closeScreen: undefined,
83
66
  });
84
67
  });
85
68
 
@@ -104,15 +87,8 @@ describe('test AddNewAutoSmart', () => {
104
87
  await bottomButton.props.onPress();
105
88
  });
106
89
  expect(mockNavigate).toHaveBeenCalledWith(Routes.SetSchedule, {
107
- automate: {},
108
- automateId: undefined,
109
- type: 'schedule',
110
- oldType: 'value_change',
111
- routeName: 'SetSchedule',
112
- scriptName: undefined,
113
- unit: route.params.unit,
114
- isAutomateTab: undefined,
115
- isMultiUnits: undefined,
90
+ automate: { type: 'schedule', unit: 1 },
91
+ closeScreen: undefined,
116
92
  });
117
93
  });
118
94
  });
@@ -1,4 +1,4 @@
1
- import React, { memo, useState, useCallback } from 'react';
1
+ import React, { useState, useCallback } from 'react';
2
2
  import { View } from 'react-native';
3
3
  import { useNavigation } from '@react-navigation/native';
4
4
  import { HeaderCustom } from '../../commons/Header';
@@ -6,38 +6,24 @@ import styles from './styles/AddNewAutoSmartStyles';
6
6
  import Text from '../../commons/Text';
7
7
  import BottomButtonView from '../../commons/BottomButtonView';
8
8
  import ItemAutomate from '../../commons/Automate/ItemAutomate';
9
- import {
10
- AUTOMATE_SELECT,
11
- AUTOMATE_TYPE,
12
- AccessibilityLabel,
13
- } from '../../configs/Constants';
9
+ import { AUTOMATE_TYPE, AccessibilityLabel } from '../../configs/Constants';
14
10
  import { useTranslations } from '../../hooks/Common/useTranslations';
15
11
  import Routes from '../../utils/Route';
16
12
 
17
- const AddNewAutoSmart = memo(({ route }) => {
13
+ const AddNewAutoSmart = ({ route }) => {
18
14
  const t = useTranslations();
19
15
  const { navigate, goBack } = useNavigation();
20
- const {
21
- type,
22
- unit,
23
- isAutomateTab,
24
- isMultiUnits,
25
- automate = {},
26
- scriptName,
27
- } = route?.params || {};
16
+ const { automate = {}, closeScreen } = route?.params || {};
28
17
 
29
18
  const typeAutoSmart = {
30
- [AUTOMATE_TYPE.AUTOMATE]: [
19
+ all: [
31
20
  {
32
21
  type: AUTOMATE_TYPE.ONE_TAP,
33
22
  route: Routes.AddNewOneTap,
34
23
  },
35
24
  {
36
25
  type: AUTOMATE_TYPE.VALUE_CHANGE,
37
- route: Routes.SelectSensorDevices,
38
- data: {
39
- title: AUTOMATE_SELECT.SELECT_SENSOR,
40
- },
26
+ route: Routes.SelectMonitorDevices,
41
27
  },
42
28
  {
43
29
  type: AUTOMATE_TYPE.SCHEDULE,
@@ -45,20 +31,13 @@ const AddNewAutoSmart = memo(({ route }) => {
45
31
  },
46
32
  {
47
33
  type: AUTOMATE_TYPE.EVENT,
48
- route: Routes.SelectSensorDevices,
49
- data: {
50
- title: AUTOMATE_SELECT.SELECT_DEVICE,
51
- isSetupEvent: true,
52
- },
34
+ route: Routes.SelectMonitorDevices,
53
35
  },
54
36
  ],
55
- [AUTOMATE_TYPE.VALUE_CHANGE]: [
37
+ change: [
56
38
  {
57
39
  type: AUTOMATE_TYPE.VALUE_CHANGE,
58
- route: Routes.SelectSensorDevices,
59
- data: {
60
- title: AUTOMATE_SELECT.SELECT_SENSOR,
61
- },
40
+ route: Routes.SelectMonitorDevices,
62
41
  },
63
42
  {
64
43
  type: AUTOMATE_TYPE.SCHEDULE,
@@ -66,72 +45,38 @@ const AddNewAutoSmart = memo(({ route }) => {
66
45
  },
67
46
  {
68
47
  type: AUTOMATE_TYPE.EVENT,
69
- route: Routes.SelectSensorDevices,
70
- data: {
71
- title: AUTOMATE_SELECT.SELECT_DEVICE,
72
- isSetupEvent: true,
73
- },
74
- },
75
- ],
76
- [AUTOMATE_TYPE.ONE_TAP_ONLY]: [
77
- {
78
- type: AUTOMATE_TYPE.ONE_TAP,
79
- route: Routes.AddNewOneTap,
48
+ route: Routes.SelectMonitorDevices,
80
49
  },
81
50
  ],
82
51
  };
83
52
 
84
- const [data] = useState(
85
- automate?.id ? typeAutoSmart[AUTOMATE_TYPE.AUTOMATE] : typeAutoSmart[type]
86
- );
53
+ const data = automate?.id ? typeAutoSmart.all : typeAutoSmart.change;
87
54
 
88
55
  const [selectedIndex, setSelectedIndex] = useState(
89
- automate?.id ? data.findIndex((obj) => obj.type === type) : -1
56
+ automate?.id ? data.findIndex((obj) => obj.type === automate.type) : -1
90
57
  );
91
58
 
92
59
  const handleOnContinue = useCallback(() => {
93
60
  const dataAutomate = data[selectedIndex];
94
61
  const params = {
95
- type: dataAutomate?.type,
96
- unit: unit,
97
- ...(dataAutomate?.data || {}),
98
- isAutomateTab,
99
- isMultiUnits,
100
- automateId: automate?.id,
101
- routeName: dataAutomate?.route,
102
- automate,
103
- scriptName,
104
- oldType: type,
62
+ automate: {
63
+ ...automate,
64
+ type: dataAutomate?.type,
65
+ },
66
+ closeScreen: closeScreen,
105
67
  };
106
68
 
107
- if (
108
- (dataAutomate.type === AUTOMATE_TYPE.VALUE_CHANGE && isMultiUnits) ||
109
- (dataAutomate.type === AUTOMATE_TYPE.EVENT && isMultiUnits)
110
- ) {
69
+ if (!automate?.unit) {
111
70
  navigate(Routes.SelectUnit, params);
112
- } else {
113
- navigate(dataAutomate.route, params);
71
+ return;
114
72
  }
115
- }, [
116
- data,
117
- selectedIndex,
118
- unit,
119
- isAutomateTab,
120
- isMultiUnits,
121
- automate,
122
- scriptName,
123
- type,
124
- navigate,
125
- ]);
126
73
 
127
- const onClose = useCallback(() => {
128
- goBack();
129
- // eslint-disable-next-line react-hooks/exhaustive-deps
130
- }, []);
74
+ navigate(dataAutomate.route, params);
75
+ }, [data, selectedIndex, automate, closeScreen, navigate]);
131
76
 
132
77
  return (
133
78
  <View style={styles.wrap}>
134
- <HeaderCustom isShowClose onClose={onClose} />
79
+ <HeaderCustom isShowClose onClose={goBack} />
135
80
  <View style={styles.container}>
136
81
  <Text semibold type={'H2'} style={styles.titleCreate}>
137
82
  {automate?.id ? t('update_smart') : t('create_smart')}
@@ -140,17 +85,16 @@ const AddNewAutoSmart = memo(({ route }) => {
140
85
  {t('choose_the_automation_method_you_want')}
141
86
  </Text>
142
87
  <View>
143
- {!!data &&
144
- data.map((item, index) => (
145
- <ItemAutomate
146
- type={item.type}
147
- isSelected={selectedIndex === index}
148
- key={item?.id?.toString()}
149
- index={index}
150
- selectedIndex={selectedIndex}
151
- setSelectedIndex={setSelectedIndex}
152
- />
153
- ))}
88
+ {data.map((item, index) => (
89
+ <ItemAutomate
90
+ automate={item}
91
+ isSelected={selectedIndex === index}
92
+ key={item?.type?.toString()}
93
+ index={index}
94
+ selectedIndex={selectedIndex}
95
+ setSelectedIndex={setSelectedIndex}
96
+ />
97
+ ))}
154
98
  </View>
155
99
  </View>
156
100
  <BottomButtonView
@@ -164,6 +108,6 @@ const AddNewAutoSmart = memo(({ route }) => {
164
108
  />
165
109
  </View>
166
110
  );
167
- });
111
+ };
168
112
 
169
113
  export default AddNewAutoSmart;
@@ -51,7 +51,7 @@ describe('Test ConnectRouterGuide', () => {
51
51
 
52
52
  const rightClick = async (params) => {
53
53
  await act(async () => {
54
- tree = renderer.create(wrapComponent({ params }));
54
+ tree = await renderer.create(wrapComponent({ params }));
55
55
  });
56
56
  const instance = tree.root;
57
57
  const viewButtonBottom = instance.findByType(ViewButtonBottom);
@@ -51,7 +51,7 @@ describe('Test FirstWarning', () => {
51
51
 
52
52
  const rightClick = async (params) => {
53
53
  await act(async () => {
54
- tree = renderer.create(wrapComponent({ params }));
54
+ tree = await renderer.create(wrapComponent({ params }));
55
55
  });
56
56
  const instance = tree.root;
57
57
  const viewButtonBottom = instance.findByType(ViewButtonBottom);
@@ -51,7 +51,7 @@ describe('Test ZigbeeDeviceConnectGuide', () => {
51
51
 
52
52
  const rightClick = async (params) => {
53
53
  await act(async () => {
54
- tree = renderer.create(wrapComponent({ params }));
54
+ tree = await renderer.create(wrapComponent({ params }));
55
55
  });
56
56
  const instance = tree.root;
57
57
  const viewButtonBottom = instance.findByType(ViewButtonBottom);
@@ -1,6 +1,5 @@
1
- import React from 'react';
1
+ import React, { useCallback } from 'react';
2
2
  import SelectSubUnit from '../../commons/SelectSubUnit';
3
- import { useCallback } from 'react';
4
3
  import { useTranslations } from '../../hooks/Common/useTranslations';
5
4
  import { useNavigation } from '@react-navigation/native';
6
5
  import Routes from '../../utils/Route';
@@ -11,6 +11,7 @@ import { getTranslate } from '../../../utils/I18n';
11
11
  import { SCProvider } from '../../../context';
12
12
  import { mockSCStore } from '../../../context/mockStore';
13
13
  import api from '../../../utils/Apis/axios';
14
+ import { useNavigation } from '@react-navigation/native';
14
15
 
15
16
  const wrapComponent = (route) => (
16
17
  <SCProvider initState={mockSCStore({})}>
@@ -20,28 +21,15 @@ const wrapComponent = (route) => (
20
21
 
21
22
  const mock = new MockAdapter(api.axiosInstance);
22
23
 
23
- const mockedNavigate = jest.fn();
24
- const mockedGoBack = jest.fn();
25
-
26
- jest.mock('@react-navigation/native', () => {
27
- return {
28
- ...jest.requireActual('@react-navigation/native'),
29
- useNavigation: () => ({
30
- navigate: mockedNavigate,
31
- goBack: mockedGoBack,
32
- }),
33
- };
34
- });
35
-
36
24
  describe('Test AddNewGateway', () => {
37
25
  let tree;
38
26
  let route;
39
-
40
- afterEach(() => {
41
- mockedNavigate.mockClear();
42
- });
27
+ const mockedGoBack = useNavigation().goBack;
28
+ const mockedNavigate = useNavigation().navigate;
43
29
 
44
30
  beforeEach(() => {
31
+ mockedGoBack.mockClear();
32
+ mockedNavigate.mockClear();
45
33
  route = {
46
34
  params: {
47
35
  unit_id: 1,
@@ -58,7 +58,7 @@ describe('test share wifi password', () => {
58
58
  it('render connect wifi guide', async () => {
59
59
  const route = { params: {} };
60
60
  await act(async () => {
61
- tree = renderer.create(wrapComponent(route));
61
+ tree = await renderer.create(wrapComponent(route));
62
62
  });
63
63
 
64
64
  const instance = tree.root;
@@ -34,7 +34,7 @@ describe('test scan gateway device QR', () => {
34
34
  it('render scan gateway device', async () => {
35
35
  const route = { params: {} };
36
36
  await act(async () => {
37
- tree = renderer.create(wrapComponent(route));
37
+ tree = await renderer.create(wrapComponent(route));
38
38
  });
39
39
 
40
40
  const instance = tree.root;
@@ -45,7 +45,7 @@ describe('test scan gateway device QR', () => {
45
45
  const scanQRCode = async (data) => {
46
46
  const route = { params: {} };
47
47
  await act(async () => {
48
- tree = renderer.create(wrapComponent(route));
48
+ tree = await renderer.create(wrapComponent(route));
49
49
  });
50
50
 
51
51
  const instance = tree.root;