@eohjsc/react-native-smart-city 0.7.3 → 0.7.5

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 (274) hide show
  1. package/assets/images/Automation-fill.svg +85 -0
  2. package/assets/images/Map/LocationPin.svg +10 -0
  3. package/assets/images/Scenario-filled.svg +22 -0
  4. package/assets/images/schedule-fill.svg +48 -0
  5. package/package.json +20 -17
  6. package/src/commons/Action/ItemQuickAction.js +1 -1
  7. package/src/commons/Action/__test__/ItemQuickAction.test.js +6 -6
  8. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
  9. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +3 -3
  10. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +5 -5
  11. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +3 -3
  12. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +2 -2
  13. package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +2 -2
  14. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -2
  15. package/src/commons/ActionGroup/SliderRangeTemplate.js +7 -7
  16. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +2 -2
  17. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/CircleButton.js +5 -5
  18. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/ControlPlay.js +5 -5
  19. package/src/commons/ActionGroup/TerminalBoxTemplate.js +2 -2
  20. package/src/commons/ActionGroup/TextBoxTemplate.js +2 -2
  21. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonCircle.test.js +2 -2
  22. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonDefault.test.js +2 -2
  23. package/src/commons/ActionGroup/TimerActionTemplate.js +6 -3
  24. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +2 -2
  25. package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +9 -10
  26. package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +5 -5
  27. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +5 -5
  28. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +8 -8
  29. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +3 -3
  30. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +6 -6
  31. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -1
  32. package/src/commons/ActionGroup/__test__/index.test.js +6 -6
  33. package/src/commons/ActionGroup/index.js +2 -2
  34. package/src/commons/ActionTemplate/__test__/index.test.js +4 -4
  35. package/src/commons/Automate/ItemAutomate.js +9 -41
  36. package/src/commons/Automate/ItemConditionScriptDetail.js +67 -0
  37. package/src/commons/Automate/ItemConditionScriptDetailStyles.js +46 -0
  38. package/src/commons/Automate/__test__/ItemAutomate.test.js +0 -21
  39. package/src/commons/BackDefault/index.js +2 -2
  40. package/src/commons/BottomButtonView/index.js +1 -0
  41. package/src/commons/ButtonPopup/index.js +3 -2
  42. package/src/commons/ChartAggregationOption/__test__/FourButtonFilterHistory.test.js +2 -2
  43. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +8 -9
  44. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +7 -7
  45. package/src/commons/DateTimeRangeChange/DateTimeButton.js +3 -3
  46. package/src/commons/DateTimeRangeChange/index.js +1 -1
  47. package/src/commons/Device/ConnectedViewHeader.js +2 -2
  48. package/src/commons/Device/Emergency/EmergencyDetail.js +3 -3
  49. package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +1 -1
  50. package/src/commons/Device/FlatListItems.js +20 -19
  51. package/src/commons/Device/Hanet/ItemHanetDevice.js +3 -3
  52. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +3 -3
  53. package/src/commons/Device/HorizontalBarChart.js +54 -34
  54. package/src/commons/Device/ItemAddNew/index.js +2 -2
  55. package/src/commons/Device/ItemDevice.js +5 -21
  56. package/src/commons/Device/SonosSpeaker/index.js +3 -3
  57. package/src/commons/Device/WaterPurifierStatus/AlertStatusMachine.js +2 -2
  58. package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +6 -2
  59. package/src/commons/DisplayChecking/index.js +2 -2
  60. package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
  61. package/src/commons/FieldTemplate/ChooseUserField/index.js +2 -2
  62. package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +3 -3
  63. package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +6 -6
  64. package/src/commons/FlatListDnD/__test__/index.test.js +4 -4
  65. package/src/commons/FlatListDnD/index.js +12 -9
  66. package/src/commons/Grid/GridItem.js +10 -2
  67. package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +3 -3
  68. package/src/commons/Header/HeaderCustom.js +2 -2
  69. package/src/commons/Header/__test__/HeaderCT.test.js +3 -3
  70. package/src/commons/HeaderAni/index.js +2 -2
  71. package/src/commons/IconComponent/index.js +3 -3
  72. package/src/commons/ImagePicker/__test__/ImagePicker.test.js +5 -5
  73. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +6 -4
  74. package/src/commons/MenuActionMore/MenuActionMoreStyles.js +2 -1
  75. package/src/commons/MenuActionMore/index.js +1 -1
  76. package/src/commons/NavBar/NavBarStyles.js +1 -1
  77. package/src/commons/NavBar/index.js +2 -2
  78. package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +3 -3
  79. package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +1 -1
  80. package/src/commons/Popover/__test__/index.test.js +3 -3
  81. package/src/commons/Processing/__test__/Connecting.test.js +4 -4
  82. package/src/commons/SearchLocation/index.js +3 -3
  83. package/src/commons/SelectActionCard/index.js +2 -2
  84. package/src/commons/SelectSubUnit/index.js +6 -2
  85. package/src/commons/SelectUnit/__test__/SelectUnit.test.js +5 -5
  86. package/src/commons/Sharing/BtnRemoveMember.js +2 -2
  87. package/src/commons/Sharing/StationDevicePermissions.js +2 -2
  88. package/src/commons/SubUnit/DeviceTemplate/ConfigAndEvaluation/ConfigAndEvaluation.js +2 -2
  89. package/src/commons/SubUnit/DeviceTemplate/ConfigValue/ConfigValue.js +2 -2
  90. package/src/commons/SubUnit/DeviceTemplate/EvaluationOverConfig/EvaluationOverConfig.js +2 -2
  91. package/src/commons/SubUnit/OneTap/ItemOneTap.js +6 -7
  92. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +0 -2
  93. package/src/commons/SubUnit/OneTap/index.js +9 -8
  94. package/src/commons/SubUnit/__test__/ShortDetail.test.js +8 -8
  95. package/src/commons/Unit/HeaderUnit/index.js +30 -22
  96. package/src/commons/Unit/SharedUnit.js +7 -7
  97. package/src/commons/Widgets/IFrame/__tests__/IFrame.test.js +9 -13
  98. package/src/commons/Widgets/IFrameWithConfig/IFrameWithConfig.js +34 -2
  99. package/src/commons/Widgets/IFrameWithConfig/__tests__/IFrameWithConfig.test.js +88 -8
  100. package/src/commons/WrapParallaxScrollView/index.js +9 -10
  101. package/src/configs/API.js +1 -1
  102. package/src/configs/AccessibilityLabel.js +2 -0
  103. package/src/configs/Constants.js +3 -3
  104. package/src/configs/Theme.js +1 -1
  105. package/src/hooks/Common/__test__/useAndroidTranslucentStatusBar.test.js +5 -5
  106. package/src/hooks/IoT/__test__/useHomeAssistantConnection.test.js +12 -12
  107. package/src/hooks/IoT/__test__/useRemoteControl.test.js +14 -7
  108. package/src/hooks/IoT/__test__/useWatchConfigs.test.js +3 -3
  109. package/src/hooks/IoT/useRemoteControl.js +24 -13
  110. package/src/hooks/useMqtt.js +2 -2
  111. package/src/iot/RemoteControl/Bluetooth.js +19 -22
  112. package/src/iot/RemoteControl/Internet.js +13 -5
  113. package/src/iot/RemoteControl/__test__/Internet.test.js +7 -7
  114. package/src/navigations/EmergencyContactsStack.js +4 -3
  115. package/src/navigations/SharedStack.js +2 -0
  116. package/src/navigations/UnitStack.js +56 -57
  117. package/src/screens/AQIGuide/index.js +0 -2
  118. package/src/screens/ActivityLog/index.js +2 -2
  119. package/src/screens/AddLocationMaps/__test__/index.test.js +12 -12
  120. package/src/screens/AddLocationMaps/index.js +16 -19
  121. package/src/screens/AddLocationMaps/indexStyle.js +1 -0
  122. package/src/screens/AddNewGateway/RenameNewDevices.js +2 -2
  123. package/src/screens/AddNewGateway/SelectDeviceType.js +1 -1
  124. package/src/screens/AddNewGateway/ShareWifiPassword.js +16 -15
  125. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +7 -7
  126. package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +8 -8
  127. package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +7 -7
  128. package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +8 -8
  129. package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +5 -5
  130. package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +4 -4
  131. package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -6
  132. package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -6
  133. package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +0 -4
  134. package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +2 -2
  135. package/src/screens/AllGateway/DetailConfigActionModbus/__test__/index.test.js +6 -6
  136. package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +19 -17
  137. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +19 -17
  138. package/src/screens/AllGateway/DeviceZigbeeDetail/__test__/index.test.js +18 -16
  139. package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +43 -35
  140. package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +38 -22
  141. package/src/screens/AllGateway/__test__/index.test.js +6 -6
  142. package/src/screens/AllGateway/components/Detail/__test__/index.test.js +3 -5
  143. package/src/screens/AllGateway/components/GatewayItem/__test__/index.test.js +3 -3
  144. package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +6 -6
  145. package/src/screens/AllGateway/hooks/__test__/index.test.js +2 -2
  146. package/src/screens/AllGateway/test-utils.js +3 -4
  147. package/src/screens/Automate/AddNewAction/ChooseAction.js +17 -3
  148. package/src/screens/Automate/AddNewAction/ChooseConfig.js +7 -6
  149. package/src/screens/Automate/AddNewAction/NewActionWrapper.js +8 -8
  150. package/src/screens/Automate/AddNewAction/SelectControlDevices.js +30 -20
  151. package/src/screens/Automate/AddNewAction/SelectMonitorDevices.js +17 -10
  152. package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +58 -44
  153. package/src/screens/Automate/AddNewAction/SetupScriptDelay.js +1 -1
  154. package/src/screens/Automate/AddNewAction/SetupScriptNotify.js +3 -3
  155. package/src/screens/Automate/AddNewAction/Styles/SetupSensorStyles.js +20 -4
  156. package/src/screens/Automate/AddNewAction/__test__/ChooseAction.test.js +12 -12
  157. package/src/screens/Automate/AddNewAction/__test__/SelectControlDevices.test.js +14 -8
  158. package/src/screens/Automate/AddNewAction/__test__/SelectMonitorDevices.test.js +13 -7
  159. package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +54 -15
  160. package/src/screens/Automate/AddNewAction/__test__/SetupScriptDelay.test.js +9 -9
  161. package/src/screens/Automate/AddNewAction/__test__/SetupScriptNotify.test.js +39 -10
  162. package/src/screens/Automate/AddNewAutoSmart/AddTypeSmart.js +10 -10
  163. package/src/screens/Automate/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +13 -8
  164. package/src/screens/Automate/Components/InputName.js +10 -7
  165. package/src/screens/Automate/EditActionsList/__tests__/UpdateActionScript.test.js +8 -8
  166. package/src/screens/Automate/EditActionsList/__tests__/UpdateDelayScript.test.js +6 -6
  167. package/src/screens/Automate/EditActionsList/__tests__/UpdateNotifyScript.test.js +7 -7
  168. package/src/screens/Automate/EditActionsList/index.js +19 -17
  169. package/src/screens/Automate/MultiUnits.js +19 -22
  170. package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +18 -8
  171. package/src/screens/Automate/Scenario/__test__/AddNewOneTap.test.js +15 -7
  172. package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +14 -6
  173. package/src/screens/Automate/ScriptDetail/Components/RenameScript.js +4 -7
  174. package/src/screens/Automate/ScriptDetail/__test__/index.test.js +56 -18
  175. package/src/screens/Automate/ScriptDetail/__test__/useStarredScript.test.js +6 -6
  176. package/src/screens/Automate/ScriptDetail/index.js +105 -41
  177. package/src/screens/Automate/SetSchedule/__test__/SelectWeekday.test.js +4 -4
  178. package/src/screens/Automate/SetSchedule/__test__/index.test.js +29 -18
  179. package/src/screens/Automate/SetSchedule/components/RowItem.js +5 -5
  180. package/src/screens/Automate/SetSchedule/index.js +8 -7
  181. package/src/screens/Automate/Styles/indexStyles.js +1 -1
  182. package/src/screens/Automate/__test__/MultiUnits.test.js +1 -4
  183. package/src/screens/Automate/__test__/index.test.js +0 -1
  184. package/src/screens/Automate/index.js +36 -34
  185. package/src/screens/ChangePosition/__test__/index.test.js +6 -6
  186. package/src/screens/ChangePosition/index.js +2 -1
  187. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +13 -13
  188. package/src/screens/Device/EditDevice/index.js +4 -4
  189. package/src/screens/Device/__test__/BluetoothDevice.test.js +300 -0
  190. package/src/screens/Device/__test__/detail.test.js +14 -14
  191. package/src/screens/Device/__test__/mqttDetail.test.js +9 -9
  192. package/src/screens/Device/components/BluetoothDevice.js +135 -0
  193. package/src/screens/Device/components/SensorDisplayItem.js +9 -8
  194. package/src/screens/Device/detail.js +70 -62
  195. package/src/screens/Device/hooks/useEvaluateValue.js +1 -1
  196. package/src/screens/Drawer/Drawer.test.js +2 -2
  197. package/src/screens/Drawer/index.js +3 -3
  198. package/src/screens/EmergencyContacts/EmergencyContactsList.js +8 -4
  199. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -3
  200. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -7
  201. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  202. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +8 -8
  203. package/src/screens/GuestInfo/components/RowGuestInfo.js +2 -2
  204. package/src/screens/GuestInfo/components/__test__/AccessScheduleSheet.test.js +3 -3
  205. package/src/screens/GuestInfo/index.js +2 -2
  206. package/src/screens/HanetCamera/ManageAccess.js +3 -3
  207. package/src/screens/HanetCamera/MemberInfo.js +2 -2
  208. package/src/screens/HanetCamera/__test__/Detail.test.js +9 -9
  209. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -10
  210. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -2
  211. package/src/screens/ManageAccess/index.js +3 -3
  212. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +9 -9
  213. package/src/screens/Notification/__test__/Notification.test.js +9 -9
  214. package/src/screens/Notification/components/NotificationItem.js +3 -4
  215. package/src/screens/Notification/index.js +3 -3
  216. package/src/screens/Notification/styles/NotificationItemStyles.js +0 -1
  217. package/src/screens/PlayBackCamera/__test__/index.test.js +1 -1
  218. package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +1 -1
  219. package/src/screens/ScanChipQR/components/QRScan/index.js +3 -3
  220. package/src/screens/SelectUnit/__test__/index.test.js +8 -8
  221. package/src/screens/SelectUnit/index.js +4 -4
  222. package/src/screens/SharedUnit/TabHeader.js +2 -2
  223. package/src/screens/Sharing/Components/EndDevice.js +3 -3
  224. package/src/screens/Sharing/UnitMemberList.js +2 -2
  225. package/src/screens/Sharing/__test__/UpdateShareDevice.test.js +7 -7
  226. package/src/screens/SideMenuDetail/__test__/index.test.js +8 -8
  227. package/src/screens/SmartAccount/Connecting/index.js +5 -5
  228. package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +8 -8
  229. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +7 -7
  230. package/src/screens/SmartAccount/SuccessfullyConnected/index.js +2 -2
  231. package/src/screens/SmartAccount/__test__/Connecting.test.js +6 -6
  232. package/src/screens/SmartAccount/__test__/SmartAccount.test.js +10 -10
  233. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +3 -2
  234. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +2 -2
  235. package/src/screens/SmartIr/components/SelectBrand.js +2 -2
  236. package/src/screens/SubUnit/AddSubUnit.js +28 -26
  237. package/src/screens/SubUnit/AddSubUnitStyles.js +10 -4
  238. package/src/screens/SubUnit/EditSubUnit.js +12 -11
  239. package/src/screens/SubUnit/ManageSubUnit.js +3 -3
  240. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +13 -13
  241. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +3 -3
  242. package/src/screens/Template/EditTemplate.js +6 -4
  243. package/src/screens/Template/__test__/EditTemplate.test.js +7 -7
  244. package/src/screens/Template/__test__/detail.test.js +4 -4
  245. package/src/screens/Template/__test__/index.test.js +1 -1
  246. package/src/screens/UVIndexGuide/index.js +2 -4
  247. package/src/screens/Unit/Detail.js +1 -5
  248. package/src/screens/Unit/MoreMenu.js +6 -5
  249. package/src/screens/Unit/SelectAddToFavorites.js +2 -2
  250. package/src/screens/Unit/SelectAddress.js +16 -12
  251. package/src/screens/Unit/Station/__test__/index.test.js +1 -1
  252. package/src/screens/Unit/__test__/MoreMenu.test.js +5 -1
  253. package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +9 -9
  254. package/src/screens/Unit/__test__/SelectAddress.test.js +11 -17
  255. package/src/screens/Unit/__test__/Summaries.test.js +7 -7
  256. package/src/screens/Unit/components/AutomateScript/index.js +5 -5
  257. package/src/screens/Unit/components/ButtonWrapper/index.js +3 -3
  258. package/src/screens/Unit/components/Header/index.js +2 -2
  259. package/src/screens/Unit/components/SharedUnit/index.js +5 -5
  260. package/src/screens/Unit/components/__test__/AutomateScript.test.js +3 -3
  261. package/src/screens/Unit/components/__test__/SharedUnit.test.js +8 -8
  262. package/src/screens/Unit/hook/__test__/useUnitConnectRemoteDevices.test.js +2 -2
  263. package/src/screens/UnitSummary/components/AirQuality/index.js +6 -11
  264. package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +5 -5
  265. package/src/screens/UnitSummary/index.js +6 -2
  266. package/src/utils/Apis/axios.js +5 -5
  267. package/src/utils/Functions/ShortEmail.js +1 -0
  268. package/src/utils/I18n/translations/en.js +6 -3
  269. package/src/utils/I18n/translations/vi.js +8 -4
  270. package/src/utils/__test__/Utils.test.js +16 -16
  271. package/src/utils/bluetooth.js +3 -0
  272. package/assets/images/OneTap.svg +0 -14
  273. package/assets/images/Schedule.svg +0 -39
  274. package/assets/images/ValueChange.svg +0 -49
@@ -25,9 +25,12 @@ const MultiUnits = () => {
25
25
  const isFocused = useIsFocused();
26
26
  const { navigate } = useNavigation();
27
27
  const { params = {}, name: currentRouteName } = useRoute();
28
- const { unit, newAutomate } = params;
28
+ const { unit = {} } = params;
29
+ const { id: unitId, name } = unit;
29
30
  const [data, setData] = useState([]);
30
31
  const permissions = useBackendPermission();
32
+ const { smart_script_for_multi_unit, max_automations_per_unit } =
33
+ permissions || {};
31
34
 
32
35
  const [tabActive, setTabActive] = useState(AUTOMATE_TABS.SCENARIO);
33
36
 
@@ -37,8 +40,8 @@ const MultiUnits = () => {
37
40
 
38
41
  const getData = useCallback(
39
42
  async (fetchParams) => {
40
- if (unit?.id) {
41
- await fetchWithCache(API.UNIT.AUTOMATE(unit?.id), {}, (response) => {
43
+ if (unitId) {
44
+ await fetchWithCache(API.UNIT.AUTOMATE(unitId), {}, (response) => {
42
45
  const { success, data: automateData } = response;
43
46
  success && setData(automateData);
44
47
  });
@@ -50,7 +53,7 @@ const MultiUnits = () => {
50
53
  success && setData(automateData);
51
54
  }
52
55
  },
53
- [unit?.id]
56
+ [unitId]
54
57
  );
55
58
 
56
59
  const onPressTabName = (tab) => () => {
@@ -62,32 +65,26 @@ const MultiUnits = () => {
62
65
  navigate(Routes.UnitStack, {
63
66
  screen: Routes.ScriptDetail,
64
67
  params: {
65
- id: item?.id,
66
- unitId: unit?.id,
67
68
  preAutomate: item,
68
69
  },
69
70
  });
70
71
  },
71
- [navigate, unit?.id]
72
+ [navigate]
72
73
  );
73
74
 
74
- useEffect(() => {
75
- newAutomate && onPressItem(newAutomate);
76
- }, [newAutomate, onPressItem]);
77
-
78
75
  const handleOnAddNew = useCallback(() => {
79
- if (unit?.id) {
80
- if (permissions?.max_automations_per_unit <= data.length) {
76
+ if (unitId) {
77
+ if (max_automations_per_unit <= data.length) {
81
78
  ToastBottomHelper.error(
82
79
  t('reach_max_automations_per_unit', {
83
- length: permissions.max_automations_per_unit,
80
+ length: max_automations_per_unit,
84
81
  }),
85
82
  '',
86
83
  7000
87
84
  );
88
85
  return;
89
86
  }
90
- } else if (!permissions?.smart_script_for_multi_unit) {
87
+ } else if (!smart_script_for_multi_unit) {
91
88
  ToastBottomHelper.error(
92
89
  t('no_permission_smart_script_for_multi_unit'),
93
90
  '',
@@ -99,7 +96,7 @@ const MultiUnits = () => {
99
96
  navigate(Routes.UnitStack, {
100
97
  screen: Routes.ScenarioName,
101
98
  params: {
102
- automate: { type: AUTOMATE_TYPE.ONE_TAP, unit: unit?.id },
99
+ automate: { type: AUTOMATE_TYPE.ONE_TAP, unit: unitId },
103
100
  closeScreen: currentRouteName,
104
101
  },
105
102
  });
@@ -107,9 +104,9 @@ const MultiUnits = () => {
107
104
  }
108
105
 
109
106
  navigate(Routes.UnitStack, {
110
- screen: Routes.AddUnknownTypeSmart,
107
+ screen: Routes.AddAutomationTypeSmart,
111
108
  params: {
112
- automate: { unit: unit?.id },
109
+ automate: { unit: unitId },
113
110
  closeScreen: currentRouteName,
114
111
  },
115
112
  });
@@ -117,11 +114,11 @@ const MultiUnits = () => {
117
114
  currentRouteName,
118
115
  data.length,
119
116
  navigate,
120
- permissions?.max_automations_per_unit,
121
- permissions?.smart_script_for_multi_unit,
117
+ max_automations_per_unit,
118
+ smart_script_for_multi_unit,
122
119
  t,
123
120
  tabActive,
124
- unit?.id,
121
+ unitId,
125
122
  ]);
126
123
 
127
124
  const renderContent = useMemo(() => {
@@ -166,7 +163,7 @@ const MultiUnits = () => {
166
163
  return (
167
164
  <View style={styles.wrap}>
168
165
  <WrapHeaderScrollable
169
- title={unit?.id ? unit?.name : t('multi_units_automate')}
166
+ title={unitId ? name : t('multi_units_automate')}
170
167
  headerAniStyle={styles.headerAniStyle}
171
168
  >
172
169
  <View style={styles.wrapContent}>
@@ -1,16 +1,16 @@
1
- import React from 'react';
2
1
  import MockAdapter from 'axios-mock-adapter';
2
+ import React from 'react';
3
3
  import { Platform, TextInput, TouchableOpacity } from 'react-native';
4
4
  import { act, create } from 'react-test-renderer';
5
5
 
6
- import AddNewOneTap from '../index';
6
+ import { useNavigation, useRoute } from '@react-navigation/native';
7
+ import { API } from '../../../../configs';
7
8
  import { AccessibilityLabel } from '../../../../configs/Constants';
8
9
  import { SCProvider } from '../../../../context';
9
10
  import { mockSCStore } from '../../../../context/mockStore';
10
- import Routes from '../../../../utils/Route';
11
11
  import api from '../../../../utils/Apis/axios';
12
- import { API } from '../../../../configs';
13
- import { useNavigation, useRoute } from '@react-navigation/native';
12
+ import Routes from '../../../../utils/Route';
13
+ import AddNewOneTap from '../index';
14
14
 
15
15
  const wrapComponent = (route) => {
16
16
  useRoute.mockReturnValue(route);
@@ -81,7 +81,8 @@ describe('test OneTap', () => {
81
81
  merge: true,
82
82
  name: Routes.ScriptDetail,
83
83
  params: {
84
- newAutomate: {
84
+ closeScreen: Routes.ScriptDetail,
85
+ preAutomate: {
85
86
  id: 1,
86
87
  script: { id: 1, name: 'William Miller' },
87
88
  type: 'one_tap',
@@ -114,7 +115,7 @@ describe('test OneTap', () => {
114
115
  await act(async () => {
115
116
  await item[0].props.onPress();
116
117
  });
117
- expect(global.mockedNavigate).not.toBeCalled();
118
+ expect(global.mockedNavigate).not.toHaveBeenCalled();
118
119
  });
119
120
 
120
121
  it('test onClose have automateId', async () => {
@@ -122,8 +123,13 @@ describe('test OneTap', () => {
122
123
  let route = {
123
124
  params: {
124
125
  closeScreen: Routes.ScriptDetail,
126
+ automate: {
127
+ unit: 1,
128
+ },
129
+ unitId: 1,
125
130
  },
126
131
  };
132
+
127
133
  mock.onPost(API.AUTOMATE.CREATE_AUTOMATE()).reply(400);
128
134
  await act(async () => {
129
135
  tree = await create(wrapComponent(route));
@@ -136,6 +142,10 @@ describe('test OneTap', () => {
136
142
  await act(async () => {
137
143
  header.props.onPress();
138
144
  });
139
- expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail);
145
+ expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail, {
146
+ unitId: 1,
147
+ automate: { unit: 1 },
148
+ closeScreen: Routes.ScriptDetail,
149
+ });
140
150
  });
141
151
  });
@@ -1,16 +1,16 @@
1
- import React from 'react';
2
1
  import MockAdapter from 'axios-mock-adapter';
2
+ import React from 'react';
3
3
  import { Platform, TextInput, TouchableOpacity } from 'react-native';
4
4
  import { act, create } from 'react-test-renderer';
5
5
 
6
- import ScenarioName from '../ScenarioName';
6
+ import { useNavigation, useRoute } from '@react-navigation/native';
7
+ import { API } from '../../../../configs';
7
8
  import { AccessibilityLabel } from '../../../../configs/Constants';
8
9
  import { SCProvider } from '../../../../context';
9
10
  import { mockSCStore } from '../../../../context/mockStore';
10
- import Routes from '../../../../utils/Route';
11
11
  import api from '../../../../utils/Apis/axios';
12
- import { API } from '../../../../configs';
13
- import { useNavigation, useRoute } from '@react-navigation/native';
12
+ import Routes from '../../../../utils/Route';
13
+ import ScenarioName from '../ScenarioName';
14
14
 
15
15
  const wrapComponent = (route) => {
16
16
  useRoute.mockReturnValue(route);
@@ -103,7 +103,7 @@ describe('test OneTap', () => {
103
103
  await act(async () => {
104
104
  await item[0].props.onPress();
105
105
  });
106
- expect(global.mockedNavigate).not.toBeCalled();
106
+ expect(global.mockedNavigate).not.toHaveBeenCalled();
107
107
  });
108
108
 
109
109
  it('test onClose have automateId', async () => {
@@ -111,6 +111,10 @@ describe('test OneTap', () => {
111
111
  let route = {
112
112
  params: {
113
113
  closeScreen: Routes.ScriptDetail,
114
+ automate: {
115
+ unit: 1,
116
+ },
117
+ unitId: 1,
114
118
  },
115
119
  };
116
120
  mock.onPost(API.AUTOMATE.CREATE_AUTOMATE()).reply(400);
@@ -125,6 +129,10 @@ describe('test OneTap', () => {
125
129
  await act(async () => {
126
130
  header.props.onPress();
127
131
  });
128
- expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail);
132
+ expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail, {
133
+ unitId: 1,
134
+ automate: { unit: 1 },
135
+ closeScreen: 'ScriptDetail',
136
+ });
129
137
  });
130
138
  });
@@ -11,7 +11,7 @@ import Event from '../../../../../assets/images/Event.svg';
11
11
  import Notify from '../../../../../assets/images/Notify.svg';
12
12
  import Delay from '../../../../../assets/images/Delay.svg';
13
13
  import { TouchableOpacity } from 'react-native';
14
- import AntDesign from 'react-native-vector-icons/AntDesign';
14
+ import { IconOutline } from '@ant-design/icons-react-native';
15
15
  import { Text } from '../../../../commons';
16
16
  import Routes from '../../../../utils/Route';
17
17
  import AccessibilityLabel from '../../../../configs/AccessibilityLabel';
@@ -40,6 +40,7 @@ const AddActionScript = memo(
40
40
  closeScreen: currentScreenName,
41
41
  numberActionCanAdd:
42
42
  max_actions_per_automation - numberActionAdded,
43
+ routeName: unit ? null : Routes.SelectControlDevices,
43
44
  };
44
45
 
45
46
  navigate(
@@ -54,10 +55,17 @@ const AddActionScript = memo(
54
55
  image: <Notify />,
55
56
  onClick: () => {
56
57
  setIsVisible(false);
57
- navigate(Routes.SetupScriptNotify, {
58
- automate,
59
- unitId: unit,
60
- });
58
+ if (unit) {
59
+ navigate(Routes.SetupScriptNotify, {
60
+ automate,
61
+ unitId: unit,
62
+ });
63
+ } else {
64
+ navigate(Routes.SelectUnit, {
65
+ automate,
66
+ routeName: Routes.SetupScriptNotify,
67
+ });
68
+ }
61
69
  },
62
70
  },
63
71
  {
@@ -109,7 +117,7 @@ const AddActionScript = memo(
109
117
  <View style={styles.wapItem}>
110
118
  <View style={styles.imageItem}>{item.image}</View>
111
119
  <Text style={styles.textItem}>{item.text}</Text>
112
- <AntDesign name="right" />
120
+ <IconOutline name="right" />
113
121
  </View>
114
122
  </TouchableOpacity>
115
123
  </View>
@@ -14,14 +14,11 @@ const RenameScript = ({ automate, setAutomate, isVisible, setIsVisible }) => {
14
14
  const transY = useKeyboardAnimated();
15
15
 
16
16
  const renameScript = useCallback(async () => {
17
- const { success, data: script } = await axiosPatch(
18
- API.AUTOMATE.SCRIPT(automate.id),
19
- {
20
- name: inputName,
21
- }
22
- );
17
+ const { success } = await axiosPatch(API.AUTOMATE.SCRIPT(automate.id), {
18
+ name: inputName,
19
+ });
23
20
  if (success) {
24
- setAutomate((prev) => ({ ...prev, name: script.name }));
21
+ setAutomate((prev) => ({ ...prev, name: inputName }));
25
22
  ToastBottomHelper.success(t('rename_successfully'));
26
23
  } else {
27
24
  ToastBottomHelper.error(t('rename_failed'));
@@ -8,7 +8,6 @@ import MockAdapter from 'axios-mock-adapter';
8
8
  import { SCProvider } from '../../../../context';
9
9
  import { mockSCStore } from '../../../../context/mockStore';
10
10
  import ScriptDetail from '../index';
11
- import MenuActionMore from '../../../../commons/MenuActionMore';
12
11
  import AlertAction from '../../../../commons/AlertAction';
13
12
  import _TextInput from '../../../../commons/Form/TextInput';
14
13
  import {
@@ -18,12 +17,12 @@ import {
18
17
  import { API } from '../../../../configs';
19
18
  import Routes from '../../../../utils/Route';
20
19
  import WrapHeaderScrollable from '../../../../commons/Sharing/WrapHeaderScrollable';
21
- import ItemAutomate from '../../../../commons/Automate/ItemAutomate';
22
20
  import api from '../../../../utils/Apis/axios';
23
21
  import Text from '../../../../commons/Text';
24
22
  import { ToastBottomHelper } from '../../../../utils/Utils';
25
23
  import { getTranslate } from '../../../../utils/I18n';
26
24
  import AddActionScript from '../Components/AddActionScript';
25
+ import ItemConditionScriptDetail from '../../../../commons/Automate/ItemConditionScriptDetail';
27
26
 
28
27
  const wrapComponent = (route, storeData = {}) => (
29
28
  <SCProvider initState={mockSCStore(storeData)}>
@@ -101,7 +100,10 @@ describe('Test ScriptDetail', () => {
101
100
  tree = await create(wrapComponent(route));
102
101
  });
103
102
  const instance = tree.root;
104
- const menu = instance.findByType(MenuActionMore);
103
+ const menu = instance.find(
104
+ (el) =>
105
+ el.props.accessibilityLabel === AccessibilityLabel.MENU_POPPER_MORE
106
+ );
105
107
  const alertAction = instance.findAllByType(AlertAction)[0];
106
108
  const rename = menu.props.listMenuItem[0];
107
109
 
@@ -127,7 +129,10 @@ describe('Test ScriptDetail', () => {
127
129
  tree = await create(wrapComponent(route));
128
130
  });
129
131
  const instance = tree.root;
130
- const menu = instance.findByType(MenuActionMore);
132
+ const menu = instance.find(
133
+ (el) =>
134
+ el.props.accessibilityLabel === AccessibilityLabel.MENU_POPPER_MORE
135
+ );
131
136
  const alertAction = instance.findAllByType(AlertAction)[0];
132
137
  const rename = menu.props.listMenuItem[0];
133
138
 
@@ -153,9 +158,9 @@ describe('Test ScriptDetail', () => {
153
158
  tree = await create(wrapComponent(route));
154
159
  });
155
160
  const instance = tree.root;
156
- const menu = instance.findByProps({
157
- accessibilityLabel: AccessibilityLabel.ICON_MORE,
158
- });
161
+ const menu = instance.find(
162
+ (el) => el.props.accessibilityLabel === AccessibilityLabel.ICON_MORE
163
+ );
159
164
 
160
165
  await act(async () => {
161
166
  await menu.props.onPress();
@@ -173,11 +178,25 @@ describe('Test ScriptDetail', () => {
173
178
  tree = await create(wrapComponent(route));
174
179
  });
175
180
  const instance = tree.root;
176
- const itemAutomate = instance.findByType(ItemAutomate);
181
+ const button = instance.find(
182
+ (el) =>
183
+ el.props.accessibilityLabel === AccessibilityLabel.ICON_MENU_POPUP &&
184
+ el.type === TouchableOpacity
185
+ );
186
+ await act(async () => {
187
+ await button.props.onPress();
188
+ });
189
+
190
+ const menuActionMore = instance.find(
191
+ (el) =>
192
+ el.props.accessibilityLabel === AccessibilityLabel.MENU_POPPER_MORE_2
193
+ );
177
194
 
178
195
  await act(async () => {
179
- await itemAutomate.props.onPress();
196
+ menuActionMore.props.onItemClick({ doAction: jest.fn() });
197
+ menuActionMore.props.listMenuItem[1].doAction();
180
198
  });
199
+
181
200
  expect(spyToastError).toBeCalledWith(
182
201
  getTranslate('en', 'only_owner_has_permission_to_edit_this_script')
183
202
  );
@@ -188,7 +207,10 @@ describe('Test ScriptDetail', () => {
188
207
  tree = await create(wrapComponent(route));
189
208
  });
190
209
  const instance = tree.root;
191
- const menu = instance.findByType(MenuActionMore);
210
+ const menu = instance.find(
211
+ (el) =>
212
+ el.props.accessibilityLabel === AccessibilityLabel.MENU_POPPER_MORE
213
+ );
192
214
  const alertAction = instance.findAllByType(AlertAction)[1];
193
215
  const deleteItem = menu.props.listMenuItem[2];
194
216
 
@@ -222,7 +244,10 @@ describe('Test ScriptDetail', () => {
222
244
  await act(async () => {
223
245
  await buttonStar.props.onPress();
224
246
  });
225
- const menu = instance.findByType(MenuActionMore);
247
+ const menu = instance.find(
248
+ (el) =>
249
+ el.props.accessibilityLabel === AccessibilityLabel.MENU_POPPER_MORE
250
+ );
226
251
  const addFavorite = menu.props.listMenuItem[1];
227
252
  mock.onPost(API.AUTOMATE.STAR_SCRIPT(1)).reply(200);
228
253
  await act(async () => {
@@ -308,6 +333,8 @@ describe('Test ScriptDetail', () => {
308
333
  unitId: route.params.preAutomate.unit,
309
334
  automateId: route.params.preAutomate.id,
310
335
  numberActionCanAdd: 2,
336
+ closeScreen: undefined,
337
+ routeName: null,
311
338
  }
312
339
  );
313
340
  mockedNavigate.mockClear();
@@ -344,7 +371,7 @@ describe('Test ScriptDetail', () => {
344
371
  const instance = tree.root;
345
372
  const switchButton = instance.findByType(Switch);
346
373
  await act(async () => {
347
- await switchButton.props.onChange(false);
374
+ await switchButton.props.onValueChange(false);
348
375
  });
349
376
  const buttonAddScript = instance.findAll(
350
377
  (el) =>
@@ -442,7 +469,10 @@ describe('Test ScriptDetail', () => {
442
469
  tree = await create(wrapComponent(route));
443
470
  });
444
471
  const instance = tree.root;
445
- const menu = instance.findByType(MenuActionMore);
472
+ const menu = instance.find(
473
+ (el) =>
474
+ el.props.accessibilityLabel === AccessibilityLabel.MENU_POPPER_MORE
475
+ );
446
476
  const gotoActivityLog = menu.props.listMenuItem[1];
447
477
 
448
478
  await act(async () => {
@@ -490,7 +520,7 @@ describe('Test ScriptDetail', () => {
490
520
  tree = await create(wrapComponent(route));
491
521
  });
492
522
  const instance = tree.root;
493
- const itemAutomate = instance.findByType(ItemAutomate);
523
+ const itemAutomate = instance.findByType(ItemConditionScriptDetail);
494
524
  expect(itemAutomate.findAllByType(Text)[1].props.children).toEqual(
495
525
  'Light Value higher than 3'
496
526
  );
@@ -498,6 +528,14 @@ describe('Test ScriptDetail', () => {
498
528
  await act(async () => {
499
529
  itemAutomate.findByType(TouchableOpacity).props.onPress();
500
530
  });
531
+ const menuActionMore = instance.find(
532
+ (el) =>
533
+ el.props.accessibilityLabel === AccessibilityLabel.MENU_POPPER_MORE_2
534
+ );
535
+ await act(async () => {
536
+ menuActionMore.props.onItemClick({ doAction: jest.fn() });
537
+ menuActionMore.props.listMenuItem[0].doAction();
538
+ });
501
539
  expect(global.mockedNavigate).toBeCalled();
502
540
  });
503
541
 
@@ -513,7 +551,7 @@ describe('Test ScriptDetail', () => {
513
551
  tree = await create(wrapComponent(route));
514
552
  });
515
553
  const instance = tree.root;
516
- const itemAutomate = instance.findByType(ItemAutomate);
554
+ const itemAutomate = instance.findByType(ItemConditionScriptDetail);
517
555
  expect(itemAutomate.findAllByType(Text)[1].props.children).toEqual(
518
556
  'Light Value equal 3'
519
557
  );
@@ -535,7 +573,7 @@ describe('Test ScriptDetail', () => {
535
573
  tree = await create(wrapComponent(route));
536
574
  });
537
575
  const instance = tree.root;
538
- const itemAutomate = instance.findByType(ItemAutomate);
576
+ const itemAutomate = instance.findByType(ItemConditionScriptDetail);
539
577
  expect(itemAutomate.findAllByType(Text)[1].props.children).toEqual(
540
578
  'Light Value lower than 3'
541
579
  );
@@ -557,7 +595,7 @@ describe('Test ScriptDetail', () => {
557
595
  tree = await create(wrapComponent(route));
558
596
  });
559
597
  const instance = tree.root;
560
- const itemAutomate = instance.findByType(ItemAutomate);
598
+ const itemAutomate = instance.findByType(ItemConditionScriptDetail);
561
599
  expect(itemAutomate.findAllByType(Text)[1].props.children).toEqual(
562
600
  'Every day at 19:00'
563
601
  );
@@ -580,7 +618,7 @@ describe('Test ScriptDetail', () => {
580
618
  tree = await create(wrapComponent(route));
581
619
  });
582
620
  const instance = tree.root;
583
- const itemAutomate = instance.findByType(ItemAutomate);
621
+ const itemAutomate = instance.findByType(ItemConditionScriptDetail);
584
622
  expect(itemAutomate.findAllByType(Text)[1].props.children).toEqual(
585
623
  'Mon, Tue, Thu, Sat at 19:00'
586
624
  );
@@ -1,12 +1,12 @@
1
- import React from 'react';
2
1
  import { act, renderHook } from '@testing-library/react-hooks';
3
- import { SCProvider } from '../../../../context';
4
- import { mockSCStore } from '../../../../context/mockStore';
5
- import { useStarredScript } from '../hooks/useStarredScript';
6
2
  import MockAdapter from 'axios-mock-adapter';
7
- import api from '../../../../utils/Apis/axios';
3
+ import React from 'react';
8
4
  import { API } from '../../../../configs';
5
+ import { SCProvider } from '../../../../context';
9
6
  import { Action } from '../../../../context/actionType';
7
+ import { mockSCStore } from '../../../../context/mockStore';
8
+ import api from '../../../../utils/Apis/axios';
9
+ import { useStarredScript } from '../hooks/useStarredScript';
10
10
 
11
11
  const mockedSetAction = jest.fn();
12
12
  const mock = new MockAdapter(api.axiosInstance);
@@ -42,6 +42,6 @@ describe('Test useStarredScript', () => {
42
42
  await act(async () => {
43
43
  await result.current.unstarScript();
44
44
  });
45
- expect(mockedSetAction).toBeCalledWith(Action.UNSTAR_SCRIPTS, [2]);
45
+ expect(mockedSetAction).toHaveBeenCalledWith(Action.UNSTAR_SCRIPTS, [2]);
46
46
  });
47
47
  });