@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.
- package/assets/images/Automation-fill.svg +85 -0
- package/assets/images/Map/LocationPin.svg +10 -0
- package/assets/images/Scenario-filled.svg +22 -0
- package/assets/images/schedule-fill.svg +48 -0
- package/package.json +20 -17
- package/src/commons/Action/ItemQuickAction.js +1 -1
- package/src/commons/Action/__test__/ItemQuickAction.test.js +6 -6
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +5 -5
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +2 -2
- package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +2 -2
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -2
- package/src/commons/ActionGroup/SliderRangeTemplate.js +7 -7
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +2 -2
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/CircleButton.js +5 -5
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/ControlPlay.js +5 -5
- package/src/commons/ActionGroup/TerminalBoxTemplate.js +2 -2
- package/src/commons/ActionGroup/TextBoxTemplate.js +2 -2
- package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonCircle.test.js +2 -2
- package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonDefault.test.js +2 -2
- package/src/commons/ActionGroup/TimerActionTemplate.js +6 -3
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +2 -2
- package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +9 -10
- package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +5 -5
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +5 -5
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +8 -8
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +3 -3
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +6 -6
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -1
- package/src/commons/ActionGroup/__test__/index.test.js +6 -6
- package/src/commons/ActionGroup/index.js +2 -2
- package/src/commons/ActionTemplate/__test__/index.test.js +4 -4
- package/src/commons/Automate/ItemAutomate.js +9 -41
- package/src/commons/Automate/ItemConditionScriptDetail.js +67 -0
- package/src/commons/Automate/ItemConditionScriptDetailStyles.js +46 -0
- package/src/commons/Automate/__test__/ItemAutomate.test.js +0 -21
- package/src/commons/BackDefault/index.js +2 -2
- package/src/commons/BottomButtonView/index.js +1 -0
- package/src/commons/ButtonPopup/index.js +3 -2
- package/src/commons/ChartAggregationOption/__test__/FourButtonFilterHistory.test.js +2 -2
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +8 -9
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +7 -7
- package/src/commons/DateTimeRangeChange/DateTimeButton.js +3 -3
- package/src/commons/DateTimeRangeChange/index.js +1 -1
- package/src/commons/Device/ConnectedViewHeader.js +2 -2
- package/src/commons/Device/Emergency/EmergencyDetail.js +3 -3
- package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +1 -1
- package/src/commons/Device/FlatListItems.js +20 -19
- package/src/commons/Device/Hanet/ItemHanetDevice.js +3 -3
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +3 -3
- package/src/commons/Device/HorizontalBarChart.js +54 -34
- package/src/commons/Device/ItemAddNew/index.js +2 -2
- package/src/commons/Device/ItemDevice.js +5 -21
- package/src/commons/Device/SonosSpeaker/index.js +3 -3
- package/src/commons/Device/WaterPurifierStatus/AlertStatusMachine.js +2 -2
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +6 -2
- package/src/commons/DisplayChecking/index.js +2 -2
- package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
- package/src/commons/FieldTemplate/ChooseUserField/index.js +2 -2
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +3 -3
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +6 -6
- package/src/commons/FlatListDnD/__test__/index.test.js +4 -4
- package/src/commons/FlatListDnD/index.js +12 -9
- package/src/commons/Grid/GridItem.js +10 -2
- package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +3 -3
- package/src/commons/Header/HeaderCustom.js +2 -2
- package/src/commons/Header/__test__/HeaderCT.test.js +3 -3
- package/src/commons/HeaderAni/index.js +2 -2
- package/src/commons/IconComponent/index.js +3 -3
- package/src/commons/ImagePicker/__test__/ImagePicker.test.js +5 -5
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +6 -4
- package/src/commons/MenuActionMore/MenuActionMoreStyles.js +2 -1
- package/src/commons/MenuActionMore/index.js +1 -1
- package/src/commons/NavBar/NavBarStyles.js +1 -1
- package/src/commons/NavBar/index.js +2 -2
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +1 -1
- package/src/commons/Popover/__test__/index.test.js +3 -3
- package/src/commons/Processing/__test__/Connecting.test.js +4 -4
- package/src/commons/SearchLocation/index.js +3 -3
- package/src/commons/SelectActionCard/index.js +2 -2
- package/src/commons/SelectSubUnit/index.js +6 -2
- package/src/commons/SelectUnit/__test__/SelectUnit.test.js +5 -5
- package/src/commons/Sharing/BtnRemoveMember.js +2 -2
- package/src/commons/Sharing/StationDevicePermissions.js +2 -2
- package/src/commons/SubUnit/DeviceTemplate/ConfigAndEvaluation/ConfigAndEvaluation.js +2 -2
- package/src/commons/SubUnit/DeviceTemplate/ConfigValue/ConfigValue.js +2 -2
- package/src/commons/SubUnit/DeviceTemplate/EvaluationOverConfig/EvaluationOverConfig.js +2 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +6 -7
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +0 -2
- package/src/commons/SubUnit/OneTap/index.js +9 -8
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +8 -8
- package/src/commons/Unit/HeaderUnit/index.js +30 -22
- package/src/commons/Unit/SharedUnit.js +7 -7
- package/src/commons/Widgets/IFrame/__tests__/IFrame.test.js +9 -13
- package/src/commons/Widgets/IFrameWithConfig/IFrameWithConfig.js +34 -2
- package/src/commons/Widgets/IFrameWithConfig/__tests__/IFrameWithConfig.test.js +88 -8
- package/src/commons/WrapParallaxScrollView/index.js +9 -10
- package/src/configs/API.js +1 -1
- package/src/configs/AccessibilityLabel.js +2 -0
- package/src/configs/Constants.js +3 -3
- package/src/configs/Theme.js +1 -1
- package/src/hooks/Common/__test__/useAndroidTranslucentStatusBar.test.js +5 -5
- package/src/hooks/IoT/__test__/useHomeAssistantConnection.test.js +12 -12
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +14 -7
- package/src/hooks/IoT/__test__/useWatchConfigs.test.js +3 -3
- package/src/hooks/IoT/useRemoteControl.js +24 -13
- package/src/hooks/useMqtt.js +2 -2
- package/src/iot/RemoteControl/Bluetooth.js +19 -22
- package/src/iot/RemoteControl/Internet.js +13 -5
- package/src/iot/RemoteControl/__test__/Internet.test.js +7 -7
- package/src/navigations/EmergencyContactsStack.js +4 -3
- package/src/navigations/SharedStack.js +2 -0
- package/src/navigations/UnitStack.js +56 -57
- package/src/screens/AQIGuide/index.js +0 -2
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddLocationMaps/__test__/index.test.js +12 -12
- package/src/screens/AddLocationMaps/index.js +16 -19
- package/src/screens/AddLocationMaps/indexStyle.js +1 -0
- package/src/screens/AddNewGateway/RenameNewDevices.js +2 -2
- package/src/screens/AddNewGateway/SelectDeviceType.js +1 -1
- package/src/screens/AddNewGateway/ShareWifiPassword.js +16 -15
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +7 -7
- package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +8 -8
- package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +7 -7
- package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +8 -8
- package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +5 -5
- package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +4 -4
- package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -6
- package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -6
- package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +0 -4
- package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +2 -2
- package/src/screens/AllGateway/DetailConfigActionModbus/__test__/index.test.js +6 -6
- package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +19 -17
- package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +19 -17
- package/src/screens/AllGateway/DeviceZigbeeDetail/__test__/index.test.js +18 -16
- package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +43 -35
- package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +38 -22
- package/src/screens/AllGateway/__test__/index.test.js +6 -6
- package/src/screens/AllGateway/components/Detail/__test__/index.test.js +3 -5
- package/src/screens/AllGateway/components/GatewayItem/__test__/index.test.js +3 -3
- package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +6 -6
- package/src/screens/AllGateway/hooks/__test__/index.test.js +2 -2
- package/src/screens/AllGateway/test-utils.js +3 -4
- package/src/screens/Automate/AddNewAction/ChooseAction.js +17 -3
- package/src/screens/Automate/AddNewAction/ChooseConfig.js +7 -6
- package/src/screens/Automate/AddNewAction/NewActionWrapper.js +8 -8
- package/src/screens/Automate/AddNewAction/SelectControlDevices.js +30 -20
- package/src/screens/Automate/AddNewAction/SelectMonitorDevices.js +17 -10
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +58 -44
- package/src/screens/Automate/AddNewAction/SetupScriptDelay.js +1 -1
- package/src/screens/Automate/AddNewAction/SetupScriptNotify.js +3 -3
- package/src/screens/Automate/AddNewAction/Styles/SetupSensorStyles.js +20 -4
- package/src/screens/Automate/AddNewAction/__test__/ChooseAction.test.js +12 -12
- package/src/screens/Automate/AddNewAction/__test__/SelectControlDevices.test.js +14 -8
- package/src/screens/Automate/AddNewAction/__test__/SelectMonitorDevices.test.js +13 -7
- package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +54 -15
- package/src/screens/Automate/AddNewAction/__test__/SetupScriptDelay.test.js +9 -9
- package/src/screens/Automate/AddNewAction/__test__/SetupScriptNotify.test.js +39 -10
- package/src/screens/Automate/AddNewAutoSmart/AddTypeSmart.js +10 -10
- package/src/screens/Automate/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +13 -8
- package/src/screens/Automate/Components/InputName.js +10 -7
- package/src/screens/Automate/EditActionsList/__tests__/UpdateActionScript.test.js +8 -8
- package/src/screens/Automate/EditActionsList/__tests__/UpdateDelayScript.test.js +6 -6
- package/src/screens/Automate/EditActionsList/__tests__/UpdateNotifyScript.test.js +7 -7
- package/src/screens/Automate/EditActionsList/index.js +19 -17
- package/src/screens/Automate/MultiUnits.js +19 -22
- package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +18 -8
- package/src/screens/Automate/Scenario/__test__/AddNewOneTap.test.js +15 -7
- package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +14 -6
- package/src/screens/Automate/ScriptDetail/Components/RenameScript.js +4 -7
- package/src/screens/Automate/ScriptDetail/__test__/index.test.js +56 -18
- package/src/screens/Automate/ScriptDetail/__test__/useStarredScript.test.js +6 -6
- package/src/screens/Automate/ScriptDetail/index.js +105 -41
- package/src/screens/Automate/SetSchedule/__test__/SelectWeekday.test.js +4 -4
- package/src/screens/Automate/SetSchedule/__test__/index.test.js +29 -18
- package/src/screens/Automate/SetSchedule/components/RowItem.js +5 -5
- package/src/screens/Automate/SetSchedule/index.js +8 -7
- package/src/screens/Automate/Styles/indexStyles.js +1 -1
- package/src/screens/Automate/__test__/MultiUnits.test.js +1 -4
- package/src/screens/Automate/__test__/index.test.js +0 -1
- package/src/screens/Automate/index.js +36 -34
- package/src/screens/ChangePosition/__test__/index.test.js +6 -6
- package/src/screens/ChangePosition/index.js +2 -1
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +13 -13
- package/src/screens/Device/EditDevice/index.js +4 -4
- package/src/screens/Device/__test__/BluetoothDevice.test.js +300 -0
- package/src/screens/Device/__test__/detail.test.js +14 -14
- package/src/screens/Device/__test__/mqttDetail.test.js +9 -9
- package/src/screens/Device/components/BluetoothDevice.js +135 -0
- package/src/screens/Device/components/SensorDisplayItem.js +9 -8
- package/src/screens/Device/detail.js +70 -62
- package/src/screens/Device/hooks/useEvaluateValue.js +1 -1
- package/src/screens/Drawer/Drawer.test.js +2 -2
- package/src/screens/Drawer/index.js +3 -3
- package/src/screens/EmergencyContacts/EmergencyContactsList.js +8 -4
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -7
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +8 -8
- package/src/screens/GuestInfo/components/RowGuestInfo.js +2 -2
- package/src/screens/GuestInfo/components/__test__/AccessScheduleSheet.test.js +3 -3
- package/src/screens/GuestInfo/index.js +2 -2
- package/src/screens/HanetCamera/ManageAccess.js +3 -3
- package/src/screens/HanetCamera/MemberInfo.js +2 -2
- package/src/screens/HanetCamera/__test__/Detail.test.js +9 -9
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -10
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -2
- package/src/screens/ManageAccess/index.js +3 -3
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +9 -9
- package/src/screens/Notification/__test__/Notification.test.js +9 -9
- package/src/screens/Notification/components/NotificationItem.js +3 -4
- package/src/screens/Notification/index.js +3 -3
- package/src/screens/Notification/styles/NotificationItemStyles.js +0 -1
- package/src/screens/PlayBackCamera/__test__/index.test.js +1 -1
- package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +1 -1
- package/src/screens/ScanChipQR/components/QRScan/index.js +3 -3
- package/src/screens/SelectUnit/__test__/index.test.js +8 -8
- package/src/screens/SelectUnit/index.js +4 -4
- package/src/screens/SharedUnit/TabHeader.js +2 -2
- package/src/screens/Sharing/Components/EndDevice.js +3 -3
- package/src/screens/Sharing/UnitMemberList.js +2 -2
- package/src/screens/Sharing/__test__/UpdateShareDevice.test.js +7 -7
- package/src/screens/SideMenuDetail/__test__/index.test.js +8 -8
- package/src/screens/SmartAccount/Connecting/index.js +5 -5
- package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +8 -8
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +7 -7
- package/src/screens/SmartAccount/SuccessfullyConnected/index.js +2 -2
- package/src/screens/SmartAccount/__test__/Connecting.test.js +6 -6
- package/src/screens/SmartAccount/__test__/SmartAccount.test.js +10 -10
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +3 -2
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +2 -2
- package/src/screens/SmartIr/components/SelectBrand.js +2 -2
- package/src/screens/SubUnit/AddSubUnit.js +28 -26
- package/src/screens/SubUnit/AddSubUnitStyles.js +10 -4
- package/src/screens/SubUnit/EditSubUnit.js +12 -11
- package/src/screens/SubUnit/ManageSubUnit.js +3 -3
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +13 -13
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +3 -3
- package/src/screens/Template/EditTemplate.js +6 -4
- package/src/screens/Template/__test__/EditTemplate.test.js +7 -7
- package/src/screens/Template/__test__/detail.test.js +4 -4
- package/src/screens/Template/__test__/index.test.js +1 -1
- package/src/screens/UVIndexGuide/index.js +2 -4
- package/src/screens/Unit/Detail.js +1 -5
- package/src/screens/Unit/MoreMenu.js +6 -5
- package/src/screens/Unit/SelectAddToFavorites.js +2 -2
- package/src/screens/Unit/SelectAddress.js +16 -12
- package/src/screens/Unit/Station/__test__/index.test.js +1 -1
- package/src/screens/Unit/__test__/MoreMenu.test.js +5 -1
- package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +9 -9
- package/src/screens/Unit/__test__/SelectAddress.test.js +11 -17
- package/src/screens/Unit/__test__/Summaries.test.js +7 -7
- package/src/screens/Unit/components/AutomateScript/index.js +5 -5
- package/src/screens/Unit/components/ButtonWrapper/index.js +3 -3
- package/src/screens/Unit/components/Header/index.js +2 -2
- package/src/screens/Unit/components/SharedUnit/index.js +5 -5
- package/src/screens/Unit/components/__test__/AutomateScript.test.js +3 -3
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +8 -8
- package/src/screens/Unit/hook/__test__/useUnitConnectRemoteDevices.test.js +2 -2
- package/src/screens/UnitSummary/components/AirQuality/index.js +6 -11
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +5 -5
- package/src/screens/UnitSummary/index.js +6 -2
- package/src/utils/Apis/axios.js +5 -5
- package/src/utils/Functions/ShortEmail.js +1 -0
- package/src/utils/I18n/translations/en.js +6 -3
- package/src/utils/I18n/translations/vi.js +8 -4
- package/src/utils/__test__/Utils.test.js +16 -16
- package/src/utils/bluetooth.js +3 -0
- package/assets/images/OneTap.svg +0 -14
- package/assets/images/Schedule.svg +0 -39
- package/assets/images/ValueChange.svg +0 -49
|
@@ -5,35 +5,35 @@ import React, {
|
|
|
5
5
|
useRef,
|
|
6
6
|
useState,
|
|
7
7
|
} from 'react';
|
|
8
|
-
import { Image, Platform, TouchableOpacity, View
|
|
8
|
+
import { Image, Platform, Switch, TouchableOpacity, View } from 'react-native';
|
|
9
9
|
import { PopoverMode } from 'react-native-popover-view';
|
|
10
|
-
import
|
|
10
|
+
import { IconFill, IconOutline } from '@ant-design/icons-react-native';
|
|
11
11
|
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
import styles from './Styles/indexStyles';
|
|
15
|
-
import Text from '../../../commons/Text';
|
|
16
|
-
import WrapHeaderScrollable from '../../../commons/Sharing/WrapHeaderScrollable';
|
|
17
|
-
import { API, Colors } from '../../../configs';
|
|
18
|
-
import { usePopover } from '../../../hooks/Common';
|
|
19
|
-
import { useStarredScript } from './hooks/useStarredScript';
|
|
20
|
-
import MenuActionMore from '../../../commons/MenuActionMore';
|
|
13
|
+
import { useIsFocused, useNavigation } from '@react-navigation/native';
|
|
21
14
|
import Add from '../../../../assets/images/Add.svg';
|
|
22
|
-
import Notify from '../../../../assets/images/Notify.svg';
|
|
23
15
|
import Delay from '../../../../assets/images/Delay.svg';
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
16
|
+
import Notify from '../../../../assets/images/Notify.svg';
|
|
17
|
+
import IconComponent from '../../../commons/IconComponent';
|
|
18
|
+
import MenuActionMore from '../../../commons/MenuActionMore';
|
|
19
|
+
import WrapHeaderScrollable from '../../../commons/Sharing/WrapHeaderScrollable';
|
|
20
|
+
import Text from '../../../commons/Text';
|
|
29
21
|
import withPreventDoubleClick from '../../../commons/WithPreventDoubleClick';
|
|
22
|
+
import { API, Colors } from '../../../configs';
|
|
30
23
|
import { AccessibilityLabel, AUTOMATE_TYPE } from '../../../configs/Constants';
|
|
31
|
-
import RenameScript from './Components/RenameScript';
|
|
32
|
-
import DeleteScript from './Components/DeleteScript';
|
|
33
24
|
import Images from '../../../configs/Images';
|
|
25
|
+
import { usePopover } from '../../../hooks/Common';
|
|
26
|
+
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
27
|
+
import { axiosGet, axiosPost } from '../../../utils/Apis/axios';
|
|
34
28
|
import { useBackendPermission } from '../../../utils/Permission/backend';
|
|
35
|
-
import
|
|
29
|
+
import Routes from '../../../utils/Route';
|
|
30
|
+
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
36
31
|
import AddActionScript from './Components/AddActionScript';
|
|
32
|
+
import DeleteScript from './Components/DeleteScript';
|
|
33
|
+
import RenameScript from './Components/RenameScript';
|
|
34
|
+
import { useStarredScript } from './hooks/useStarredScript';
|
|
35
|
+
import styles from './Styles/indexStyles';
|
|
36
|
+
import ItemConditionScriptDetail from '../../../commons/Automate/ItemConditionScriptDetail';
|
|
37
37
|
|
|
38
38
|
const PreventDoubleTouch = withPreventDoubleClick(TouchableOpacity);
|
|
39
39
|
|
|
@@ -43,13 +43,18 @@ const ScriptDetail = ({ route }) => {
|
|
|
43
43
|
const refMenuAction = useRef();
|
|
44
44
|
const { childRef, showingPopover, showPopoverWithRef, hidePopover } =
|
|
45
45
|
usePopover();
|
|
46
|
+
const {
|
|
47
|
+
childRef: childRef1,
|
|
48
|
+
showingPopover: showingPopover1,
|
|
49
|
+
showPopoverWithRef: showPopoverWithRef1,
|
|
50
|
+
hidePopover: hidePopover1,
|
|
51
|
+
} = usePopover();
|
|
46
52
|
const t = useTranslations();
|
|
47
53
|
const {
|
|
48
|
-
id,
|
|
49
54
|
saveAt,
|
|
50
55
|
preAutomate = {}, // pre-loaded automate data
|
|
51
|
-
newAutomate, // updated automate data
|
|
52
56
|
newActionsList, // updated actions list
|
|
57
|
+
closeScreen,
|
|
53
58
|
} = params;
|
|
54
59
|
const [automate, setAutomate] = useState(preAutomate);
|
|
55
60
|
const isFocused = useIsFocused();
|
|
@@ -58,12 +63,22 @@ const ScriptDetail = ({ route }) => {
|
|
|
58
63
|
const [isShowDelete, setIsShowDelete] = useState(false);
|
|
59
64
|
const [isShowAddAction, setIsShowAddAction] = useState(false);
|
|
60
65
|
|
|
61
|
-
const {
|
|
66
|
+
const {
|
|
67
|
+
script,
|
|
68
|
+
type,
|
|
69
|
+
name,
|
|
70
|
+
unit,
|
|
71
|
+
can_edit,
|
|
72
|
+
id: automateId,
|
|
73
|
+
value_change,
|
|
74
|
+
} = automate;
|
|
75
|
+
const { end_device_id, unit_id } = value_change || {};
|
|
62
76
|
const { enable } = script || {};
|
|
63
77
|
const [enableScript, setEnableScript] = useState(enable);
|
|
78
|
+
const refMenuAction1 = useRef();
|
|
64
79
|
const onShowActivityLog = useCallback(() => {
|
|
65
80
|
navigate(Routes.ActivityLog, {
|
|
66
|
-
id:
|
|
81
|
+
id: automateId,
|
|
67
82
|
type:
|
|
68
83
|
type === AUTOMATE_TYPE.ONE_TAP
|
|
69
84
|
? `automate.${AUTOMATE_TYPE.ONE_TAP}`
|
|
@@ -74,7 +89,7 @@ const ScriptDetail = ({ route }) => {
|
|
|
74
89
|
user: Boolean(unit),
|
|
75
90
|
},
|
|
76
91
|
});
|
|
77
|
-
}, [navigate,
|
|
92
|
+
}, [navigate, automateId, type, unit]);
|
|
78
93
|
|
|
79
94
|
const listMenuItem = useMemo(
|
|
80
95
|
() => [
|
|
@@ -91,6 +106,23 @@ const ScriptDetail = ({ route }) => {
|
|
|
91
106
|
[t, onShowActivityLog]
|
|
92
107
|
);
|
|
93
108
|
|
|
109
|
+
const listMenuItemCondition = useMemo(() => {
|
|
110
|
+
const items = [
|
|
111
|
+
{ text: t('edit_condition'), doAction: () => handleUpdateAutomate() },
|
|
112
|
+
];
|
|
113
|
+
if (value_change) {
|
|
114
|
+
items.unshift({
|
|
115
|
+
text: t('device_display'),
|
|
116
|
+
doAction: () =>
|
|
117
|
+
navigate(Routes.DeviceDetail, {
|
|
118
|
+
unitId: unit_id,
|
|
119
|
+
sensorId: end_device_id,
|
|
120
|
+
}),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return items;
|
|
124
|
+
}, [t, handleUpdateAutomate, value_change, navigate, unit_id, end_device_id]);
|
|
125
|
+
|
|
94
126
|
const handleShowMenuAction = useCallback(() => {
|
|
95
127
|
if (!can_edit) {
|
|
96
128
|
ToastBottomHelper.error(
|
|
@@ -107,39 +139,41 @@ const ScriptDetail = ({ route }) => {
|
|
|
107
139
|
|
|
108
140
|
const fetchAutomateActions = useCallback(async () => {
|
|
109
141
|
const { success, data: automateData } = await axiosGet(
|
|
110
|
-
API.AUTOMATE.SCRIPT_ITEMS(
|
|
142
|
+
API.AUTOMATE.SCRIPT_ITEMS(automateId)
|
|
111
143
|
);
|
|
112
144
|
if (success) {
|
|
113
145
|
setData(automateData.script_items || []);
|
|
114
146
|
}
|
|
115
|
-
}, [
|
|
147
|
+
}, [automateId]);
|
|
116
148
|
|
|
117
149
|
const fetchAutomate = useCallback(async () => {
|
|
118
150
|
const { success, data: automateData } = await axiosGet(
|
|
119
|
-
API.AUTOMATE.FETCH_AUTOMATE(
|
|
151
|
+
API.AUTOMATE.FETCH_AUTOMATE(automateId)
|
|
120
152
|
);
|
|
121
153
|
if (success) {
|
|
122
154
|
setAutomate(automateData);
|
|
123
155
|
setEnableScript(automateData.script.enable);
|
|
124
156
|
}
|
|
125
|
-
}, [
|
|
157
|
+
}, [automateId]);
|
|
126
158
|
|
|
127
159
|
const onPressEdit = useCallback(() => {
|
|
128
160
|
navigate(Routes.EditActionsList, {
|
|
129
161
|
data,
|
|
130
|
-
id,
|
|
162
|
+
id: automateId,
|
|
131
163
|
unitId: automate.unit,
|
|
132
164
|
});
|
|
133
|
-
}, [navigate, data,
|
|
165
|
+
}, [navigate, data, automateId, automate.unit]);
|
|
134
166
|
|
|
135
167
|
const handleScriptAction = useCallback(async () => {
|
|
136
|
-
const { success } = await axiosPost(
|
|
168
|
+
const { success } = await axiosPost(
|
|
169
|
+
API.AUTOMATE.ACTION_ONE_TAP(automateId)
|
|
170
|
+
);
|
|
137
171
|
if (success) {
|
|
138
172
|
ToastBottomHelper.success(t('activated_successfully'));
|
|
139
173
|
} else {
|
|
140
174
|
ToastBottomHelper.error(t('activation_failed'));
|
|
141
175
|
}
|
|
142
|
-
}, [
|
|
176
|
+
}, [automateId, t]);
|
|
143
177
|
|
|
144
178
|
const handleUpdateAutomate = useCallback(async () => {
|
|
145
179
|
if (!can_edit) {
|
|
@@ -158,6 +192,19 @@ const ScriptDetail = ({ route }) => {
|
|
|
158
192
|
});
|
|
159
193
|
}, [automate, can_edit, enableScript, navigate, route.name, t]);
|
|
160
194
|
|
|
195
|
+
const handleGoBack = useCallback(async () => {
|
|
196
|
+
if (closeScreen === Routes.UnitDetail) {
|
|
197
|
+
navigate(closeScreen, { unitId: unit });
|
|
198
|
+
} else if (
|
|
199
|
+
closeScreen === Routes.MultiUnits ||
|
|
200
|
+
closeScreen === Routes.Automate
|
|
201
|
+
) {
|
|
202
|
+
navigate(closeScreen, {});
|
|
203
|
+
} else {
|
|
204
|
+
goBack();
|
|
205
|
+
}
|
|
206
|
+
}, [closeScreen, goBack, navigate, unit]);
|
|
207
|
+
|
|
161
208
|
const onChangeSwitch = useCallback(
|
|
162
209
|
async (checked) => {
|
|
163
210
|
setEnableScript(checked);
|
|
@@ -210,9 +257,9 @@ const ScriptDetail = ({ route }) => {
|
|
|
210
257
|
saveAt && fetchAutomateActions();
|
|
211
258
|
}, [saveAt, fetchAutomateActions]);
|
|
212
259
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}, [
|
|
260
|
+
const handleShowMenuAction1 = useCallback(() => {
|
|
261
|
+
showPopoverWithRef1(refMenuAction1);
|
|
262
|
+
}, [showPopoverWithRef1, refMenuAction1]);
|
|
216
263
|
|
|
217
264
|
return (
|
|
218
265
|
<View style={styles.wrap}>
|
|
@@ -220,7 +267,7 @@ const ScriptDetail = ({ route }) => {
|
|
|
220
267
|
title={name}
|
|
221
268
|
headerAniStyle={styles.headerAniStyle}
|
|
222
269
|
rightComponent={rightComponent}
|
|
223
|
-
onGoBack={
|
|
270
|
+
onGoBack={handleGoBack}
|
|
224
271
|
>
|
|
225
272
|
<View style={styles.wrapContent}>
|
|
226
273
|
{!!can_edit && (
|
|
@@ -228,16 +275,17 @@ const ScriptDetail = ({ route }) => {
|
|
|
228
275
|
<Text type="H3" semibold>
|
|
229
276
|
{t('enable_this_script')}
|
|
230
277
|
</Text>
|
|
231
|
-
<Switch
|
|
278
|
+
<Switch value={enableScript} onValueChange={onChangeSwitch} />
|
|
232
279
|
</View>
|
|
233
280
|
)}
|
|
234
281
|
<Text type="H3" semibold>
|
|
235
282
|
{t('how_to_start')}
|
|
236
283
|
</Text>
|
|
237
|
-
<
|
|
284
|
+
<ItemConditionScriptDetail
|
|
238
285
|
automate={automate}
|
|
239
286
|
enableScript={enableScript}
|
|
240
|
-
|
|
287
|
+
handleShowMenuAction1={handleShowMenuAction1}
|
|
288
|
+
refMenuAction1={refMenuAction1}
|
|
241
289
|
/>
|
|
242
290
|
{type === AUTOMATE_TYPE.ONE_TAP && enableScript && (
|
|
243
291
|
<TouchableOpacity
|
|
@@ -294,8 +342,24 @@ const ScriptDetail = ({ route }) => {
|
|
|
294
342
|
isTextCenter={false}
|
|
295
343
|
wrapStyle={styles.wrapStyle}
|
|
296
344
|
mode={
|
|
345
|
+
/* istanbul ignore next */
|
|
346
|
+
Platform.OS === 'ios' ? PopoverMode.JS_MODAL : PopoverMode.RN_MODAL
|
|
347
|
+
}
|
|
348
|
+
accessibilityLabel={AccessibilityLabel.MENU_POPPER_MORE}
|
|
349
|
+
/>
|
|
350
|
+
<MenuActionMore
|
|
351
|
+
isVisible={showingPopover1}
|
|
352
|
+
hideMore={hidePopover1}
|
|
353
|
+
listMenuItem={listMenuItemCondition}
|
|
354
|
+
childRef={childRef1}
|
|
355
|
+
onItemClick={onItemClick}
|
|
356
|
+
isTextCenter={false}
|
|
357
|
+
wrapStyle={styles.wrapStyle}
|
|
358
|
+
mode={
|
|
359
|
+
/* istanbul ignore next */
|
|
297
360
|
Platform.OS === 'ios' ? PopoverMode.JS_MODAL : PopoverMode.RN_MODAL
|
|
298
361
|
}
|
|
362
|
+
accessibilityLabel={AccessibilityLabel.MENU_POPPER_MORE_2}
|
|
299
363
|
/>
|
|
300
364
|
<AddActionScript
|
|
301
365
|
automate={automate}
|
|
@@ -479,9 +543,9 @@ const ButtonStar = ({ automate }) => {
|
|
|
479
543
|
accessibilityLabel={AccessibilityLabel.HEADER_SCRIPT_DETAIL_BUTTON_STAR}
|
|
480
544
|
>
|
|
481
545
|
{isStarred ? (
|
|
482
|
-
<
|
|
546
|
+
<IconFill name="star" size={25} color={Colors.Yellow6} />
|
|
483
547
|
) : (
|
|
484
|
-
<
|
|
548
|
+
<IconOutline name="star" size={25} />
|
|
485
549
|
)}
|
|
486
550
|
</PreventDoubleTouch>
|
|
487
551
|
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import { act, create } from 'react-test-renderer';
|
|
3
4
|
import { SCProvider } from '../../../../context';
|
|
4
5
|
import { mockSCStore } from '../../../../context/mockStore';
|
|
5
|
-
import { TouchableOpacity } from 'react-native';
|
|
6
6
|
import SelectWeekday from '../components/SelectWeekday';
|
|
7
7
|
|
|
8
8
|
const wrapComponent = (props) => (
|
|
@@ -28,7 +28,7 @@ it('test select', async () => {
|
|
|
28
28
|
await act(async () => {
|
|
29
29
|
await items[0].props.onPress();
|
|
30
30
|
});
|
|
31
|
-
expect(mockSetWeekday).
|
|
31
|
+
expect(mockSetWeekday).toHaveBeenCalledWith(['1']);
|
|
32
32
|
|
|
33
33
|
mockSetWeekday.mockClear();
|
|
34
34
|
props = {
|
|
@@ -44,5 +44,5 @@ it('test select', async () => {
|
|
|
44
44
|
await act(async () => {
|
|
45
45
|
await items[0].props.onPress();
|
|
46
46
|
});
|
|
47
|
-
expect(mockSetWeekday).
|
|
47
|
+
expect(mockSetWeekday).toHaveBeenCalledWith(['0', '1']);
|
|
48
48
|
});
|
|
@@ -1,34 +1,37 @@
|
|
|
1
|
+
import { useNavigation, useRoute } from '@react-navigation/native';
|
|
2
|
+
import moment from 'moment';
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { act, create } from 'react-test-renderer';
|
|
5
|
+
import BottomButtonView from '../../../../commons/BottomButtonView';
|
|
6
|
+
import Calendar from '../../../../commons/Calendar';
|
|
7
|
+
import WheelDateTimePicker from '../../../../commons/WheelDateTimePicker';
|
|
8
|
+
import AccessibilityLabel from '../../../../configs/AccessibilityLabel';
|
|
3
9
|
import { SCProvider } from '../../../../context';
|
|
4
10
|
import { mockSCStore } from '../../../../context/mockStore';
|
|
5
|
-
import
|
|
6
|
-
import RowItem from '../components/RowItem';
|
|
7
|
-
import WheelDateTimePicker from '../../../../commons/WheelDateTimePicker';
|
|
11
|
+
import Routes from '../../../../utils/Route';
|
|
8
12
|
import RepeatOptionsPopup, {
|
|
9
13
|
REPEAT_OPTIONS,
|
|
10
14
|
} from '../components/RepeatOptionsPopup';
|
|
11
|
-
import
|
|
12
|
-
import BottomButtonView from '../../../../commons/BottomButtonView';
|
|
13
|
-
import Routes from '../../../../utils/Route';
|
|
15
|
+
import RowItem from '../components/RowItem';
|
|
14
16
|
import SelectWeekday from '../components/SelectWeekday';
|
|
15
|
-
import
|
|
16
|
-
import { useNavigation } from '@react-navigation/native';
|
|
17
|
-
import AccessibilityLabel from '../../../../configs/AccessibilityLabel';
|
|
17
|
+
import SetSchedule from '../index';
|
|
18
18
|
|
|
19
|
-
const wrapComponent = (route) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const wrapComponent = (route) => {
|
|
20
|
+
useRoute.mockReturnValue(route);
|
|
21
|
+
return (
|
|
22
|
+
<SCProvider initState={mockSCStore({})}>
|
|
23
|
+
<SetSchedule route={route} />
|
|
24
|
+
</SCProvider>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
24
27
|
|
|
25
28
|
describe('Test SetSchedule', () => {
|
|
26
29
|
let tree;
|
|
27
30
|
let route = {
|
|
28
31
|
params: {
|
|
29
|
-
type: 'schedule',
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
automate: { type: 'schedule', unit: 1 },
|
|
33
|
+
unitId: 1,
|
|
34
|
+
closeScreen: 'UnitDetail',
|
|
32
35
|
},
|
|
33
36
|
};
|
|
34
37
|
|
|
@@ -70,7 +73,11 @@ describe('Test SetSchedule', () => {
|
|
|
70
73
|
await act(async () => {
|
|
71
74
|
await header.props.onPress();
|
|
72
75
|
});
|
|
73
|
-
expect(global.mockedNavigate).
|
|
76
|
+
expect(global.mockedNavigate).toHaveBeenCalledWith('UnitDetail', {
|
|
77
|
+
automate: { type: 'schedule', unit: 1 },
|
|
78
|
+
closeScreen: 'UnitDetail',
|
|
79
|
+
unitId: 1,
|
|
80
|
+
});
|
|
74
81
|
});
|
|
75
82
|
|
|
76
83
|
it('test repeat options popup', async () => {
|
|
@@ -137,7 +144,11 @@ describe('Test SetSchedule', () => {
|
|
|
137
144
|
repeat: 'once',
|
|
138
145
|
time_repeat: '12:00:00',
|
|
139
146
|
weekday_repeat: [],
|
|
147
|
+
type: 'schedule',
|
|
148
|
+
unit: 1,
|
|
140
149
|
},
|
|
150
|
+
closeScreen: 'UnitDetail',
|
|
151
|
+
unitId: 1,
|
|
141
152
|
});
|
|
142
153
|
});
|
|
143
154
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import AntDesign from 'react-native-vector-icons/AntDesign';
|
|
3
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
4
4
|
import Text from '../../../../commons/Text';
|
|
5
|
-
import styles from '../styles/RowItemStyles';
|
|
6
5
|
import { Colors } from '../../../../configs';
|
|
6
|
+
import styles from '../styles/RowItemStyles';
|
|
7
7
|
|
|
8
8
|
const RowItem = ({ title, value, icon = null, arrow = false, onPress }) => {
|
|
9
9
|
return (
|
|
@@ -17,8 +17,8 @@ const RowItem = ({ title, value, icon = null, arrow = false, onPress }) => {
|
|
|
17
17
|
</Text>
|
|
18
18
|
</View>
|
|
19
19
|
<View style={[styles.itemRight, arrow && styles.center]}>
|
|
20
|
-
{arrow && <
|
|
21
|
-
{icon && <
|
|
20
|
+
{arrow && <IconOutline name="right" color={Colors.Gray7} />}
|
|
21
|
+
{icon && <IconOutline name={icon} size={17} color={Colors.Black} />}
|
|
22
22
|
</View>
|
|
23
23
|
</TouchableOpacity>
|
|
24
24
|
);
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import React, { memo, useCallback, useState } from 'react';
|
|
2
|
-
import { ScrollView } from 'react-native';
|
|
3
1
|
import { useNavigation } from '@react-navigation/native';
|
|
4
2
|
import moment from 'moment';
|
|
5
|
-
import
|
|
3
|
+
import React, { memo, useCallback, useState } from 'react';
|
|
4
|
+
import { ScrollView } from 'react-native';
|
|
6
5
|
import Calendar from '../../../commons/Calendar';
|
|
6
|
+
import WheelDateTimePicker from '../../../commons/WheelDateTimePicker';
|
|
7
|
+
import { useBoolean } from '../../../hooks/Common';
|
|
8
|
+
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
9
|
+
import Routes from '../../../utils/Route';
|
|
10
|
+
import NewActionWrapper from '../AddNewAction/NewActionWrapper';
|
|
7
11
|
import RepeatOptionsPopup, {
|
|
8
12
|
REPEAT_OPTIONS,
|
|
9
13
|
} from './components/RepeatOptionsPopup';
|
|
10
14
|
import RowItem from './components/RowItem';
|
|
11
15
|
import SelectWeekday from './components/SelectWeekday';
|
|
12
|
-
import { useBoolean } from '../../../hooks/Common';
|
|
13
|
-
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
14
16
|
import styles from './styles/indexStyles';
|
|
15
|
-
import Routes from '../../../utils/Route';
|
|
16
|
-
import NewActionWrapper from '../AddNewAction/NewActionWrapper';
|
|
17
17
|
|
|
18
18
|
const SetSchedule = ({ route }) => {
|
|
19
19
|
const t = useTranslations();
|
|
@@ -54,6 +54,7 @@ const SetSchedule = ({ route }) => {
|
|
|
54
54
|
date_repeat: date.format('YYYY-MM-DD'),
|
|
55
55
|
weekday_repeat: weekday,
|
|
56
56
|
},
|
|
57
|
+
unitId: automate.unit,
|
|
57
58
|
});
|
|
58
59
|
}, [navigate, closeScreen, automate, repeat, time, date, weekday]);
|
|
59
60
|
|
|
@@ -76,7 +76,6 @@ describe('Test MultiUnits', () => {
|
|
|
76
76
|
params: {
|
|
77
77
|
isMultiUnits: true,
|
|
78
78
|
unitName: null,
|
|
79
|
-
unit: null,
|
|
80
79
|
},
|
|
81
80
|
});
|
|
82
81
|
await act(async () => {
|
|
@@ -111,7 +110,6 @@ describe('Test MultiUnits', () => {
|
|
|
111
110
|
expect(global.mockedNavigate).toBeCalledWith(Routes.UnitStack, {
|
|
112
111
|
screen: Routes.ScriptDetail,
|
|
113
112
|
params: {
|
|
114
|
-
id: response[1].id,
|
|
115
113
|
preAutomate: response[1],
|
|
116
114
|
},
|
|
117
115
|
});
|
|
@@ -120,7 +118,7 @@ describe('Test MultiUnits', () => {
|
|
|
120
118
|
ItemAddNews[0].props.onAddNew();
|
|
121
119
|
});
|
|
122
120
|
expect(global.mockedNavigate).toBeCalledWith(Routes.UnitStack, {
|
|
123
|
-
screen: Routes.
|
|
121
|
+
screen: Routes.AddAutomationTypeSmart,
|
|
124
122
|
params: {
|
|
125
123
|
automate: { unit: undefined },
|
|
126
124
|
closeScreen: undefined,
|
|
@@ -264,7 +262,6 @@ describe('Test MultiUnits', () => {
|
|
|
264
262
|
params: {
|
|
265
263
|
isMultiUnits: true,
|
|
266
264
|
unitName: null,
|
|
267
|
-
unit: null,
|
|
268
265
|
},
|
|
269
266
|
});
|
|
270
267
|
await act(async () => {
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { IconFill } from '@ant-design/icons-react-native';
|
|
2
|
+
import {
|
|
3
|
+
useIsFocused,
|
|
4
|
+
useNavigation,
|
|
5
|
+
useRoute,
|
|
6
|
+
} from '@react-navigation/native';
|
|
1
7
|
import React, {
|
|
2
8
|
useCallback,
|
|
3
9
|
useEffect,
|
|
@@ -6,27 +12,21 @@ import React, {
|
|
|
6
12
|
useState,
|
|
7
13
|
} from 'react';
|
|
8
14
|
import { FlatList, Image, TouchableOpacity, View } from 'react-native';
|
|
9
|
-
import AntDesign from 'react-native-vector-icons/AntDesign';
|
|
10
|
-
import {
|
|
11
|
-
useIsFocused,
|
|
12
|
-
useNavigation,
|
|
13
|
-
useRoute,
|
|
14
|
-
} from '@react-navigation/native';
|
|
15
15
|
import { useSCContextSelector } from '../../context';
|
|
16
16
|
|
|
17
|
-
import
|
|
17
|
+
import ItemAddNew from '../../commons/Device/ItemAddNew';
|
|
18
|
+
import ItemOneTap from '../../commons/SubUnit/OneTap/ItemOneTap';
|
|
19
|
+
import Text from '../../commons/Text';
|
|
18
20
|
import { API, Colors, Images } from '../../configs';
|
|
21
|
+
import { AccessibilityLabel, UNIT_TYPES } from '../../configs/Constants';
|
|
22
|
+
import { useGetIdUser } from '../../hooks/Common';
|
|
23
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
19
24
|
import { axiosGet } from '../../utils/Apis/axios';
|
|
20
|
-
import
|
|
21
|
-
import ItemOneTap from '../../commons/SubUnit/OneTap/ItemOneTap';
|
|
25
|
+
import { useBackendPermission } from '../../utils/Permission/backend';
|
|
22
26
|
import Routes from '../../utils/Route';
|
|
23
|
-
import Loading from './Components/Loading';
|
|
24
|
-
import ItemAddNew from '../../commons/Device/ItemAddNew';
|
|
25
|
-
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
26
|
-
import { useGetIdUser } from '../../hooks/Common';
|
|
27
|
-
import { AccessibilityLabel, UNIT_TYPES } from '../../configs/Constants';
|
|
28
27
|
import { keyExtractor, ToastBottomHelper } from '../../utils/Utils';
|
|
29
|
-
import
|
|
28
|
+
import Loading from './Components/Loading';
|
|
29
|
+
import styles from './Styles/indexStyles';
|
|
30
30
|
|
|
31
31
|
const Automate = () => {
|
|
32
32
|
const t = useTranslations();
|
|
@@ -75,7 +75,6 @@ const Automate = () => {
|
|
|
75
75
|
navigate(Routes.UnitStack, {
|
|
76
76
|
screen: Routes.ScriptDetail,
|
|
77
77
|
params: {
|
|
78
|
-
id: item?.id,
|
|
79
78
|
closeScreen: currentRouteName,
|
|
80
79
|
preAutomate: item, // pre-loaded automate data
|
|
81
80
|
},
|
|
@@ -164,29 +163,32 @@ const Automate = () => {
|
|
|
164
163
|
<Image source={Images.arrowBack} style={styles.arrowRight} />
|
|
165
164
|
</TouchableOpacity>
|
|
166
165
|
</View>
|
|
167
|
-
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
isOwner={isOwner}
|
|
171
|
-
automate={automates[0]}
|
|
172
|
-
wrapSyles={styles.wrapAutomateItem}
|
|
173
|
-
onPressItem={() =>
|
|
174
|
-
onPressItem(automates[0], unit_id, type, isOwner)
|
|
175
|
-
}
|
|
176
|
-
/>
|
|
177
|
-
{!!automates[1] && (
|
|
166
|
+
<View style={styles.automatesRow}>
|
|
167
|
+
{!!automates?.length && (
|
|
168
|
+
<>
|
|
178
169
|
<ItemOneTap
|
|
179
170
|
isOwner={isOwner}
|
|
180
|
-
automate={automates[
|
|
171
|
+
automate={automates[0]}
|
|
181
172
|
wrapSyles={styles.wrapAutomateItem}
|
|
182
173
|
onPressItem={() =>
|
|
183
|
-
onPressItem(automates[
|
|
174
|
+
onPressItem(automates[0], unit_id, type, isOwner)
|
|
184
175
|
}
|
|
185
176
|
/>
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
177
|
+
{!!automates[1] && (
|
|
178
|
+
<ItemOneTap
|
|
179
|
+
isOwner={isOwner}
|
|
180
|
+
automate={automates[1]}
|
|
181
|
+
wrapSyles={styles.wrapAutomateItem}
|
|
182
|
+
onPressItem={() =>
|
|
183
|
+
onPressItem(automates[1], unit_id, type, isOwner)
|
|
184
|
+
}
|
|
185
|
+
/>
|
|
186
|
+
)}
|
|
187
|
+
</>
|
|
188
|
+
)}
|
|
189
|
+
{(!automates?.length || automates.length === 1) &&
|
|
190
|
+
renderListFooterComponent(unit_id, automates)}
|
|
191
|
+
</View>
|
|
190
192
|
</View>
|
|
191
193
|
);
|
|
192
194
|
},
|
|
@@ -210,7 +212,7 @@ const Automate = () => {
|
|
|
210
212
|
/* istanbul ignore next */
|
|
211
213
|
headerRight: () => (
|
|
212
214
|
<TouchableOpacity style={styles.buttonAdd}>
|
|
213
|
-
<
|
|
215
|
+
<IconFill name={'plus-circle'} size={28} color={Colors.Orange} />
|
|
214
216
|
</TouchableOpacity>
|
|
215
217
|
),
|
|
216
218
|
});
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { act, create } from 'react-test-renderer';
|
|
3
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
4
1
|
import { useRoute } from '@react-navigation/native';
|
|
2
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
3
|
+
import React from 'react';
|
|
5
4
|
import DraggableFlatList from 'react-native-draggable-flatlist';
|
|
5
|
+
import { act, create } from 'react-test-renderer';
|
|
6
6
|
|
|
7
7
|
import ChangePosition from '../';
|
|
8
|
+
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
9
|
+
import { API } from '../../../configs';
|
|
8
10
|
import { SCProvider } from '../../../context';
|
|
9
11
|
import { mockSCStore } from '../../../context/mockStore';
|
|
10
12
|
import api from '../../../utils/Apis/axios';
|
|
11
|
-
import { API } from '../../../configs';
|
|
12
13
|
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
13
|
-
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
14
14
|
|
|
15
15
|
const mock = new MockAdapter(api.axiosInstance);
|
|
16
16
|
const mockSetDisplay = jest.fn();
|
|
@@ -60,6 +60,6 @@ describe('Test ChangePosition', () => {
|
|
|
60
60
|
expect(global.mockedGoBack).toHaveBeenCalled();
|
|
61
61
|
expect(mockFetchData).toHaveBeenCalled();
|
|
62
62
|
expect(mockSetDisplay).toHaveBeenCalled();
|
|
63
|
-
expect(spyToastSuccess).
|
|
63
|
+
expect(spyToastSuccess).toHaveBeenCalledWith('Updated widget successfully');
|
|
64
64
|
});
|
|
65
65
|
});
|
|
@@ -49,7 +49,8 @@ const ChangePosition = () => {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
const renderItem = ({ item,
|
|
52
|
+
const renderItem = ({ item, getIndex, drag, isActive }) => {
|
|
53
|
+
const index = getIndex();
|
|
53
54
|
return (
|
|
54
55
|
<View style={styles.widgetItem}>
|
|
55
56
|
<View style={[styles.itemOrder, isActive ? styles.isDragging : {}]}>
|