@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.
- package/package.json +1 -1
- package/src/Images/Common/reorder.svg +3 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/AutoLockStyles.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +3 -1
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +3 -10
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +1 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/SetupGeneratePasscodeStyles.js +1 -1
- package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +13 -5
- package/src/commons/ActionGroup/SliderRangeTemplate.js +100 -69
- package/src/commons/ActionGroup/SliderRangeTemplateStyles.js +27 -27
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +4 -1
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +1 -1
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +4 -1
- package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +56 -0
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +2 -2
- package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +45 -8
- package/src/commons/ActionGroup/__test__/index.test.js +0 -19
- package/src/commons/ActionGroup/index.js +0 -3
- package/src/commons/ActionTemplate/CurtainAction.js +5 -5
- package/src/commons/ActionTemplate/CurtainActionStyles.js +1 -1
- package/src/commons/ActionTemplate/OnOffButtonAction.js +4 -4
- package/src/commons/ActionTemplate/OnOffButtonActionStyles.js +1 -1
- package/src/commons/ActionTemplate/OnOffSimpleAction.js +4 -4
- package/src/commons/ActionTemplate/OnOffSimpleActionStyles.js +1 -1
- package/src/commons/ActionTemplate/OnOffSmartLockAction.js +4 -4
- package/src/commons/ActionTemplate/OnOffSmartLockActionStyles.js +1 -1
- package/src/commons/ActionTemplate/OneButtonAction.js +3 -3
- package/src/commons/ActionTemplate/OneButtonActionStyles.js +1 -1
- package/src/commons/ActionTemplate/ThreeButtonAction.js +5 -5
- package/src/commons/ActionTemplate/ThreeButtonActionStyles.js +1 -1
- package/src/commons/ActionTemplate/__test__/CurtainAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/OnOffSimpleAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/OnOffSmartLockAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/OneButtonAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/ThreeButtonAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/index.test.js +21 -70
- package/src/commons/ActionTemplate/index.js +19 -55
- package/src/commons/Alert/__test__/Alert.test.js +1 -1
- package/src/commons/Auth/AccountList.js +1 -1
- package/src/commons/Auth/__test__/OtpInputList.test.js +17 -19
- package/src/commons/Automate/ItemAutomate.js +10 -4
- package/src/commons/Automate/__test__/ItemAutomate.test.js +11 -11
- package/src/commons/BackDefault/__test__/BackDefault.test.js +1 -1
- package/src/commons/Button/__test__/Button.test.js +1 -1
- package/src/commons/ButtonPopup/__test__/ButtonPopup.test.js +1 -1
- package/src/commons/Calendar/__test__/Calendar.test.js +1 -1
- package/src/commons/ChartLoading/__test__/ChartLoading.test.js +1 -1
- package/src/commons/CircleButton/__test__/CircleButton.test.js +1 -1
- package/src/commons/CircleView/__test__/CircleView.test.js +1 -1
- package/src/commons/DateTimeRangeChange/__test__/DateTimeButton.test.js +4 -2
- package/src/commons/DateTimeRangeChange/index.js +31 -48
- package/src/commons/Device/DeviceAlertStatus.js +2 -1
- package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +2 -2
- package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +1 -1
- package/src/commons/Device/FlatListItems.js +1 -1
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +2 -2
- package/src/commons/Device/HistoryChart.js +6 -49
- package/src/commons/Device/LinearChart/LinearChart.test.js +1 -1
- package/src/commons/Device/ProgressBar/__test__/ProgressBar.test.js +1 -1
- package/src/commons/Device/ProgressBar/index.js +5 -11
- package/src/commons/Device/ProgressBar/styles.js +11 -3
- package/src/commons/Device/RainningSensor/__test__/CurrentRainSensor.test.js +5 -5
- package/src/commons/Device/SonosSpeaker/__test__/SonosSpeaker.test.js +3 -3
- package/src/commons/Device/WindDirection/Compass/Compass.test.js +2 -2
- package/src/commons/Device/WindSpeed/Anemometer/index.js +2 -0
- package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +14 -1
- package/src/commons/Device/WindSpeed/LinearChart/index.js +5 -3
- package/src/commons/Device/__test__/DeviceAlertStatus.test.js +3 -3
- package/src/commons/Device/__test__/DisconnectedView.test.js +2 -2
- package/src/commons/Device/__test__/FlatListItems.test.js +1 -1
- package/src/commons/Device/__test__/SensorConnectedStatus.test.js +1 -1
- package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +1 -1
- package/src/commons/FlatListDnD/__test__/index.test.js +49 -0
- package/src/commons/FlatListDnD/index.js +37 -0
- package/src/commons/FlatListDnD/styles.js +12 -0
- package/src/commons/Form/__test__/CurrencyInput.test.js +2 -2
- package/src/commons/Form/__test__/TextInput.test.js +3 -3
- package/src/commons/Form/__test__/TextInputPassword.test.js +2 -2
- package/src/commons/FullLoading/__test__/index.test.js +2 -2
- package/src/commons/Header/HeaderCustom.js +2 -1
- package/src/commons/HorizontalPicker/index.js +65 -38
- package/src/commons/IconComponent/index.js +3 -2
- package/src/commons/ImageButton/__test__/ImageButton.test.js +1 -1
- package/src/commons/MediaPlayer/__test__/index.test.js +8 -3
- package/src/commons/MediaPlayer/index.js +11 -7
- package/src/commons/MenuActionMore/index.js +6 -4
- package/src/commons/Modal/ModalBottom.js +2 -3
- package/src/commons/Modal/ModalCustom.js +2 -3
- package/src/commons/NavBar/index.js +48 -50
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplateStyles.js +1 -1
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +5 -5
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplateStyles.js +1 -1
- package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +5 -5
- package/src/commons/OneTapTemplate/StatesGridActionTemplateStyles.js +1 -1
- package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +2 -2
- package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +1 -1
- package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +2 -2
- package/src/commons/PreventAccess/index.js +1 -1
- package/src/commons/RowItem/__test__/RowItem.test.js +1 -1
- package/src/commons/RowUser/__test__/RowUser.test.js +1 -1
- package/src/commons/Section/Section.test.js +2 -2
- package/src/commons/SelectSubUnit/__test__/SelectSubUnit.test.js +1 -1
- package/src/commons/SelectUnit/__test__/SelectUnit.test.js +3 -3
- package/src/commons/Sharing/StationDevicePermissions.js +4 -4
- package/src/commons/Sharing/WrapHeaderScrollable.js +5 -5
- package/src/commons/Sharing/__test__/ButtonRemoveMember.test.js +1 -1
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +3 -3
- package/src/commons/Sharing/__test__/MemberList.test.js +6 -4
- package/src/commons/Sharing/__test__/RowMember.test.js +2 -2
- package/src/commons/Sharing/__test__/WrapHeaderScrollable.test.js +4 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +7 -11
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +13 -16
- package/src/commons/SubUnit/OneTap/index.js +22 -7
- package/src/commons/TextButton/__test__/TextButton.test.js +2 -2
- package/src/commons/Today/__test__/Today.test.js +1 -1
- package/src/commons/TouchableScale/__test__/TouchableScale.test.js +1 -1
- package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +4 -0
- package/src/commons/UnitSummary/AirQuality/index.js +2 -2
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +1 -1
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +0 -6
- package/src/commons/UnitSummary/__test__/TotalPowerBox.test.js +1 -1
- package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +1 -1
- package/src/commons/ViewButtonBottom/__test__/ViewButtonBottom.test.js +1 -1
- package/src/configs/API.js +14 -31
- package/src/configs/AccessibilityLabel.js +1 -0
- package/src/configs/Colors.js +1 -1
- package/src/configs/Constants.js +14 -48
- package/src/context/reducer.ts +3 -1
- package/src/hoc/__test__/withRemoteControl.test.js +1 -1
- package/src/hooks/Common/__test__/useStatusbar.test.js +5 -5
- package/src/hooks/Common/index.js +0 -2
- package/src/hooks/Common/useKeyboardShow.js +4 -4
- package/src/hooks/Common/useStatusBar.js +2 -2
- package/src/hooks/Common/useTitleHeader.js +5 -7
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +11 -0
- package/src/hooks/IoT/useBluetoothConnection.js +6 -3
- package/src/hooks/index.js +1 -2
- package/src/navigations/UnitStack.js +51 -17
- package/src/screens/ActivityLog/FilterPopup.js +4 -4
- package/src/screens/ActivityLog/__test__/FilterPopup.test.js +2 -2
- package/src/screens/ActivityLog/__test__/index.test.js +2 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +3 -3
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +5 -5
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +9 -33
- package/src/screens/AddNewAutoSmart/index.js +33 -89
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectRouterGuide.test.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +1 -1
- package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +1 -2
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +5 -17
- package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +1 -1
- package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +2 -2
- package/src/screens/AddNewGateway/__test__/ScanModbusQR.test.js +3 -3
- package/src/screens/AddNewGateway/__test__/ScanWifiDeviceQR.test.js +2 -2
- package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +8 -16
- package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +10 -12
- package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -14
- package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -14
- package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +1 -1
- package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +3 -2
- package/src/screens/AddNewGateway/index.js +1 -1
- package/src/screens/AllCamera/__test__/index.test.js +18 -57
- package/src/screens/AllCamera/index.js +100 -33
- package/src/screens/AllGateway/DetailConfigActionZigbee/__test__/index.test.js +0 -18
- package/src/screens/AllGateway/DetailConfigActionZigbee/index.js +1 -1
- package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +5 -2
- package/src/screens/AllGateway/hooks/__test__/index.test.js +1 -1
- package/src/screens/Automate/AddNewAction/ChooseAction.js +139 -0
- package/src/screens/Automate/AddNewAction/ChooseConfig.js +179 -0
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/LoadingSelectAction.js +1 -1
- package/src/screens/Automate/AddNewAction/Components/SelectDevices.js +75 -0
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/DeviceStyles.js +5 -1
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/__test__/index.test.js +4 -4
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/index.js +5 -4
- package/src/screens/Automate/AddNewAction/NewActionWrapper.js +56 -0
- package/src/screens/Automate/AddNewAction/SelectControlDevices.js +69 -0
- package/src/screens/Automate/AddNewAction/SelectMonitorDevices.js +110 -0
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +196 -0
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SelectActionStyles.js +1 -1
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SelectSensorDevicesStyles.js +1 -1
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Styles/SetupSensorStyles.js +5 -3
- package/src/screens/{AddNewAction/__test__/SelectAction.test.js → Automate/AddNewAction/__test__/ChooseAction.test.js} +101 -122
- package/src/screens/Automate/AddNewAction/__test__/ChooseConfig.test.js +210 -0
- package/src/screens/Automate/AddNewAction/__test__/SelectControlDevices.test.js +130 -0
- package/src/screens/Automate/AddNewAction/__test__/SelectMonitorDevices.test.js +92 -0
- package/src/screens/Automate/AddNewAction/__test__/SetupSensor.test.js +131 -0
- package/src/screens/Automate/Components/InputName.js +64 -0
- package/src/screens/{AddNewOneTap/AddNewOneTapStyles.js → Automate/Components/InputNameStyles.js} +2 -2
- package/src/screens/{EditActionsList → Automate/EditActionsList}/Styles/indexStyles.js +5 -1
- package/src/screens/{EditActionsList → Automate/EditActionsList}/__tests__/index.test.js +20 -12
- package/src/screens/{EditActionsList → Automate/EditActionsList}/index.js +18 -19
- package/src/screens/Automate/MultiUnits.js +70 -68
- package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +134 -0
- package/src/screens/Automate/OneTap/index.js +16 -0
- package/src/screens/Automate/Scenario/ScenarioName.js +15 -0
- package/src/screens/{AddNewOneTap → Automate/Scenario}/__test__/AddNewOneTap.test.js +27 -45
- package/src/screens/Automate/ScriptDetail/Components/DeleteScript.js +45 -0
- package/src/screens/Automate/ScriptDetail/Components/RenameScript.js +58 -0
- package/src/screens/{ScriptDetail → Automate/ScriptDetail}/Styles/indexStyles.js +1 -1
- package/src/screens/{ScriptDetail → Automate/ScriptDetail}/__test__/index.test.js +67 -76
- package/src/screens/{ScriptDetail → Automate/ScriptDetail}/__test__/useStarredScript.test.js +7 -6
- package/src/screens/{ScriptDetail → Automate/ScriptDetail}/hooks/useStarredScript.js +4 -4
- package/src/screens/Automate/ScriptDetail/index.js +346 -0
- package/src/screens/Automate/ScriptDetail/utils.js +113 -0
- package/src/screens/{SetSchedule → Automate/SetSchedule}/__test__/SelectWeekday.test.js +2 -2
- package/src/screens/{SetSchedule → Automate/SetSchedule}/__test__/index.test.js +21 -46
- package/src/screens/{SetSchedule → Automate/SetSchedule}/components/RepeatOptionsPopup.js +4 -4
- package/src/screens/{SetSchedule → Automate/SetSchedule}/components/RowItem.js +2 -2
- package/src/screens/{SetSchedule → Automate/SetSchedule}/components/SelectWeekday.js +3 -3
- package/src/screens/Automate/SetSchedule/index.js +140 -0
- package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/RepeatOptionsPopupStyles.js +1 -1
- package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/RowItemStyles.js +1 -1
- package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/SelectWeekdayStyles.js +1 -1
- package/src/screens/{SetSchedule → Automate/SetSchedule}/styles/indexStyles.js +1 -1
- package/src/screens/Automate/ValueChange/ValueChangeName.js +16 -0
- package/src/screens/Automate/__test__/MultiUnits.test.js +78 -122
- package/src/screens/Automate/__test__/index.test.js +21 -47
- package/src/screens/Automate/constants.js +0 -0
- package/src/screens/Automate/index.js +18 -24
- package/src/screens/ChangePosition/__test__/index.test.js +75 -0
- package/src/screens/ChangePosition/index.js +112 -0
- package/src/screens/ChangePosition/styles.js +87 -0
- package/src/screens/Device/__test__/DetailHistoryChart.test.js +2 -2
- package/src/screens/Device/__test__/EmergencyCountdown.test.js +4 -2
- package/src/screens/Device/__test__/detail.test.js +202 -257
- package/src/screens/Device/__test__/sensorDisplayItem.test.js +14 -10
- package/src/screens/Device/components/ChartWrapper.js +3 -3
- package/src/screens/Device/components/SensorDisplayItem.js +2 -1
- package/src/screens/Device/components/VisualChart.js +56 -9
- package/src/screens/Device/components/__test__/VisualChart.test.js +1 -1
- package/src/screens/Device/detail.js +14 -0
- package/src/screens/Device/hooks/__test__/useEmergencyButton.test.js +35 -13
- package/src/screens/Device/hooks/useEvaluateValue.js +28 -2
- package/src/screens/Device/styles.js +7 -0
- package/src/screens/DeviceInfo/__test__/index.test.js +16 -18
- package/src/screens/DeviceInfo/index.js +6 -5
- package/src/screens/GuestInfo/components/__test__/AccessScheduleSheet.test.js +52 -0
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +18 -13
- package/src/screens/Notification/__test__/Notification.test.js +64 -73
- package/src/screens/Notification/index.js +14 -14
- package/src/screens/PlayBackCamera/index.js +2 -3
- package/src/screens/SelectUnit/__test__/index.test.js +0 -5
- package/src/screens/SelectUnit/index.js +1 -2
- package/src/screens/SharedUnit/index.js +5 -4
- package/src/screens/Sharing/Components/TitleCheckBox.js +2 -2
- package/src/screens/Sharing/SelectUser.js +2 -2
- package/src/screens/Sharing/__test__/MemberList.test.js +9 -15
- package/src/screens/Sharing/__test__/MemberList2.test.js +10 -16
- package/src/screens/Sharing/__test__/SelectUser.test.js +8 -4
- package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +1 -1
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +3 -3
- package/src/screens/SmartAccount/__test__/Connecting.test.js +1 -1
- package/src/screens/SmartAccount/__test__/SmartAccount.test.js +3 -3
- package/src/screens/SmartAccount/index.js +1 -0
- package/src/screens/SmartIr/__test__/ButtonsBottom.test.js +1 -1
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +5 -5
- package/src/screens/SmartIr/__test__/SelectBrand.test.js +2 -2
- package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +2 -2
- package/src/screens/SmartIr/__test__/SmartIr.test.js +2 -2
- package/src/screens/SubUnit/ManageSubUnit.js +4 -4
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +9 -28
- package/src/screens/TDSGuide/index.js +1 -1
- package/src/screens/Template/GatewayList.js +4 -1
- package/src/screens/Template/__test__/detail.test.js +24 -22
- package/src/screens/Template/detail.js +1 -0
- package/src/screens/UVIndexGuide/index.js +2 -2
- package/src/screens/Unit/Detail.js +6 -5
- package/src/screens/Unit/SelectAddToFavorites.js +1 -1
- package/src/screens/Unit/__test__/ChooseLocation.test.js +8 -13
- package/src/screens/Unit/__test__/Detail.test.js +10 -14
- package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +1 -1
- package/src/screens/Unit/__test__/SmartAccount.test.js +8 -14
- package/src/screens/Unit/components/__test__/Header.test.js +4 -4
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +1 -1
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +14 -6
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +1 -1
- package/src/screens/UnitSummary/components/Temperature/index.js +2 -2
- package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +4 -0
- package/src/screens/UnitSummary/components/UvIndex/index.js +2 -2
- package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +6 -11
- package/src/screens/UnitSummary/components/WaterQuality/index.js +2 -2
- package/src/screens/UnitSummary/components/__test__/TotalPowerBox.test.js +1 -1
- package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +1 -1
- package/src/screens/UnitSummary/components/__test__/index.test.js +2 -2
- package/src/screens/WaterQualityGuide/index.js +10 -5
- package/src/utils/Apis/axios.js +3 -0
- package/src/utils/I18n/translations/en.json +24 -18
- package/src/utils/I18n/translations/vi.json +22 -18
- package/src/utils/Route/index.js +9 -3
- package/src/utils/Utils.js +29 -0
- package/src/utils/__test__/Utils.test.js +6 -0
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +0 -130
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +0 -109
- package/src/commons/Auth/SocialButton.js +0 -54
- package/src/commons/Auth/__test__/SocialButton.test.js +0 -44
- package/src/commons/Sharing/__test__/StationDevicePermission.test.js +0 -85
- package/src/hooks/__test__/useInitDeepLink.test.js +0 -28
- package/src/hooks/useInitDeepLink.js +0 -25
- package/src/screens/AddNewAction/SelectAction.js +0 -570
- package/src/screens/AddNewAction/SelectSensorDevices.js +0 -236
- package/src/screens/AddNewAction/SetupSensor.js +0 -263
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +0 -181
- package/src/screens/AddNewAction/__test__/SetupSensor.test.js +0 -114
- package/src/screens/AddNewOneTap/index.js +0 -147
- package/src/screens/ScriptDetail/hooks/index.js +0 -136
- package/src/screens/ScriptDetail/index.js +0 -525
- package/src/screens/SetSchedule/index.js +0 -200
- /package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/index.js +0 -0
- /package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/LoadingSelectAction.test.js +0 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { useNavigation } from '@react-navigation/native';
|
|
4
|
+
|
|
5
|
+
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
6
|
+
import ActionTemplate from '../../../commons/ActionTemplate';
|
|
7
|
+
import NumberUpDownActionTemplate from '../../../commons/OneTapTemplate/NumberUpDownActionTemplate';
|
|
8
|
+
import OptionsDropdownActionTemplate from '../../../commons/OneTapTemplate/OptionsDropdownActionTemplate';
|
|
9
|
+
import StatesGridActionTemplate from '../../../commons/OneTapTemplate/StatesGridActionTemplate';
|
|
10
|
+
import { axiosGet, axiosPost } from '../../../utils/Apis/axios';
|
|
11
|
+
import { API } from '../../../configs';
|
|
12
|
+
import Routes from '../../../utils/Route';
|
|
13
|
+
import NewActionWrapper from './NewActionWrapper';
|
|
14
|
+
import moment from 'moment';
|
|
15
|
+
|
|
16
|
+
const RenderActionItem = ({ device, item, handleOnSelectAction }) => {
|
|
17
|
+
switch (item.template) {
|
|
18
|
+
case 'on_off_button_action_template':
|
|
19
|
+
case 'one_button_action_template':
|
|
20
|
+
case 'three_button_action_template':
|
|
21
|
+
case 'OnOffSimpleActionTemplate':
|
|
22
|
+
case 'curtain_action_template':
|
|
23
|
+
case 'OnOffSmartLockActionTemplate':
|
|
24
|
+
return (
|
|
25
|
+
<ActionTemplate
|
|
26
|
+
device={device}
|
|
27
|
+
item={item}
|
|
28
|
+
onSelectAction={handleOnSelectAction}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
case 'OptionsDropdownActionTemplate':
|
|
32
|
+
return (
|
|
33
|
+
<OptionsDropdownActionTemplate
|
|
34
|
+
key={item.id}
|
|
35
|
+
device={device}
|
|
36
|
+
item={item}
|
|
37
|
+
onSelectAction={handleOnSelectAction}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
case 'NumberUpDownActionTemplate':
|
|
41
|
+
return (
|
|
42
|
+
<NumberUpDownActionTemplate
|
|
43
|
+
key={item.id}
|
|
44
|
+
device={device}
|
|
45
|
+
item={item}
|
|
46
|
+
onSelectAction={handleOnSelectAction}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
case 'StatesGridActionTemplate':
|
|
50
|
+
return (
|
|
51
|
+
<StatesGridActionTemplate
|
|
52
|
+
key={item.id}
|
|
53
|
+
device={device}
|
|
54
|
+
item={item}
|
|
55
|
+
onSelectAction={handleOnSelectAction}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
default:
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const ChooseAction = ({ route }) => {
|
|
64
|
+
const t = useTranslations();
|
|
65
|
+
const { navigate } = useNavigation();
|
|
66
|
+
const { unitId, device, automateId, index = -1 } = route?.params || {};
|
|
67
|
+
const [data, setData] = useState([]);
|
|
68
|
+
const [actions, setActions] = useState([]);
|
|
69
|
+
|
|
70
|
+
const fetchData = useCallback(async () => {
|
|
71
|
+
const { success, data: automateData } = await axiosGet(
|
|
72
|
+
API.DEVICE.DISPLAY_ACTIONS(device.id)
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
if (success) {
|
|
76
|
+
setData(automateData);
|
|
77
|
+
}
|
|
78
|
+
}, [device.id]);
|
|
79
|
+
|
|
80
|
+
const onSave = useCallback(async () => {
|
|
81
|
+
let list_action = [...actions];
|
|
82
|
+
list_action = list_action.map((item) => ({
|
|
83
|
+
action: item.action,
|
|
84
|
+
data: item.data,
|
|
85
|
+
}));
|
|
86
|
+
const { success } = await axiosPost(
|
|
87
|
+
API.AUTOMATE.ADD_SCRIPT_ACTION(automateId),
|
|
88
|
+
{
|
|
89
|
+
list_action,
|
|
90
|
+
unit: unitId,
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
success &&
|
|
95
|
+
navigate({
|
|
96
|
+
name: Routes.ScriptDetail,
|
|
97
|
+
merge: true,
|
|
98
|
+
params: { saveAt: moment().valueOf() },
|
|
99
|
+
});
|
|
100
|
+
}, [actions, navigate, unitId, automateId]);
|
|
101
|
+
|
|
102
|
+
const handleOnSelectAction = (action) => {
|
|
103
|
+
let newActions = [...actions];
|
|
104
|
+
|
|
105
|
+
if (index < 0) {
|
|
106
|
+
newActions.push(action);
|
|
107
|
+
} else {
|
|
108
|
+
newActions[index] = action; // todo Bang this case is not happening?
|
|
109
|
+
}
|
|
110
|
+
setActions(newActions);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
fetchData();
|
|
115
|
+
}, [fetchData]);
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<NewActionWrapper
|
|
119
|
+
canNext={actions.length}
|
|
120
|
+
onNext={onSave}
|
|
121
|
+
nextTitle={t('save')}
|
|
122
|
+
title={t('choose_action')}
|
|
123
|
+
name={t('set_up {name}', { name: device?.name })}
|
|
124
|
+
>
|
|
125
|
+
<View>
|
|
126
|
+
{!!data?.length &&
|
|
127
|
+
data.map((item) => (
|
|
128
|
+
<RenderActionItem
|
|
129
|
+
device={device}
|
|
130
|
+
item={item}
|
|
131
|
+
key={item.id}
|
|
132
|
+
handleOnSelectAction={handleOnSelectAction}
|
|
133
|
+
/>
|
|
134
|
+
))}
|
|
135
|
+
</View>
|
|
136
|
+
</NewActionWrapper>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
export default ChooseAction;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { Image, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import { useNavigation } from '@react-navigation/native';
|
|
4
|
+
|
|
5
|
+
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
6
|
+
import Text from '../../../commons/Text';
|
|
7
|
+
import { axiosGet } from '../../../utils/Apis/axios';
|
|
8
|
+
import { API, Colors, Images } from '../../../configs';
|
|
9
|
+
import Routes from '../../../utils/Route';
|
|
10
|
+
import styles from './Styles/SelectActionStyles';
|
|
11
|
+
import { TitleCheckBox } from '../../Sharing/Components';
|
|
12
|
+
import { LoadingSelectAction } from './Components';
|
|
13
|
+
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
14
|
+
import {
|
|
15
|
+
generateAutomationConditionText,
|
|
16
|
+
generateAutomationDataConditionText,
|
|
17
|
+
} from '../ScriptDetail/utils';
|
|
18
|
+
import { useSCContextSelector } from '../../../context';
|
|
19
|
+
import { AUTOMATE_TYPE } from '../../../configs/Constants';
|
|
20
|
+
import NewActionWrapper from './NewActionWrapper';
|
|
21
|
+
|
|
22
|
+
const ChooseConfig = ({ route }) => {
|
|
23
|
+
const t = useTranslations();
|
|
24
|
+
const { navigate } = useNavigation();
|
|
25
|
+
const {
|
|
26
|
+
device,
|
|
27
|
+
automate = {},
|
|
28
|
+
newCondition,
|
|
29
|
+
closeScreen,
|
|
30
|
+
} = route?.params || {};
|
|
31
|
+
|
|
32
|
+
const [configs, setConfigs] = useState([]);
|
|
33
|
+
const [checkedItem, setCheckedItem] = useState({ id: automate?.config_id });
|
|
34
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
35
|
+
const valueEvaluations = useSCContextSelector((state) => {
|
|
36
|
+
return state.valueEvaluations;
|
|
37
|
+
});
|
|
38
|
+
const [conditions, setConditions] = useState({});
|
|
39
|
+
const fetchData = useCallback(async () => {
|
|
40
|
+
setIsLoading(true);
|
|
41
|
+
const params = {};
|
|
42
|
+
if (automate?.type === AUTOMATE_TYPE.EVENT) {
|
|
43
|
+
params.type = 'event';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const { success, data: automateData } = await axiosGet(
|
|
47
|
+
API.AUTOMATE.DISPLAY_CONFIGS(device.id),
|
|
48
|
+
{ params }
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
if (success) {
|
|
52
|
+
setConfigs(automateData);
|
|
53
|
+
}
|
|
54
|
+
setIsLoading(false);
|
|
55
|
+
}, [device.id, automate?.type]);
|
|
56
|
+
|
|
57
|
+
const onSave = useCallback(() => {
|
|
58
|
+
let condition = conditions[checkedItem?.id];
|
|
59
|
+
const isDefault =
|
|
60
|
+
automate?.config_id && automate?.config_id === checkedItem?.id;
|
|
61
|
+
if (!condition && !isDefault) {
|
|
62
|
+
ToastBottomHelper.error(t('please_choose_condition_before_continue'));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
navigate(Routes.ValueChangeName, {
|
|
67
|
+
automate: {
|
|
68
|
+
...automate,
|
|
69
|
+
...condition,
|
|
70
|
+
},
|
|
71
|
+
closeScreen,
|
|
72
|
+
});
|
|
73
|
+
}, [conditions, checkedItem?.id, navigate, automate, closeScreen, t]);
|
|
74
|
+
|
|
75
|
+
const onChecked = useCallback(
|
|
76
|
+
(_, isChecked, id) => {
|
|
77
|
+
setCheckedItem(isChecked ? configs.find((i) => i?.id === id) : {});
|
|
78
|
+
},
|
|
79
|
+
[configs]
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const onPressItem = (item) => () => {
|
|
83
|
+
navigate(Routes.SetupConfigCondition, {
|
|
84
|
+
item,
|
|
85
|
+
defaultCondition: conditions[item.id],
|
|
86
|
+
closeScreen,
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const renderCondition = useCallback(
|
|
91
|
+
(item) => {
|
|
92
|
+
return generateAutomationDataConditionText(
|
|
93
|
+
automate?.type,
|
|
94
|
+
item.name,
|
|
95
|
+
conditions[item.id],
|
|
96
|
+
item.value_evaluation || {
|
|
97
|
+
// backward compatible
|
|
98
|
+
template: item.evaluate_template,
|
|
99
|
+
configuration: item.evaluate_configuration,
|
|
100
|
+
},
|
|
101
|
+
t
|
|
102
|
+
);
|
|
103
|
+
},
|
|
104
|
+
[automate?.type, conditions, t]
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
fetchData();
|
|
109
|
+
}, [fetchData]);
|
|
110
|
+
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
newCondition &&
|
|
113
|
+
setConditions((prev) => ({
|
|
114
|
+
...prev,
|
|
115
|
+
[newCondition.config]: newCondition,
|
|
116
|
+
}));
|
|
117
|
+
}, [newCondition]);
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<NewActionWrapper
|
|
121
|
+
name={t('set_up {name}', { name: device?.name })}
|
|
122
|
+
nextTitle={t('continue')}
|
|
123
|
+
onNext={onSave}
|
|
124
|
+
canNext={checkedItem?.id}
|
|
125
|
+
>
|
|
126
|
+
{isLoading ? (
|
|
127
|
+
<LoadingSelectAction style={styles.container} />
|
|
128
|
+
) : (
|
|
129
|
+
configs.map((item) => {
|
|
130
|
+
const hasCondition = conditions[item.id];
|
|
131
|
+
const isChecked = checkedItem?.id === item?.id;
|
|
132
|
+
const isDefault = automate?.config_id === item?.id;
|
|
133
|
+
return (
|
|
134
|
+
<View style={styles.wrapItem} key={item?.id}>
|
|
135
|
+
<TitleCheckBox
|
|
136
|
+
onPress={onChecked}
|
|
137
|
+
id={item?.id}
|
|
138
|
+
title={item?.name}
|
|
139
|
+
titleStyle={styles.titleStyle}
|
|
140
|
+
wrapStyle={styles.wrapStyleCheckBox}
|
|
141
|
+
isChecked={isChecked}
|
|
142
|
+
/>
|
|
143
|
+
<TouchableOpacity
|
|
144
|
+
onPress={onPressItem(item)}
|
|
145
|
+
style={[styles.wrapCondition, styles.shadowView]}
|
|
146
|
+
accessibilityLabel={`config-${item.id}`}
|
|
147
|
+
>
|
|
148
|
+
<Text type="Body" color={Colors.Gray7}>
|
|
149
|
+
{t('condition')}
|
|
150
|
+
</Text>
|
|
151
|
+
<Text
|
|
152
|
+
numberOfLines={1}
|
|
153
|
+
type="H4"
|
|
154
|
+
semibold={isChecked}
|
|
155
|
+
style={styles.description}
|
|
156
|
+
>
|
|
157
|
+
{hasCondition
|
|
158
|
+
? renderCondition(item)
|
|
159
|
+
: isDefault
|
|
160
|
+
? generateAutomationConditionText(
|
|
161
|
+
automate,
|
|
162
|
+
valueEvaluations[automate?.config_id],
|
|
163
|
+
t
|
|
164
|
+
)
|
|
165
|
+
: t('no_condition')}
|
|
166
|
+
</Text>
|
|
167
|
+
{hasCondition && (
|
|
168
|
+
<Image source={Images.arrowBack} style={styles.arrowRight} />
|
|
169
|
+
)}
|
|
170
|
+
</TouchableOpacity>
|
|
171
|
+
</View>
|
|
172
|
+
);
|
|
173
|
+
})
|
|
174
|
+
)}
|
|
175
|
+
</NewActionWrapper>
|
|
176
|
+
);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export default ChooseConfig;
|
package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/LoadingSelectAction.js
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import ContentLoader, { Rect } from 'react-content-loader/native';
|
|
4
|
-
import { Constants } from '
|
|
4
|
+
import { Constants } from '../../../../configs';
|
|
5
5
|
|
|
6
6
|
const LoadingSelectAction = ({ style }) => (
|
|
7
7
|
<View style={style}>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { View } from 'react-native';
|
|
2
|
+
import styles from '../Styles/SelectSensorDevicesStyles';
|
|
3
|
+
import Text from '../../../../commons/Text';
|
|
4
|
+
import NavBar from '../../../../commons/NavBar';
|
|
5
|
+
import Device from '../Device';
|
|
6
|
+
import React, { useCallback, useState } from 'react';
|
|
7
|
+
import { useTranslations } from '../../../../hooks/Common/useTranslations';
|
|
8
|
+
import NewActionWrapper from '../NewActionWrapper';
|
|
9
|
+
|
|
10
|
+
const SelectDevices = ({
|
|
11
|
+
onPressContinue,
|
|
12
|
+
listStation,
|
|
13
|
+
listMenuItem,
|
|
14
|
+
title,
|
|
15
|
+
stations,
|
|
16
|
+
defaultSelectedDevice,
|
|
17
|
+
}) => {
|
|
18
|
+
const t = useTranslations();
|
|
19
|
+
|
|
20
|
+
const [selectedDevice, setSelectedDevice] = useState(defaultSelectedDevice);
|
|
21
|
+
const [indexStation, setIndexStation] = useState(0);
|
|
22
|
+
|
|
23
|
+
const onSnapToItem = useCallback((item, index) => {
|
|
24
|
+
setIndexStation(index);
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
const onPressDevice = (sensor) => {
|
|
28
|
+
if (selectedDevice && selectedDevice.id === sensor.id) {
|
|
29
|
+
setSelectedDevice(null);
|
|
30
|
+
} else {
|
|
31
|
+
setSelectedDevice(sensor);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<NewActionWrapper
|
|
37
|
+
nextTitle={t('continue')}
|
|
38
|
+
onNext={() => onPressContinue(selectedDevice, indexStation)}
|
|
39
|
+
canNext={Object.keys(selectedDevice || {}).length}
|
|
40
|
+
name={title}
|
|
41
|
+
>
|
|
42
|
+
{listStation.length ? (
|
|
43
|
+
<NavBar
|
|
44
|
+
listStation={listStation}
|
|
45
|
+
listMenuItem={listMenuItem}
|
|
46
|
+
onSnapToItem={onSnapToItem}
|
|
47
|
+
indexStation={indexStation}
|
|
48
|
+
style={styles.navbar}
|
|
49
|
+
/>
|
|
50
|
+
) : (
|
|
51
|
+
<View style={styles.noneData}>
|
|
52
|
+
<Text center>
|
|
53
|
+
{t('you_do_not_have_the_device_or_have_share_control_device')}
|
|
54
|
+
</Text>
|
|
55
|
+
</View>
|
|
56
|
+
)}
|
|
57
|
+
|
|
58
|
+
<View style={styles.boxDevices}>
|
|
59
|
+
{stations[indexStation]?.sensors &&
|
|
60
|
+
stations[indexStation].sensors.map((sensor) => (
|
|
61
|
+
<Device
|
|
62
|
+
svgMain={sensor.icon || 'sensor'}
|
|
63
|
+
title={sensor.name}
|
|
64
|
+
sensor={sensor}
|
|
65
|
+
isSelectDevice={selectedDevice && selectedDevice.id === sensor.id}
|
|
66
|
+
onPress={onPressDevice}
|
|
67
|
+
key={sensor.id}
|
|
68
|
+
/>
|
|
69
|
+
))}
|
|
70
|
+
</View>
|
|
71
|
+
</NewActionWrapper>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default SelectDevices;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { Colors, Constants } from '
|
|
2
|
+
import { Colors, Constants } from '../../../../configs';
|
|
3
3
|
|
|
4
4
|
const marginItem = 12;
|
|
5
5
|
const marginHorizontal = 16;
|
|
@@ -40,4 +40,8 @@ export default StyleSheet.create({
|
|
|
40
40
|
height: 40,
|
|
41
41
|
resizeMode: 'contain',
|
|
42
42
|
},
|
|
43
|
+
antIconStyle: {
|
|
44
|
+
width: 40,
|
|
45
|
+
height: 40,
|
|
46
|
+
},
|
|
43
47
|
});
|
|
@@ -2,9 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
3
|
import { TouchableWithoutFeedback } from 'react-native';
|
|
4
4
|
|
|
5
|
-
import Device from '
|
|
6
|
-
import { SCProvider } from '
|
|
7
|
-
import { mockSCStore } from '
|
|
5
|
+
import Device from '../index';
|
|
6
|
+
import { SCProvider } from '../../../../../context';
|
|
7
|
+
import { mockSCStore } from '../../../../../context/mockStore';
|
|
8
8
|
|
|
9
9
|
const wrapComponent = (svgMain, sensor, title, isSelectDevice, onPress) => (
|
|
10
10
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -25,7 +25,7 @@ describe('Test SelectDevice', () => {
|
|
|
25
25
|
const sensor = { id: 1, name: 'sensor' };
|
|
26
26
|
const mockFuntion = jest.fn();
|
|
27
27
|
await act(async () => {
|
|
28
|
-
tree = renderer.create(
|
|
28
|
+
tree = await renderer.create(
|
|
29
29
|
wrapComponent(sensor.icon_kit, sensor, sensor.name, true, mockFuntion)
|
|
30
30
|
);
|
|
31
31
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { memo } from 'react';
|
|
2
2
|
import { TouchableWithoutFeedback, View } from 'react-native';
|
|
3
|
-
import { Colors } from '
|
|
4
|
-
import Text from '
|
|
5
|
-
import IconComponent from '
|
|
6
|
-
import { AccessibilityLabel } from '
|
|
3
|
+
import { Colors } from '../../../../configs';
|
|
4
|
+
import Text from '../../../../commons/Text';
|
|
5
|
+
import IconComponent from '../../../../commons/IconComponent';
|
|
6
|
+
import { AccessibilityLabel } from '../../../../configs/Constants';
|
|
7
7
|
import styles from './DeviceStyles';
|
|
8
8
|
|
|
9
9
|
const Device = memo(({ svgMain, sensor, title, isSelectDevice, onPress }) => {
|
|
@@ -23,6 +23,7 @@ const Device = memo(({ svgMain, sensor, title, isSelectDevice, onPress }) => {
|
|
|
23
23
|
<IconComponent
|
|
24
24
|
icon={sensor?.icon_kit || svgMain}
|
|
25
25
|
style={styles.iconSensor}
|
|
26
|
+
antIconStyle={styles.antIconStyle}
|
|
26
27
|
/>
|
|
27
28
|
</View>
|
|
28
29
|
<Text numberOfLines={1} semibold type="Body" color={Colors.Gray9}>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
|
+
import { KeyboardAvoidingView, Platform, TouchableOpacity } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import styles from './Styles/SelectActionStyles';
|
|
5
|
+
import WrapHeaderScrollable from '../../../commons/Sharing/WrapHeaderScrollable';
|
|
6
|
+
import { Icon } from '@ant-design/react-native';
|
|
7
|
+
import { Colors } from '../../../configs';
|
|
8
|
+
import { useNavigation, useRoute } from '@react-navigation/native';
|
|
9
|
+
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
10
|
+
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
11
|
+
|
|
12
|
+
const NewActionWrapper = ({ name, children, canNext, onNext, nextTitle }) => {
|
|
13
|
+
const { navigate } = useNavigation();
|
|
14
|
+
const { params = {} } = useRoute();
|
|
15
|
+
const { closeScreen } = params;
|
|
16
|
+
|
|
17
|
+
const handleClose = useCallback(() => {
|
|
18
|
+
navigate(closeScreen);
|
|
19
|
+
}, [closeScreen, navigate]);
|
|
20
|
+
|
|
21
|
+
const rightComponent = useMemo(
|
|
22
|
+
() => (
|
|
23
|
+
<TouchableOpacity
|
|
24
|
+
style={styles.closeButton}
|
|
25
|
+
onPress={handleClose}
|
|
26
|
+
accessibilityLabel={AccessibilityLabel.ICON_CLOSE}
|
|
27
|
+
>
|
|
28
|
+
<Icon name={'close'} size={24} color={Colors.Black} />
|
|
29
|
+
</TouchableOpacity>
|
|
30
|
+
),
|
|
31
|
+
[handleClose]
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<KeyboardAvoidingView
|
|
36
|
+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
37
|
+
style={styles.wrap}
|
|
38
|
+
>
|
|
39
|
+
<WrapHeaderScrollable
|
|
40
|
+
title={name}
|
|
41
|
+
headerAniStyle={styles.headerAniStyle}
|
|
42
|
+
rightComponent={rightComponent}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</WrapHeaderScrollable>
|
|
46
|
+
<BottomButtonView
|
|
47
|
+
style={styles.bottomButtonView}
|
|
48
|
+
mainTitle={nextTitle}
|
|
49
|
+
onPressMain={onNext}
|
|
50
|
+
typeMain={canNext ? 'primary' : 'disabled'}
|
|
51
|
+
/>
|
|
52
|
+
</KeyboardAvoidingView>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default NewActionWrapper;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { useNavigation } from '@react-navigation/native';
|
|
3
|
+
import { fetchWithCache } from '../../../utils/Apis/axios';
|
|
4
|
+
import { API } from '../../../configs';
|
|
5
|
+
import Routes from '../../../utils/Route';
|
|
6
|
+
import SelectDevices from './Components/SelectDevices';
|
|
7
|
+
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
8
|
+
|
|
9
|
+
const SelectControlDevices = ({ route }) => {
|
|
10
|
+
const t = useTranslations();
|
|
11
|
+
const { unitId, closeScreen, automateId } = route?.params || {};
|
|
12
|
+
|
|
13
|
+
const [stations, setStations] = useState([]);
|
|
14
|
+
const [listStation, setListStation] = useState([]);
|
|
15
|
+
const [listMenuItem, setListMenuItem] = useState([]);
|
|
16
|
+
|
|
17
|
+
const { navigate } = useNavigation();
|
|
18
|
+
const [loading, setLoading] = useState(true);
|
|
19
|
+
|
|
20
|
+
const fetchDetails = useCallback(async () => {
|
|
21
|
+
await fetchWithCache(API.UNIT.DEVICE_CONTROL(unitId), {}, (response) => {
|
|
22
|
+
const { success, data } = response;
|
|
23
|
+
if (success) {
|
|
24
|
+
const newData = data.filter((item) => item.sensors.length > 0);
|
|
25
|
+
const listMenu = newData.map((item, index) => ({
|
|
26
|
+
text: item.name,
|
|
27
|
+
station: item,
|
|
28
|
+
index: index,
|
|
29
|
+
}));
|
|
30
|
+
setStations(newData);
|
|
31
|
+
setListMenuItem(listMenu);
|
|
32
|
+
setListStation(listMenu);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
setLoading(false);
|
|
36
|
+
}, [unitId]);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
fetchDetails();
|
|
40
|
+
}, [fetchDetails]);
|
|
41
|
+
|
|
42
|
+
const onPressContinue = useCallback(
|
|
43
|
+
(selectedDevice) => {
|
|
44
|
+
navigate(Routes.ChooseAction, {
|
|
45
|
+
unitId,
|
|
46
|
+
automateId,
|
|
47
|
+
device: selectedDevice,
|
|
48
|
+
closeScreen,
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
[navigate, unitId, automateId, closeScreen]
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
if (loading) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<SelectDevices
|
|
60
|
+
onPressContinue={onPressContinue}
|
|
61
|
+
listStation={listStation}
|
|
62
|
+
listMenuItem={listMenuItem}
|
|
63
|
+
stations={stations}
|
|
64
|
+
title={t('select_device')}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export default SelectControlDevices;
|