@eohjsc/react-native-smart-city 0.3.8 → 0.3.11

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 (297) hide show
  1. package/README.md +36 -15
  2. package/package.json +10 -6
  3. package/react-native-smart-city.podspec +1 -0
  4. package/src/commons/Action/ItemQuickAction.js +16 -4
  5. package/src/commons/Action/__test__/ItemQuickAction.test.js +11 -6
  6. package/src/commons/ActionGroup/ColorPickerTemplate.js +37 -24
  7. package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
  8. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
  9. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
  10. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +24 -0
  11. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +14 -0
  12. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +1 -0
  13. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +8 -2
  14. package/src/commons/ActionGroup/SliderRangeTemplate.js +6 -2
  15. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -3
  16. package/src/commons/ActionGroup/StatesGridActionTemplate.js +22 -8
  17. package/src/commons/ActionGroup/TimerActionTemplate.js +11 -3
  18. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +1 -5
  19. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
  20. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
  21. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +53 -78
  22. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +36 -20
  23. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +77 -0
  24. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +58 -6
  25. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +49 -1
  26. package/src/commons/ActionGroup/__test__/index.test.js +135 -0
  27. package/src/commons/Auth/AccountList.js +1 -1
  28. package/src/commons/Automate/ItemAutomate.js +1 -3
  29. package/src/commons/Calendar/__test__/Calendar.test.js +33 -0
  30. package/src/commons/Connecting/__test__/Connecting.test.js +19 -2
  31. package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +7 -3
  32. package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +8 -11
  33. package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
  34. package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +3 -2
  35. package/src/commons/ConnectingProcess/index.js +76 -26
  36. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +16 -13
  37. package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
  38. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +0 -5
  39. package/src/commons/Device/ConnectedViewHeader.js +1 -1
  40. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
  41. package/src/commons/Device/HistoryChart.js +7 -3
  42. package/src/commons/Device/ItemDevice.js +34 -13
  43. package/src/commons/Device/LinearChart.js +15 -0
  44. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
  45. package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
  46. package/src/commons/Device/SonosSpeaker/index.js +1 -1
  47. package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
  48. package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +7 -2
  49. package/src/commons/Explore/__test__/CityItem.test.js +33 -54
  50. package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +25 -0
  51. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +96 -0
  52. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +39 -0
  53. package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +118 -0
  54. package/src/commons/FieldTemplate/ChooseUserField/index.js +62 -0
  55. package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +30 -0
  56. package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +90 -0
  57. package/src/commons/FieldTemplate/PasscodeField/index.js +43 -0
  58. package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +13 -0
  59. package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +179 -0
  60. package/src/commons/FieldTemplate/ScheduleField/index.js +176 -0
  61. package/src/commons/Form/CurrencyInput.js +15 -1
  62. package/src/commons/Form/TextInputPassword.js +1 -1
  63. package/src/commons/FullLoading/index.js +2 -1
  64. package/src/commons/Header/HeaderCustom.js +2 -1
  65. package/src/commons/HeaderAni/index.js +6 -1
  66. package/src/commons/HorizontalPicker/index.js +2 -2
  67. package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +0 -6
  68. package/src/commons/MediaPlayerDetail/index.js +29 -47
  69. package/src/commons/MenuActionAddnew/index.js +1 -0
  70. package/src/commons/MenuActionList/index.js +1 -0
  71. package/src/commons/MenuActionMore/index.js +1 -1
  72. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +62 -0
  73. package/src/commons/PreventAccess/index.js +9 -1
  74. package/src/commons/Sharing/MemberList.js +10 -2
  75. package/src/commons/Sharing/WrapHeaderScrollable.js +2 -0
  76. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
  77. package/src/commons/SubUnit/Favorites/index.js +6 -3
  78. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
  79. package/src/commons/SubUnit/OneTap/index.js +1 -2
  80. package/src/commons/SubUnit/ShortDetail.js +25 -9
  81. package/src/commons/SubUnit/__test__/Item.test.js +0 -1
  82. package/src/commons/SubUnit/__test__/ShortDetail.test.js +9 -2
  83. package/src/commons/Unit/SharedUnit.js +1 -0
  84. package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
  85. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +28 -1
  86. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +2 -13
  87. package/src/commons/UnitSummary/ConfigHistoryChart.js +55 -13
  88. package/src/commons/WheelDateTimePicker/index.js +4 -3
  89. package/src/configs/API.js +91 -143
  90. package/src/configs/Constants.js +80 -1
  91. package/src/configs/SCConfig.js +4 -0
  92. package/src/context/actionType.ts +14 -2
  93. package/src/context/mockStore.ts +26 -0
  94. package/src/context/reducer.ts +84 -5
  95. package/src/hooks/Common/index.js +2 -0
  96. package/src/hooks/Common/useGGHomeDeviceConnected.js +16 -0
  97. package/src/hooks/Common/useGetIdUser.js +1 -5
  98. package/src/hooks/Common/useSensorsStatus.js +4 -4
  99. package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +199 -0
  100. package/src/hooks/IoT/__test__/useRemoteControl.test.js +198 -0
  101. package/src/hooks/IoT/__test__/useValueEvaluation.test.js +58 -0
  102. package/src/hooks/IoT/index.js +5 -0
  103. package/src/hooks/IoT/useGGHomeConnection.js +93 -0
  104. package/src/hooks/IoT/useRemoteControl.js +79 -0
  105. package/src/hooks/IoT/useValueEvaluation.js +45 -0
  106. package/src/hooks/index.js +4 -0
  107. package/src/hooks/useReceiveNotifications.js +12 -7
  108. package/src/iot/Monitor.js +3 -2
  109. package/src/iot/RemoteControl/Bluetooth.js +1 -1
  110. package/src/iot/RemoteControl/GoogleHome.js +75 -49
  111. package/src/iot/RemoteControl/Internet.js +1 -1
  112. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +95 -48
  113. package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
  114. package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
  115. package/src/iot/RemoteControl/index.js +52 -52
  116. package/src/navigations/UnitStack.js +19 -20
  117. package/src/navigations/UnitStackStyles.js +21 -0
  118. package/src/screens/AQIGuide/index.js +1 -1
  119. package/src/screens/ActivityLog/FilterPopup.js +2 -0
  120. package/src/screens/ActivityLog/__test__/index.test.js +38 -23
  121. package/src/screens/ActivityLog/hooks/__test__/index.test.js +51 -90
  122. package/src/screens/ActivityLog/hooks/index.js +1 -1
  123. package/src/screens/ActivityLog/index.js +2 -2
  124. package/src/screens/AddCommon/SelectSubUnit.js +1 -0
  125. package/src/screens/AddCommon/SelectUnit.js +1 -0
  126. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +13 -24
  127. package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
  128. package/src/screens/AddLocationMaps/__test__/index.test.js +265 -0
  129. package/src/screens/AddLocationMaps/index.js +48 -21
  130. package/src/screens/AddNewAction/SelectAction.js +33 -13
  131. package/src/screens/AddNewAction/SelectSensorDevices.js +8 -2
  132. package/src/screens/AddNewAction/SetupSensor.js +68 -32
  133. package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
  134. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
  135. package/src/screens/AddNewAction/__test__/SetupSensor.test.js +2 -0
  136. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
  137. package/src/screens/AddNewAutoSmart/index.js +5 -2
  138. package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
  139. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +42 -34
  140. package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -4
  141. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +22 -22
  142. package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
  143. package/src/screens/AddNewDevice/index.js +1 -0
  144. package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
  145. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +46 -40
  146. package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +64 -10
  147. package/src/screens/AddNewGateway/SelectGateway.js +1 -0
  148. package/src/screens/AddNewGateway/SetupGatewayWifi.js +2 -0
  149. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +4 -6
  150. package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -4
  151. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +5 -29
  152. package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +0 -4
  153. package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -4
  154. package/src/screens/AddNewGateway/index.js +1 -0
  155. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +10 -24
  156. package/src/screens/AddNewOneTap/index.js +3 -2
  157. package/src/screens/AllCamera/index.js +4 -4
  158. package/src/screens/Automate/MultiUnits.js +8 -8
  159. package/src/screens/Automate/__test__/MultiUnits.test.js +6 -9
  160. package/src/screens/Automate/__test__/index.test.js +7 -12
  161. package/src/screens/Automate/index.js +5 -3
  162. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +36 -8
  163. package/src/screens/ConfirmUnitDeletion/index.js +7 -1
  164. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +71 -22
  165. package/src/screens/Device/EditDevice/index.js +17 -15
  166. package/src/screens/Device/__test__/detail.test.js +33 -86
  167. package/src/screens/Device/components/DetailHistoryChart.js +1 -1
  168. package/src/screens/Device/components/SensorConnectStatusViewHeader.js +44 -24
  169. package/src/screens/Device/components/SensorDisplayItem.js +5 -2
  170. package/src/screens/Device/detail.js +101 -51
  171. package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
  172. package/src/screens/Device/hooks/useEvaluateValue.js +97 -0
  173. package/src/screens/Device/hooks/useFavoriteDevice.js +7 -11
  174. package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
  175. package/src/screens/EditActionsList/index.js +1 -1
  176. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +6 -3
  177. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
  178. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +20 -2
  179. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +40 -23
  180. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  181. package/src/screens/EmergencySetting/index.js +4 -1
  182. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
  183. package/src/screens/Explore/index.js +2 -0
  184. package/src/screens/GuestInfo/__test__/index.test.js +14 -41
  185. package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
  186. package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
  187. package/src/screens/HanetCamera/Detail.js +1 -1
  188. package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +8 -12
  189. package/src/screens/HanetCamera/__test__/Detail.test.js +27 -42
  190. package/src/screens/HanetCamera/__test__/ManageAccess.test.js +8 -5
  191. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -32
  192. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +3 -2
  193. package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +43 -35
  194. package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
  195. package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
  196. package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
  197. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +33 -22
  198. package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +44 -45
  199. package/src/screens/ManageAccess/hooks/index.js +7 -4
  200. package/src/screens/ManageAccess/index.js +2 -1
  201. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
  202. package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
  203. package/src/screens/Notification/__test__/Notification.test.js +31 -25
  204. package/src/screens/Notification/__test__/NotificationItem.test.js +8 -7
  205. package/src/screens/Notification/components/NotificationItem.js +17 -20
  206. package/src/screens/Notification/index.js +13 -2
  207. package/src/screens/PlayBackCamera/Timer.js +2 -2
  208. package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
  209. package/src/screens/PlayBackCamera/index.js +54 -35
  210. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
  211. package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
  212. package/src/screens/ScanChipQR/hooks/index.js +15 -16
  213. package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
  214. package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
  215. package/src/screens/ScriptDetail/index.js +30 -15
  216. package/src/screens/SelectUnit/__test__/index.test.js +12 -55
  217. package/src/screens/SelectUnit/index.js +9 -4
  218. package/src/screens/SetSchedule/index.js +15 -11
  219. package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
  220. package/src/screens/SharedUnit/index.js +2 -0
  221. package/src/screens/Sharing/Components/SensorItem.js +10 -12
  222. package/src/screens/Sharing/InfoMemberUnit.js +1 -1
  223. package/src/screens/Sharing/MemberList.js +12 -11
  224. package/src/screens/Sharing/SelectPermission.js +136 -83
  225. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +47 -29
  226. package/src/screens/Sharing/__test__/MemberList.test.js +13 -127
  227. package/src/screens/Sharing/__test__/MemberList2.test.js +80 -0
  228. package/src/screens/Sharing/__test__/SelectPermission.test.js +28 -38
  229. package/src/screens/Sharing/__test__/SelectUser.test.js +17 -38
  230. package/src/screens/Sharing/hooks/index.js +3 -0
  231. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
  232. package/src/screens/SideMenuDetail/__test__/index.test.js +154 -0
  233. package/src/screens/SideMenuDetail/index.js +148 -0
  234. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -2
  235. package/src/screens/SmartIr/components/SelectBrand.js +1 -1
  236. package/src/screens/SubUnit/AddSubUnit.js +23 -17
  237. package/src/screens/SubUnit/Detail.js +1 -2
  238. package/src/screens/SubUnit/EditSubUnit.js +15 -13
  239. package/src/screens/SubUnit/ManageSubUnit.js +13 -7
  240. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +29 -89
  241. package/src/screens/SubUnit/__test__/Detail.test.js +31 -8
  242. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +21 -89
  243. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +27 -1
  244. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +48 -45
  245. package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
  246. package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
  247. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +22 -91
  248. package/src/screens/TDSGuide/index.js +4 -1
  249. package/src/screens/UVIndexGuide/index.js +1 -1
  250. package/src/screens/Unit/ChooseLocation.js +7 -14
  251. package/src/screens/Unit/Detail.js +37 -75
  252. package/src/screens/Unit/ManageUnit.js +1 -0
  253. package/src/screens/Unit/SelectAddress.js +46 -26
  254. package/src/screens/Unit/SelectDevices.js +158 -0
  255. package/src/screens/Unit/SelectDevicesStyles.js +40 -0
  256. package/src/screens/Unit/SmartAccount.js +4 -4
  257. package/src/screens/Unit/Station/index.js +4 -0
  258. package/src/screens/Unit/Summaries.js +18 -2
  259. package/src/screens/Unit/__test__/CheckSendEmail.test.js +24 -29
  260. package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
  261. package/src/screens/Unit/__test__/Detail.test.js +98 -199
  262. package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
  263. package/src/screens/Unit/__test__/SelectAddress.test.js +249 -50
  264. package/src/screens/Unit/__test__/SelectDevices.test.js +110 -0
  265. package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
  266. package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
  267. package/src/screens/Unit/__test__/Summaries.test.js +100 -0
  268. package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +36 -0
  269. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +54 -0
  270. package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
  271. package/src/screens/Unit/components/SharedUnit/index.js +1 -0
  272. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
  273. package/src/screens/Unit/components/__test__/SharedUnit.test.js +31 -34
  274. package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +50 -0
  275. package/src/screens/Unit/styles.js +8 -0
  276. package/src/screens/UnitSummary/__test__/index.test.js +91 -30
  277. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +31 -2
  278. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
  279. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +2 -13
  280. package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -1
  281. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
  282. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +11 -2
  283. package/src/screens/UnitSummary/components/RunningDevices/index.js +7 -10
  284. package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
  285. package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +10 -2
  286. package/src/screens/UnitSummary/index.js +15 -1
  287. package/src/screens/WaterQualityGuide/index.js +1 -1
  288. package/src/utils/Apis/axios.js +61 -32
  289. package/src/utils/Converter/time.js +0 -18
  290. package/src/utils/I18n/translations/en.json +13 -1
  291. package/src/utils/I18n/translations/vi.json +14 -1
  292. package/src/utils/Permission/common.js +67 -0
  293. package/src/utils/Route/index.js +2 -0
  294. package/src/utils/Setting/Location.js +30 -0
  295. package/src/utils/Utils.js +12 -7
  296. package/src/utils/Validation.js +3 -0
  297. package/src/utils/__test__/Utils.test.js +12 -0
@@ -1,15 +1,17 @@
1
1
  import React from 'react';
2
2
  import renderer, { act } from 'react-test-renderer';
3
3
  import { TouchableOpacity, Platform } from 'react-native';
4
- import axios from 'axios';
4
+ import MockAdapter from 'axios-mock-adapter';
5
5
 
6
6
  import AddCommonSelectUnit from '../SelectUnit';
7
7
  import Text from '../../../commons/Text';
8
8
  import { TESTID } from '../../../configs/Constants';
9
9
  import { SCProvider } from '../../../context';
10
10
  import { mockSCStore } from '../../../context/mockStore';
11
+ import api from '../../../utils/Apis/axios';
12
+ import { API } from '../../../configs';
11
13
 
12
- jest.mock('axios');
14
+ const mock = new MockAdapter(api.axiosInstance);
13
15
 
14
16
  const mockedGoBack = jest.fn();
15
17
  const mockedNavigate = jest.fn();
@@ -86,11 +88,7 @@ describe('Test SelectUnit container', () => {
86
88
  { id: 2, name: 'Unit 2' },
87
89
  ],
88
90
  };
89
-
90
- axios.get.mockImplementation(async () => {
91
- return response;
92
- });
93
-
91
+ mock.onGet(API.SHARE.UNITS()).reply(200, response.data);
94
92
  await act(async () => {
95
93
  tree = renderer.create(wrapComponent(route));
96
94
  });
@@ -151,10 +149,6 @@ describe('Test SelectUnit container', () => {
151
149
  describe('test single SelectUnit', () => {
152
150
  let tree;
153
151
 
154
- beforeEach(() => {
155
- axios.get.mockClear();
156
- });
157
-
158
152
  test('fetch Unit success', async () => {
159
153
  Platform.OS = 'android';
160
154
  const route = { params: { addType: 'AddSubUnit' } };
@@ -166,15 +160,10 @@ describe('test single SelectUnit', () => {
166
160
  { id: 2, name: 'Unit 2' },
167
161
  ],
168
162
  };
169
-
170
- axios.get.mockImplementation(async () => {
171
- return response;
172
- });
173
-
163
+ mock.onGet(API.SHARE.UNITS()).reply(200, response.data);
174
164
  await act(async () => {
175
165
  tree = renderer.create(wrapComponent(route));
176
166
  });
177
-
178
167
  const instance = tree.root;
179
168
  const unitName = instance.findAll(
180
169
  (item) =>
@@ -183,35 +172,23 @@ describe('test single SelectUnit', () => {
183
172
  const radioButton = instance.findAll(
184
173
  (item) => item.props.testID === TESTID.SELECT_UNIT_RADIO_BUTTON
185
174
  );
186
-
187
175
  expect(unitName[0].props.children).toBe('Unit 1');
188
176
  expect(unitName[1].props.children).toBe('Unit 2');
189
177
  expect(radioButton[0].props.active).toBeFalsy();
190
178
  expect(radioButton[1].props.active).toBeFalsy();
191
-
192
179
  const selectUnit = instance.findAll(
193
180
  (item) => item.props.testID === TESTID.SELECT_UNIT_SELECT
194
181
  );
195
-
196
182
  await act(async () => {
197
183
  selectUnit[0].props.onPress();
198
184
  });
199
-
200
185
  expect(radioButton[0].props.active).toBeTruthy();
201
186
  });
202
187
 
203
188
  test('fetch Unit not success', async () => {
204
189
  Platform.OS = 'ios';
205
190
  const route = { params: { addType: 'AddSubUnit' } };
206
- const response = {
207
- status: 500,
208
- success: false,
209
- };
210
-
211
- axios.get.mockImplementation(async () => {
212
- return response;
213
- });
214
-
191
+ mock.onGet(500);
215
192
  await act(async () => {
216
193
  tree = renderer.create(wrapComponent(route));
217
194
  });
@@ -224,9 +201,8 @@ describe('test single SelectUnit', () => {
224
201
  const radioButton = instance.findAll(
225
202
  (item) => item.props.testID === TESTID.SELECT_UNIT_RADIO_BUTTON
226
203
  );
227
-
228
- expect(unitName).toHaveLength(0);
229
- expect(radioButton).toHaveLength(0);
204
+ expect(unitName).toHaveLength(2);
205
+ expect(radioButton).toHaveLength(2);
230
206
  });
231
207
 
232
208
  test('click goBack', async () => {
@@ -0,0 +1,265 @@
1
+ import React from 'react';
2
+ import { Alert } from 'react-native';
3
+ import { act, create } from 'react-test-renderer';
4
+ import MockAdapter from 'axios-mock-adapter';
5
+ import RNP from 'react-native-permissions';
6
+ import RNAndroidLocationEnabler from 'react-native-android-location-enabler';
7
+
8
+ import { SCProvider } from '../../../context';
9
+ import { mockSCStore } from '../../../context/mockStore';
10
+ import AddLocationMaps from '../index';
11
+ import { API } from '../../../configs';
12
+ import { TESTID } from '../../../configs/Constants';
13
+ import api from '../../../utils/Apis/axios';
14
+ import {
15
+ GEOLOCATION_ERROR,
16
+ OpenSetting,
17
+ } from '../../../utils/Permission/common';
18
+ import { RESULTS } from 'react-native-permissions';
19
+
20
+ const wrapComponent = (route) => (
21
+ <SCProvider initState={mockSCStore({})}>
22
+ <AddLocationMaps route={route} />
23
+ </SCProvider>
24
+ );
25
+
26
+ const mock = new MockAdapter(api.axiosInstance);
27
+
28
+ const mockNavigate = jest.fn();
29
+ const mockGoBack = jest.fn();
30
+ jest.mock('@react-navigation/native', () => {
31
+ return {
32
+ ...jest.requireActual('@react-navigation/native'),
33
+ useNavigation: () => ({
34
+ navigate: mockNavigate,
35
+ goBack: mockGoBack,
36
+ }),
37
+ };
38
+ });
39
+
40
+ jest.mock('react', () => {
41
+ return {
42
+ ...jest.requireActual('react'),
43
+ memo: (x) => x,
44
+ };
45
+ });
46
+
47
+ jest.mock('react-native-maps', () => {
48
+ const { forwardRef } = require('react');
49
+ const { View } = require('react-native');
50
+ const MockMapView = forwardRef((props, ref) => (
51
+ <View refs={ref}>{props.children}</View>
52
+ ));
53
+ const MockMarker = (props) => <View>{props.children}</View>;
54
+ const MockCircle = (props) => <View>{props.children}</View>;
55
+ return {
56
+ __esModule: true,
57
+ default: MockMapView,
58
+ Marker: MockMarker,
59
+ Circle: MockCircle,
60
+ PROVIDER_GOOGLE: 'google',
61
+ };
62
+ });
63
+
64
+ jest.mock('react-native-android-location-enabler', () => {
65
+ return {
66
+ ...jest.requireActual('react-native-android-location-enabler'),
67
+ promptForEnableLocationIfNeeded: jest.fn(),
68
+ };
69
+ });
70
+
71
+ jest.mock('../../../utils/Permission/common');
72
+
73
+ const position = {
74
+ coords: {
75
+ latitude: 100,
76
+ longitude: 100,
77
+ },
78
+ };
79
+ const mockGeolocation = {
80
+ getCurrentPosition: (onSuccess, onError, options) => {
81
+ onSuccess(position);
82
+ },
83
+ };
84
+ global.navigator.geolocation = mockGeolocation;
85
+
86
+ jest.mock('react-native-permissions', () => {
87
+ return require('react-native-permissions/mock');
88
+ });
89
+
90
+ describe('Test SelectAddress', () => {
91
+ let tree, route, Platform;
92
+ const mockUpdateLocation = jest.fn();
93
+
94
+ beforeAll(() => {
95
+ Platform = require('react-native').Platform;
96
+ RNAndroidLocationEnabler.promptForEnableLocationIfNeeded.mockClear();
97
+ RNP.check.mockClear();
98
+ route = {
99
+ params: {
100
+ updateLocation: mockUpdateLocation,
101
+ },
102
+ };
103
+ });
104
+
105
+ test('test get current location success', async () => {
106
+ await act(async () => {
107
+ tree = await create(wrapComponent(route));
108
+ });
109
+ const instance = tree.root;
110
+ const button = instance.find(
111
+ (el) => el.props.testID === TESTID.BUTTON_YOUR_LOCATION
112
+ );
113
+
114
+ const response = {
115
+ status: 200,
116
+ data: {
117
+ results: [
118
+ {
119
+ formatted_address: 'address',
120
+ geometry: {
121
+ location: {
122
+ lat: 10,
123
+ lng: 10,
124
+ },
125
+ },
126
+ },
127
+ ],
128
+ },
129
+ };
130
+ mock
131
+ .onGet(API.EXTERNAL.GOOGLE_MAP.GET_LOCATION_FROM_LAT_LNG)
132
+ .reply(200, response.data);
133
+ await act(async () => {
134
+ await button.props.onPress();
135
+ });
136
+ });
137
+
138
+ test('test get current location failed permission denied', async () => {
139
+ await act(async () => {
140
+ tree = await create(wrapComponent(route));
141
+ });
142
+ const instance = tree.root;
143
+ const button = instance.find(
144
+ (el) => el.props.testID === TESTID.BUTTON_YOUR_LOCATION
145
+ );
146
+
147
+ global.navigator.geolocation = {
148
+ getCurrentPosition: (onSuccess, onError, options) => {
149
+ onError({ code: GEOLOCATION_ERROR.PERMISSION_DENIED });
150
+ },
151
+ };
152
+ RNP.check.mockImplementationOnce(() => RESULTS.BLOCKED);
153
+ OpenSetting.mockImplementationOnce(() => {});
154
+
155
+ await act(async () => {
156
+ await button.props.onPress();
157
+ });
158
+ OpenSetting.mockClear();
159
+ });
160
+
161
+ test('test get current location failed location not enabled android', async () => {
162
+ Platform.OS = 'android';
163
+ await act(async () => {
164
+ tree = await create(wrapComponent(route));
165
+ });
166
+ const instance = tree.root;
167
+ const button = instance.find(
168
+ (el) => el.props.testID === TESTID.BUTTON_YOUR_LOCATION
169
+ );
170
+
171
+ global.navigator.geolocation = {
172
+ getCurrentPosition: (onSuccess, onError, options) => {
173
+ onError({ code: GEOLOCATION_ERROR.POSITION_UNAVAILABLE });
174
+ },
175
+ };
176
+
177
+ // cancel
178
+ RNAndroidLocationEnabler.promptForEnableLocationIfNeeded.mockImplementationOnce(
179
+ async () => {
180
+ throw new Error();
181
+ }
182
+ );
183
+ await act(async () => {
184
+ await button.props.onPress();
185
+ });
186
+ expect(
187
+ RNAndroidLocationEnabler.promptForEnableLocationIfNeeded
188
+ ).toBeCalled();
189
+
190
+ RNAndroidLocationEnabler.promptForEnableLocationIfNeeded.mockClear();
191
+
192
+ // enabled
193
+ RNAndroidLocationEnabler.promptForEnableLocationIfNeeded.mockImplementationOnce(
194
+ async () => true
195
+ );
196
+ await act(async () => {
197
+ await button.props.onPress();
198
+ });
199
+ expect(
200
+ RNAndroidLocationEnabler.promptForEnableLocationIfNeeded
201
+ ).toBeCalled();
202
+ });
203
+
204
+ test('test get current location failed location not enabled ios', async () => {
205
+ Platform.OS = 'ios';
206
+ jest.spyOn(Alert, 'alert');
207
+
208
+ await act(async () => {
209
+ tree = await create(wrapComponent(route));
210
+ });
211
+ const instance = tree.root;
212
+ const button = instance.find(
213
+ (el) => el.props.testID === TESTID.BUTTON_YOUR_LOCATION
214
+ );
215
+
216
+ global.navigator.geolocation = {
217
+ getCurrentPosition: (onSuccess, onError, options) => {
218
+ onError({ code: GEOLOCATION_ERROR.POSITION_UNAVAILABLE });
219
+ },
220
+ };
221
+
222
+ await act(async () => {
223
+ await button.props.onPress();
224
+ });
225
+ // expect AlertAsync is called
226
+ });
227
+
228
+ test('test get current location failed error not handle', async () => {
229
+ await act(async () => {
230
+ tree = await create(wrapComponent(route));
231
+ });
232
+ const instance = tree.root;
233
+ const button = instance.find(
234
+ (el) => el.props.testID === TESTID.BUTTON_YOUR_LOCATION
235
+ );
236
+
237
+ global.navigator.geolocation = {
238
+ getCurrentPosition: (onSuccess, onError, options) => {
239
+ onError({ code: GEOLOCATION_ERROR.TIMEOUT });
240
+ },
241
+ };
242
+ RNP.check.mockImplementationOnce(() => RESULTS.DENIED);
243
+ OpenSetting.mockImplementationOnce(() => {});
244
+
245
+ await act(async () => {
246
+ await button.props.onPress();
247
+ });
248
+ expect(OpenSetting).toBeCalledTimes(0);
249
+ OpenSetting.mockClear();
250
+ });
251
+
252
+ test('test choose on map', async () => {
253
+ await act(async () => {
254
+ tree = await create(wrapComponent(route));
255
+ });
256
+ const instance = tree.root;
257
+ const button = instance.find(
258
+ (el) => el.props.testID === TESTID.BUTTON_CHOOSE_ON_MAP
259
+ );
260
+ await act(async () => {
261
+ await button.props.onPress();
262
+ });
263
+ expect(mockNavigate).toBeCalled();
264
+ });
265
+ });
@@ -3,26 +3,30 @@ import { View, ScrollView, TouchableOpacity } from 'react-native';
3
3
  import MapView, { Marker, Circle, PROVIDER_GOOGLE } from 'react-native-maps';
4
4
  import { useNavigation } from '@react-navigation/native';
5
5
  import { IconOutline, IconFill } from '@ant-design/icons-react-native';
6
+ import { check, RESULTS } from 'react-native-permissions';
6
7
  import { useTranslations } from '../../hooks/Common/useTranslations';
7
8
 
8
9
  import Text from '../../commons/Text';
9
- import { ViewButtonBottom } from '../../commons';
10
+ import { ViewButtonBottom, FullLoading } from '../../commons';
10
11
  import SearchBarLocation from '../../commons/SearchLocation';
11
12
  import RowLocation from '../../commons/SearchLocation/RowLocation';
12
13
  import { axiosGet } from '../../utils/Apis/axios';
13
14
  import { API, Colors, SCConfig } from '../../configs';
14
- import { TESTID } from '../../configs/Constants';
15
+ import {
16
+ TESTID,
17
+ MAP_INITIAL_REGION,
18
+ EOH_LOCATION,
19
+ } from '../../configs/Constants';
15
20
  import styles from './indexStyle';
16
21
  import Routes from '../../utils/Route';
22
+ import {
23
+ GEOLOCATION_ERROR,
24
+ keyPermission,
25
+ OpenSetting,
26
+ } from '../../utils/Permission/common';
27
+ import { openPromptEnableLocation } from '../../utils/Setting/Location';
17
28
 
18
29
  export const initialRadius = 250;
19
- const initialRegion = {
20
- latitudeDelta: 0.0090222,
21
- longitudeDelta: 0.009221,
22
- };
23
-
24
- const DEFAULT_LATITUDE = 10.7974046; // EoH center
25
- const DEFAULT_LONGITUDE = 106.7035663;
26
30
 
27
31
  navigator.geolocation = require('@react-native-community/geolocation');
28
32
 
@@ -32,7 +36,7 @@ const AddLocationMaps = memo(() => {
32
36
  const [input, setInput] = useState('');
33
37
  const [searchData, setSearchData] = useState([]);
34
38
  const [searchedLocation, setSearchedLocation] = useState(null);
35
-
39
+ const [loading, setLoading] = useState(false);
36
40
  const mapRef = useRef(null);
37
41
 
38
42
  const onDone = useCallback(() => {
@@ -45,9 +49,9 @@ const AddLocationMaps = memo(() => {
45
49
  goBack();
46
50
  }, [goBack]);
47
51
 
48
- const onTextInput = useCallback(async (input) => {
49
- setInput(input);
50
- if (!input) {
52
+ const onTextInput = useCallback(async (newValue) => {
53
+ setInput(newValue);
54
+ if (!newValue) {
51
55
  setSearchData([]);
52
56
  setSearchedLocation(null);
53
57
  return;
@@ -55,7 +59,7 @@ const AddLocationMaps = memo(() => {
55
59
  try {
56
60
  const config = {
57
61
  params: {
58
- input: input,
62
+ input: newValue,
59
63
  key: SCConfig.GOOGLE_MAP_API_KEY,
60
64
  sessiontoken: 123456324,
61
65
  strictBounds: false,
@@ -70,6 +74,7 @@ const AddLocationMaps = memo(() => {
70
74
  if (success) {
71
75
  setSearchData(data.predictions);
72
76
  }
77
+ // eslint-disable-next-line no-empty
73
78
  } catch (error) {}
74
79
  }, []);
75
80
 
@@ -82,7 +87,8 @@ const AddLocationMaps = memo(() => {
82
87
  {
83
88
  latitude: lat,
84
89
  longitude: lng,
85
- ...initialRegion,
90
+ latitudeDelta: MAP_INITIAL_REGION.LAT,
91
+ longitudeDelta: MAP_INITIAL_REGION.LNG,
86
92
  },
87
93
  600
88
94
  );
@@ -117,6 +123,7 @@ const AddLocationMaps = memo(() => {
117
123
  async (position) => {
118
124
  const currentLatitude = JSON.stringify(position.coords.latitude);
119
125
  const currentLongitude = JSON.stringify(position.coords.longitude);
126
+ setLoading(true);
120
127
  const { success, data } = await axiosGet(
121
128
  API.EXTERNAL.GOOGLE_MAP.GET_LOCATION_FROM_LAT_LNG,
122
129
  {
@@ -135,11 +142,26 @@ const AddLocationMaps = memo(() => {
135
142
  longitude: result.geometry.location.lng,
136
143
  });
137
144
  }
145
+ setLoading(false);
146
+ },
147
+ async (error) => {
148
+ if (error.code === GEOLOCATION_ERROR.PERMISSION_DENIED) {
149
+ const permissionResult = await check(keyPermission.LOCATION);
150
+ permissionResult === RESULTS.BLOCKED &&
151
+ OpenSetting(
152
+ t('location_rationale_title'),
153
+ t('location_require_message')
154
+ );
155
+ } else if (error.code === GEOLOCATION_ERROR.POSITION_UNAVAILABLE) {
156
+ const locationEnabaled = await openPromptEnableLocation();
157
+ process.env.NODE_ENV !== 'test' &&
158
+ locationEnabaled &&
159
+ getCurrentPosition();
160
+ }
138
161
  },
139
- (error) => {},
140
162
  {}
141
163
  );
142
- }, []);
164
+ }, [t]);
143
165
 
144
166
  const chooseOnMap = useCallback(() => {
145
167
  navigate(Routes.UnitStack, {
@@ -169,7 +191,10 @@ const AddLocationMaps = memo(() => {
169
191
  </Text>
170
192
  <View style={styles.searchLocation}>
171
193
  <SearchBarLocation input={input} onTextInput={onTextInput} />
172
- <ScrollView style={styles.searchData}>
194
+ <ScrollView
195
+ style={styles.searchData}
196
+ scrollIndicatorInsets={{ right: 1 }}
197
+ >
173
198
  {searchData.map((item) => (
174
199
  <RowLocation item={item} onPress={onPressRowLocation} />
175
200
  ))}
@@ -220,9 +245,10 @@ const AddLocationMaps = memo(() => {
220
245
  provider={PROVIDER_GOOGLE}
221
246
  style={styles.mapView}
222
247
  initialRegion={{
223
- ...initialRegion,
224
- latitude: DEFAULT_LATITUDE,
225
- longitude: DEFAULT_LONGITUDE,
248
+ latitude: EOH_LOCATION.LAT,
249
+ longitude: EOH_LOCATION.LNG,
250
+ latitudeDelta: MAP_INITIAL_REGION.LAT,
251
+ longitudeDelta: MAP_INITIAL_REGION.LNG,
226
252
  }}
227
253
  followUserLocation={true}
228
254
  >
@@ -262,6 +288,7 @@ const AddLocationMaps = memo(() => {
262
288
  onRightClick={onDone}
263
289
  rightDisabled={!input}
264
290
  />
291
+ {loading && <FullLoading />}
265
292
  </View>
266
293
  );
267
294
  });
@@ -12,7 +12,11 @@ import OptionsDropdownActionTemplate from '../../commons/OneTapTemplate/OptionsD
12
12
  import StatesGridActionTemplate from '../../commons/OneTapTemplate/StatesGridActionTemplate';
13
13
  import { axiosGet, axiosPost } from '../../utils/Apis/axios';
14
14
  import { API, Images } from '../../configs';
15
- import { CONDITION_TYPES, TESTID } from '../../configs/Constants';
15
+ import {
16
+ CONDITION_TYPES,
17
+ STATE_VALUE_SENSOR_TYPES,
18
+ TESTID,
19
+ } from '../../configs/Constants';
16
20
  import Routes from '../../utils/Route';
17
21
  import styles from './Styles/SelectActionStyles';
18
22
  import moment from 'moment';
@@ -21,7 +25,7 @@ import { TitleCheckBox } from '../Sharing/Components';
21
25
  import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
22
26
  import { popAction } from '../../navigations/utils';
23
27
  import { LoadingSelectAction } from './Components';
24
- import { ToastBottomHelper } from '../../utils/Utils';
28
+ import { notImplemented, ToastBottomHelper } from '../../utils/Utils';
25
29
 
26
30
  const SelectAction = memo(({ route }) => {
27
31
  const t = useTranslations();
@@ -48,10 +52,10 @@ const SelectAction = memo(({ route }) => {
48
52
  const fetchData = useCallback(async () => {
49
53
  isSelectSensor && setIsLoading(true);
50
54
  setIsfetched(true);
51
- const { success, data } = await axiosGet(
55
+ const { success, data: automateData } = await axiosGet(
52
56
  isSelectSensor
53
57
  ? API.AUTOMATE.GET_SENSOR_CONFIG(device.id)
54
- : API.SENSOR.DISPLAY_ACTIONS(device.id),
58
+ : API.DEVICE.DISPLAY_ACTIONS(device.id),
55
59
  isSelectSensor && {},
56
60
  isSelectSensor && true
57
61
  );
@@ -78,21 +82,21 @@ const SelectAction = memo(({ route }) => {
78
82
  const condition = conditionType.find((item) => {
79
83
  return item.conditionValue === automate.condition;
80
84
  });
81
- const updateSensorData = data.map((obj) =>
85
+ const updateSensorData = automateData.map((obj) =>
82
86
  obj.id === automate.config_id
83
87
  ? { ...obj, value: automate.value, ...condition }
84
88
  : obj
85
89
  );
86
- let selectSensor = data.find((config) => {
90
+ let selectSensor = automateData.find((config) => {
87
91
  return config.id === automate.config_id;
88
92
  });
89
93
  setSensorData(updateSensorData);
90
94
  setCheckedItem(selectSensor);
91
95
  } else {
92
- setSensorData(data);
96
+ setSensorData(automateData);
93
97
  }
94
98
  } else {
95
- setData(data);
99
+ setData(automateData);
96
100
  }
97
101
  }
98
102
  setIsfetched(false);
@@ -130,6 +134,7 @@ const SelectAction = memo(({ route }) => {
130
134
  value: itemTemp?.value,
131
135
  config_id: itemTemp?.id,
132
136
  config_name: itemTemp?.name,
137
+ sensor_type: itemTemp?.sensor_type,
133
138
  },
134
139
  scriptName,
135
140
  });
@@ -265,7 +270,7 @@ const SelectAction = memo(({ route }) => {
265
270
  dispatch(popAction(3));
266
271
  isAutomateTab && goBack();
267
272
  } else {
268
- alert(t('feature_under_development'));
273
+ notImplemented(t);
269
274
  }
270
275
  // eslint-disable-next-line react-hooks/exhaustive-deps
271
276
  }, [route.params]);
@@ -286,6 +291,23 @@ const SelectAction = memo(({ route }) => {
286
291
  });
287
292
  };
288
293
 
294
+ const RenderCondition = useCallback(
295
+ (item) => {
296
+ const stateConditionData = STATE_VALUE_SENSOR_TYPES.find(
297
+ (i) => i.type === item?.sensor_type
298
+ );
299
+ const isNumberValue = !stateConditionData;
300
+
301
+ if (isNumberValue) {
302
+ return `${item?.name} ${
303
+ item?.title ? item.title : t('is_below') + ' (<)'
304
+ } ${item?.value} ${item?.unit}`;
305
+ }
306
+ return t(stateConditionData?.stateValue[item?.value]);
307
+ },
308
+ [t]
309
+ );
310
+
289
311
  const rightComponent = useMemo(
290
312
  () => (
291
313
  <TouchableOpacity style={styles.closeButton} onPress={handleClose}>
@@ -326,7 +348,7 @@ const SelectAction = memo(({ route }) => {
326
348
  <LoadingSelectAction style={styles.container} />
327
349
  ) : (
328
350
  sensorData.map((item) => {
329
- const isHasValue = !!item?.value;
351
+ const isHasValue = !!item?.value || item?.value === 0;
330
352
  return (
331
353
  <View style={styles.wrapItem} key={item?.id}>
332
354
  <TitleCheckBox
@@ -351,9 +373,7 @@ const SelectAction = memo(({ route }) => {
351
373
  style={styles.description}
352
374
  >
353
375
  {isHasValue
354
- ? `${item?.name} ${
355
- item?.title ? item.title : t('is_below') + ' (<)'
356
- } ${item.value} ${item?.unit}`
376
+ ? RenderCondition(item)
357
377
  : `${t('no')} ${t('condition')}`}
358
378
  </Text>
359
379
  {isHasValue && (
@@ -28,6 +28,7 @@ const SelectSensorDevices = memo(({ route }) => {
28
28
  isAutomateTab,
29
29
  isCreateNewAction,
30
30
  isMultiUnits,
31
+ oldType,
31
32
  } = route.params;
32
33
 
33
34
  const [listStation, setListStation] = useState([]);
@@ -137,7 +138,7 @@ const SelectSensorDevices = memo(({ route }) => {
137
138
  navigate(Routes.ScriptDetail, {
138
139
  id: automateId,
139
140
  name: scriptName,
140
- type: type,
141
+ type: oldType,
141
142
  havePermission: true,
142
143
  unit,
143
144
  isMultiUnits,
@@ -175,6 +176,7 @@ const SelectSensorDevices = memo(({ route }) => {
175
176
  <ScrollView
176
177
  style={styles.wrap}
177
178
  contentContainerStyle={styles.contentContainerStyle}
179
+ scrollIndicatorInsets={{ right: 1 }}
178
180
  >
179
181
  <Text bold type="H2" style={styles.title}>
180
182
  {t(title)}
@@ -216,7 +218,11 @@ const SelectSensorDevices = memo(({ route }) => {
216
218
  style={styles.bottomButtonView}
217
219
  mainTitle={t('continue')}
218
220
  onPressMain={onPressContinue}
219
- typeMain={selectedDevice ? 'primary' : 'disabled'}
221
+ typeMain={
222
+ Object.keys(selectedDevice || {}).length === 0
223
+ ? 'disabled'
224
+ : 'primary'
225
+ }
220
226
  />
221
227
  </View>
222
228
  );