@eohjsc/react-native-smart-city 0.3.91 → 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__/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 +3 -3
- package/src/commons/ActionTemplate/CurtainActionStyles.js +1 -1
- package/src/commons/ActionTemplate/OnOffButtonAction.js +2 -2
- package/src/commons/ActionTemplate/OnOffButtonActionStyles.js +1 -1
- package/src/commons/ActionTemplate/OnOffSimpleAction.js +2 -2
- package/src/commons/ActionTemplate/OnOffSimpleActionStyles.js +1 -1
- package/src/commons/ActionTemplate/OnOffSmartLockAction.js +2 -2
- package/src/commons/ActionTemplate/OnOffSmartLockActionStyles.js +1 -1
- package/src/commons/ActionTemplate/OneButtonAction.js +1 -1
- package/src/commons/ActionTemplate/OneButtonActionStyles.js +1 -1
- package/src/commons/ActionTemplate/ThreeButtonAction.js +3 -3
- package/src/commons/ActionTemplate/ThreeButtonActionStyles.js +1 -1
- package/src/commons/Auth/AccountList.js +1 -1
- package/src/commons/Auth/__test__/OtpInputList.test.js +13 -17
- package/src/commons/Automate/ItemAutomate.js +10 -4
- package/src/commons/Automate/__test__/ItemAutomate.test.js +11 -11
- package/src/commons/Device/DeviceAlertStatus.js +2 -1
- package/src/commons/Device/ProgressBar/index.js +5 -11
- package/src/commons/Device/ProgressBar/styles.js +11 -3
- 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 +4 -2
- 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__/TextInput.test.js +1 -1
- 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/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 +1 -1
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplateStyles.js +1 -1
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +1 -1
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplateStyles.js +1 -1
- package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +1 -1
- package/src/commons/OneTapTemplate/StatesGridActionTemplateStyles.js +1 -1
- package/src/commons/PreventAccess/index.js +1 -1
- package/src/commons/Sharing/StationDevicePermissions.js +4 -4
- package/src/commons/Sharing/WrapHeaderScrollable.js +5 -5
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +2 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +7 -11
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +11 -6
- package/src/commons/SubUnit/OneTap/index.js +19 -6
- package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +4 -0
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +1 -1
- package/src/configs/API.js +6 -0
- package/src/configs/AccessibilityLabel.js +1 -0
- package/src/configs/Colors.js +1 -1
- package/src/configs/Constants.js +12 -18
- 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 +33 -9
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +8 -31
- package/src/screens/AddNewAutoSmart/index.js +24 -60
- package/src/screens/AddNewGateway/SelectDeviceSubUnit.js +1 -2
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +5 -17
- package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +5 -13
- package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +9 -11
- package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -14
- package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -14
- package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +3 -2
- package/src/screens/AddNewGateway/index.js +1 -1
- package/src/screens/AllCamera/index.js +2 -3
- 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/{AddNewAction → Automate/AddNewAction}/ChooseAction.js +78 -119
- package/src/screens/{AddNewAction → Automate/AddNewAction}/ChooseConfig.js +45 -73
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/LoadingSelectAction.js +1 -1
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Components/SelectDevices.js +3 -3
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/DeviceStyles.js +5 -1
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/__test__/index.test.js +3 -3
- package/src/screens/{AddNewAction → Automate/AddNewAction}/Device/index.js +5 -4
- package/src/screens/{AddNewAction → Automate/AddNewAction}/NewActionWrapper.js +11 -10
- package/src/screens/{AddNewAction → Automate/AddNewAction}/SelectControlDevices.js +11 -49
- package/src/screens/{AddNewAction → Automate/AddNewAction}/SelectMonitorDevices.js +10 -42
- package/src/screens/{AddNewAction → Automate/AddNewAction}/SetupConfigCondition.js +52 -101
- 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 +4 -2
- package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/ChooseAction.test.js +10 -11
- package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/ChooseConfig.test.js +26 -27
- package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/SelectControlDevices.test.js +9 -9
- package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/SelectMonitorDevices.test.js +5 -5
- package/src/screens/{AddNewAction → Automate/AddNewAction}/__test__/SetupSensor.test.js +43 -13
- 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 +6 -6
- package/src/screens/{EditActionsList → Automate/EditActionsList}/index.js +18 -19
- package/src/screens/Automate/MultiUnits.js +68 -66
- 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 +69 -72
- 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/{ScriptDetail → Automate/ScriptDetail}/utils.js +32 -31
- 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 +76 -120
- package/src/screens/Automate/__test__/index.test.js +2 -9
- package/src/screens/Automate/constants.js +0 -0
- package/src/screens/Automate/index.js +11 -22
- 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__/detail.test.js +202 -257
- package/src/screens/Device/__test__/sensorDisplayItem.test.js +4 -0
- package/src/screens/Device/components/SensorDisplayItem.js +2 -1
- package/src/screens/Device/components/VisualChart.js +55 -8
- 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 +20 -2
- package/src/screens/Device/styles.js +7 -0
- 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 +1 -1
- package/src/screens/PlayBackCamera/index.js +2 -3
- package/src/screens/SharedUnit/index.js +5 -4
- 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/index.js +1 -0
- 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 +14 -20
- 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 +3 -1
- package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +1 -1
- package/src/screens/Unit/__test__/SmartAccount.test.js +8 -14
- package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +4 -0
- package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +6 -11
- package/src/screens/WaterQualityGuide/index.js +10 -5
- package/src/utils/I18n/translations/en.json +23 -18
- package/src/utils/I18n/translations/vi.json +21 -18
- package/src/utils/Route/index.js +3 -0
- 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 -46
- 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/AddNewOneTap/index.js +0 -156
- package/src/screens/ScriptDetail/hooks/index.js +0 -136
- package/src/screens/ScriptDetail/index.js +0 -446
- 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
|
@@ -2,119 +2,87 @@ import React, { useCallback, useEffect, useState } from 'react';
|
|
|
2
2
|
import { Image, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import { useNavigation } from '@react-navigation/native';
|
|
4
4
|
|
|
5
|
-
import { useTranslations } from '
|
|
6
|
-
import Text from '
|
|
7
|
-
import { axiosGet } from '
|
|
8
|
-
import { API, Colors, Images } from '
|
|
9
|
-
import Routes from '
|
|
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
10
|
import styles from './Styles/SelectActionStyles';
|
|
11
|
-
import { TitleCheckBox } from '
|
|
11
|
+
import { TitleCheckBox } from '../../Sharing/Components';
|
|
12
12
|
import { LoadingSelectAction } from './Components';
|
|
13
|
-
import { ToastBottomHelper } from '
|
|
13
|
+
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
14
14
|
import {
|
|
15
15
|
generateAutomationConditionText,
|
|
16
16
|
generateAutomationDataConditionText,
|
|
17
|
-
getAutomationData,
|
|
18
17
|
} from '../ScriptDetail/utils';
|
|
19
|
-
import { useSCContextSelector } from '
|
|
20
|
-
import { AUTOMATE_TYPE } from '
|
|
18
|
+
import { useSCContextSelector } from '../../../context';
|
|
19
|
+
import { AUTOMATE_TYPE } from '../../../configs/Constants';
|
|
21
20
|
import NewActionWrapper from './NewActionWrapper';
|
|
22
21
|
|
|
23
22
|
const ChooseConfig = ({ route }) => {
|
|
24
23
|
const t = useTranslations();
|
|
25
24
|
const { navigate } = useNavigation();
|
|
26
25
|
const {
|
|
27
|
-
unit,
|
|
28
26
|
device,
|
|
29
|
-
automateId,
|
|
30
27
|
automate = {},
|
|
31
|
-
|
|
32
|
-
type,
|
|
33
|
-
isAutomateTab,
|
|
34
|
-
isMultiUnits,
|
|
35
|
-
newSensorData,
|
|
28
|
+
newCondition,
|
|
36
29
|
closeScreen,
|
|
37
30
|
} = route?.params || {};
|
|
38
31
|
|
|
39
|
-
const [
|
|
32
|
+
const [configs, setConfigs] = useState([]);
|
|
40
33
|
const [checkedItem, setCheckedItem] = useState({ id: automate?.config_id });
|
|
41
34
|
const [isLoading, setIsLoading] = useState(false);
|
|
42
35
|
const valueEvaluations = useSCContextSelector((state) => {
|
|
43
36
|
return state.valueEvaluations;
|
|
44
37
|
});
|
|
45
|
-
|
|
38
|
+
const [conditions, setConditions] = useState({});
|
|
46
39
|
const fetchData = useCallback(async () => {
|
|
47
40
|
setIsLoading(true);
|
|
48
|
-
const
|
|
49
|
-
if (type === AUTOMATE_TYPE.EVENT) {
|
|
50
|
-
|
|
41
|
+
const params = {};
|
|
42
|
+
if (automate?.type === AUTOMATE_TYPE.EVENT) {
|
|
43
|
+
params.type = 'event';
|
|
51
44
|
}
|
|
52
45
|
|
|
53
46
|
const { success, data: automateData } = await axiosGet(
|
|
54
47
|
API.AUTOMATE.DISPLAY_CONFIGS(device.id),
|
|
55
|
-
|
|
48
|
+
{ params }
|
|
56
49
|
);
|
|
50
|
+
|
|
57
51
|
if (success) {
|
|
58
|
-
|
|
52
|
+
setConfigs(automateData);
|
|
59
53
|
}
|
|
60
54
|
setIsLoading(false);
|
|
61
|
-
}, [device.id, type]);
|
|
55
|
+
}, [device.id, automate?.type]);
|
|
62
56
|
|
|
63
57
|
const onSave = useCallback(() => {
|
|
64
|
-
let
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// todo Bang refactor remove this using same data format for get/push
|
|
69
|
-
if ([null, undefined].includes(itemTemp?.value) && isDefault) {
|
|
70
|
-
itemTemp = getAutomationData(type, automate);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if ([null, undefined].includes(itemTemp?.value)) {
|
|
58
|
+
let condition = conditions[checkedItem?.id];
|
|
59
|
+
const isDefault =
|
|
60
|
+
automate?.config_id && automate?.config_id === checkedItem?.id;
|
|
61
|
+
if (!condition && !isDefault) {
|
|
74
62
|
ToastBottomHelper.error(t('please_choose_condition_before_continue'));
|
|
75
63
|
return;
|
|
76
64
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
type,
|
|
80
|
-
unit,
|
|
81
|
-
isAutomateTab,
|
|
82
|
-
isMultiUnits,
|
|
83
|
-
automateId,
|
|
65
|
+
|
|
66
|
+
navigate(Routes.ValueChangeName, {
|
|
84
67
|
automate: {
|
|
85
68
|
...automate,
|
|
86
|
-
...
|
|
69
|
+
...condition,
|
|
87
70
|
},
|
|
88
|
-
|
|
71
|
+
closeScreen,
|
|
89
72
|
});
|
|
90
|
-
}, [
|
|
91
|
-
sensorData,
|
|
92
|
-
navigate,
|
|
93
|
-
type,
|
|
94
|
-
unit,
|
|
95
|
-
isAutomateTab,
|
|
96
|
-
isMultiUnits,
|
|
97
|
-
automateId,
|
|
98
|
-
automate,
|
|
99
|
-
scriptName,
|
|
100
|
-
checkedItem?.id,
|
|
101
|
-
t,
|
|
102
|
-
]);
|
|
73
|
+
}, [conditions, checkedItem?.id, navigate, automate, closeScreen, t]);
|
|
103
74
|
|
|
104
75
|
const onChecked = useCallback(
|
|
105
76
|
(_, isChecked, id) => {
|
|
106
|
-
setCheckedItem(isChecked ?
|
|
77
|
+
setCheckedItem(isChecked ? configs.find((i) => i?.id === id) : {});
|
|
107
78
|
},
|
|
108
|
-
[
|
|
79
|
+
[configs]
|
|
109
80
|
);
|
|
110
81
|
|
|
111
82
|
const onPressItem = (item) => () => {
|
|
112
83
|
navigate(Routes.SetupConfigCondition, {
|
|
113
84
|
item,
|
|
114
|
-
|
|
115
|
-
isAutomateTab,
|
|
116
|
-
type,
|
|
117
|
-
automate,
|
|
85
|
+
defaultCondition: conditions[item.id],
|
|
118
86
|
closeScreen,
|
|
119
87
|
});
|
|
120
88
|
};
|
|
@@ -122,8 +90,9 @@ const ChooseConfig = ({ route }) => {
|
|
|
122
90
|
const renderCondition = useCallback(
|
|
123
91
|
(item) => {
|
|
124
92
|
return generateAutomationDataConditionText(
|
|
125
|
-
type,
|
|
126
|
-
item,
|
|
93
|
+
automate?.type,
|
|
94
|
+
item.name,
|
|
95
|
+
conditions[item.id],
|
|
127
96
|
item.value_evaluation || {
|
|
128
97
|
// backward compatible
|
|
129
98
|
template: item.evaluate_template,
|
|
@@ -132,7 +101,7 @@ const ChooseConfig = ({ route }) => {
|
|
|
132
101
|
t
|
|
133
102
|
);
|
|
134
103
|
},
|
|
135
|
-
[
|
|
104
|
+
[automate?.type, conditions, t]
|
|
136
105
|
);
|
|
137
106
|
|
|
138
107
|
useEffect(() => {
|
|
@@ -140,8 +109,12 @@ const ChooseConfig = ({ route }) => {
|
|
|
140
109
|
}, [fetchData]);
|
|
141
110
|
|
|
142
111
|
useEffect(() => {
|
|
143
|
-
|
|
144
|
-
|
|
112
|
+
newCondition &&
|
|
113
|
+
setConditions((prev) => ({
|
|
114
|
+
...prev,
|
|
115
|
+
[newCondition.config]: newCondition,
|
|
116
|
+
}));
|
|
117
|
+
}, [newCondition]);
|
|
145
118
|
|
|
146
119
|
return (
|
|
147
120
|
<NewActionWrapper
|
|
@@ -153,8 +126,8 @@ const ChooseConfig = ({ route }) => {
|
|
|
153
126
|
{isLoading ? (
|
|
154
127
|
<LoadingSelectAction style={styles.container} />
|
|
155
128
|
) : (
|
|
156
|
-
|
|
157
|
-
const
|
|
129
|
+
configs.map((item) => {
|
|
130
|
+
const hasCondition = conditions[item.id];
|
|
158
131
|
const isChecked = checkedItem?.id === item?.id;
|
|
159
132
|
const isDefault = automate?.config_id === item?.id;
|
|
160
133
|
return (
|
|
@@ -181,18 +154,17 @@ const ChooseConfig = ({ route }) => {
|
|
|
181
154
|
semibold={isChecked}
|
|
182
155
|
style={styles.description}
|
|
183
156
|
>
|
|
184
|
-
{
|
|
157
|
+
{hasCondition
|
|
185
158
|
? renderCondition(item)
|
|
186
159
|
: isDefault
|
|
187
160
|
? generateAutomationConditionText(
|
|
188
|
-
type,
|
|
189
161
|
automate,
|
|
190
162
|
valueEvaluations[automate?.config_id],
|
|
191
163
|
t
|
|
192
164
|
)
|
|
193
165
|
: t('no_condition')}
|
|
194
166
|
</Text>
|
|
195
|
-
{
|
|
167
|
+
{hasCondition && (
|
|
196
168
|
<Image source={Images.arrowBack} style={styles.arrowRight} />
|
|
197
169
|
)}
|
|
198
170
|
</TouchableOpacity>
|
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}>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { View } from 'react-native';
|
|
2
2
|
import styles from '../Styles/SelectSensorDevicesStyles';
|
|
3
|
-
import Text from '
|
|
4
|
-
import NavBar from '
|
|
3
|
+
import Text from '../../../../commons/Text';
|
|
4
|
+
import NavBar from '../../../../commons/NavBar';
|
|
5
5
|
import Device from '../Device';
|
|
6
6
|
import React, { useCallback, useState } from 'react';
|
|
7
|
-
import { useTranslations } from '
|
|
7
|
+
import { useTranslations } from '../../../../hooks/Common/useTranslations';
|
|
8
8
|
import NewActionWrapper from '../NewActionWrapper';
|
|
9
9
|
|
|
10
10
|
const 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({})}>
|
|
@@ -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}>
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import React, { useCallback, useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { KeyboardAvoidingView, Platform, TouchableOpacity } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import styles from './Styles/SelectActionStyles';
|
|
5
|
-
import
|
|
6
|
-
import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
|
|
5
|
+
import WrapHeaderScrollable from '../../../commons/Sharing/WrapHeaderScrollable';
|
|
7
6
|
import { Icon } from '@ant-design/react-native';
|
|
8
|
-
import { Colors } from '
|
|
7
|
+
import { Colors } from '../../../configs';
|
|
9
8
|
import { useNavigation, useRoute } from '@react-navigation/native';
|
|
10
|
-
import BottomButtonView from '
|
|
11
|
-
import { AccessibilityLabel } from '
|
|
9
|
+
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
10
|
+
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
12
11
|
|
|
13
12
|
const NewActionWrapper = ({ name, children, canNext, onNext, nextTitle }) => {
|
|
14
|
-
const t = useTranslations();
|
|
15
13
|
const { navigate } = useNavigation();
|
|
16
14
|
const { params = {} } = useRoute();
|
|
17
15
|
const { closeScreen } = params;
|
|
@@ -34,9 +32,12 @@ const NewActionWrapper = ({ name, children, canNext, onNext, nextTitle }) => {
|
|
|
34
32
|
);
|
|
35
33
|
|
|
36
34
|
return (
|
|
37
|
-
<
|
|
35
|
+
<KeyboardAvoidingView
|
|
36
|
+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
37
|
+
style={styles.wrap}
|
|
38
|
+
>
|
|
38
39
|
<WrapHeaderScrollable
|
|
39
|
-
title={
|
|
40
|
+
title={name}
|
|
40
41
|
headerAniStyle={styles.headerAniStyle}
|
|
41
42
|
rightComponent={rightComponent}
|
|
42
43
|
>
|
|
@@ -48,7 +49,7 @@ const NewActionWrapper = ({ name, children, canNext, onNext, nextTitle }) => {
|
|
|
48
49
|
onPressMain={onNext}
|
|
49
50
|
typeMain={canNext ? 'primary' : 'disabled'}
|
|
50
51
|
/>
|
|
51
|
-
</
|
|
52
|
+
</KeyboardAvoidingView>
|
|
52
53
|
);
|
|
53
54
|
};
|
|
54
55
|
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { useNavigation } from '@react-navigation/native';
|
|
3
|
-
import { fetchWithCache } from '
|
|
4
|
-
import { API } from '
|
|
5
|
-
import Routes from '
|
|
3
|
+
import { fetchWithCache } from '../../../utils/Apis/axios';
|
|
4
|
+
import { API } from '../../../configs';
|
|
5
|
+
import Routes from '../../../utils/Route';
|
|
6
6
|
import SelectDevices from './Components/SelectDevices';
|
|
7
|
-
import { useTranslations } from '
|
|
7
|
+
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
8
8
|
|
|
9
9
|
const SelectControlDevices = ({ route }) => {
|
|
10
10
|
const t = useTranslations();
|
|
11
|
-
const {
|
|
12
|
-
unit,
|
|
13
|
-
automateId,
|
|
14
|
-
automate = {},
|
|
15
|
-
type,
|
|
16
|
-
scriptName,
|
|
17
|
-
isAutomateTab,
|
|
18
|
-
isCreateNewAction,
|
|
19
|
-
isMultiUnits,
|
|
20
|
-
oldType,
|
|
21
|
-
closeScreen,
|
|
22
|
-
} = route?.params || {};
|
|
11
|
+
const { unitId, closeScreen, automateId } = route?.params || {};
|
|
23
12
|
|
|
24
13
|
const [stations, setStations] = useState([]);
|
|
25
14
|
const [listStation, setListStation] = useState([]);
|
|
@@ -29,7 +18,7 @@ const SelectControlDevices = ({ route }) => {
|
|
|
29
18
|
const [loading, setLoading] = useState(true);
|
|
30
19
|
|
|
31
20
|
const fetchDetails = useCallback(async () => {
|
|
32
|
-
await fetchWithCache(API.UNIT.DEVICE_CONTROL(
|
|
21
|
+
await fetchWithCache(API.UNIT.DEVICE_CONTROL(unitId), {}, (response) => {
|
|
33
22
|
const { success, data } = response;
|
|
34
23
|
if (success) {
|
|
35
24
|
const newData = data.filter((item) => item.sensors.length > 0);
|
|
@@ -44,48 +33,22 @@ const SelectControlDevices = ({ route }) => {
|
|
|
44
33
|
}
|
|
45
34
|
});
|
|
46
35
|
setLoading(false);
|
|
47
|
-
}, [
|
|
36
|
+
}, [unitId]);
|
|
48
37
|
|
|
49
38
|
useEffect(() => {
|
|
50
39
|
fetchDetails();
|
|
51
40
|
}, [fetchDetails]);
|
|
52
41
|
|
|
53
42
|
const onPressContinue = useCallback(
|
|
54
|
-
(selectedDevice
|
|
43
|
+
(selectedDevice) => {
|
|
55
44
|
navigate(Routes.ChooseAction, {
|
|
56
|
-
|
|
45
|
+
unitId,
|
|
46
|
+
automateId,
|
|
57
47
|
device: selectedDevice,
|
|
58
|
-
automateId: automateId,
|
|
59
|
-
automate: {
|
|
60
|
-
...automate,
|
|
61
|
-
sensor_id: selectedDevice?.id
|
|
62
|
-
? selectedDevice.id
|
|
63
|
-
: automate.sensor_id,
|
|
64
|
-
},
|
|
65
|
-
stationName: stations[indexStation]?.name,
|
|
66
|
-
type,
|
|
67
|
-
scriptName,
|
|
68
|
-
isAutomateTab,
|
|
69
|
-
isCreateNewAction,
|
|
70
|
-
isMultiUnits,
|
|
71
|
-
oldType,
|
|
72
48
|
closeScreen,
|
|
73
49
|
});
|
|
74
50
|
},
|
|
75
|
-
[
|
|
76
|
-
navigate,
|
|
77
|
-
unit,
|
|
78
|
-
automateId,
|
|
79
|
-
automate,
|
|
80
|
-
stations,
|
|
81
|
-
type,
|
|
82
|
-
scriptName,
|
|
83
|
-
isAutomateTab,
|
|
84
|
-
isCreateNewAction,
|
|
85
|
-
isMultiUnits,
|
|
86
|
-
oldType,
|
|
87
|
-
closeScreen,
|
|
88
|
-
]
|
|
51
|
+
[navigate, unitId, automateId, closeScreen]
|
|
89
52
|
);
|
|
90
53
|
|
|
91
54
|
if (loading) {
|
|
@@ -95,7 +58,6 @@ const SelectControlDevices = ({ route }) => {
|
|
|
95
58
|
return (
|
|
96
59
|
<SelectDevices
|
|
97
60
|
onPressContinue={onPressContinue}
|
|
98
|
-
automateId={automateId}
|
|
99
61
|
listStation={listStation}
|
|
100
62
|
listMenuItem={listMenuItem}
|
|
101
63
|
stations={stations}
|
|
@@ -1,27 +1,16 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { useNavigation } from '@react-navigation/native';
|
|
3
3
|
|
|
4
|
-
import { useTranslations } from '
|
|
5
|
-
import { fetchWithCache } from '
|
|
6
|
-
import { API } from '
|
|
7
|
-
import Routes from '
|
|
4
|
+
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
5
|
+
import { fetchWithCache } from '../../../utils/Apis/axios';
|
|
6
|
+
import { API } from '../../../configs';
|
|
7
|
+
import Routes from '../../../utils/Route';
|
|
8
8
|
import SelectDevices from './Components/SelectDevices';
|
|
9
|
-
import { AUTOMATE_TYPE } from '
|
|
9
|
+
import { AUTOMATE_TYPE } from '../../../configs/Constants';
|
|
10
10
|
|
|
11
11
|
const SelectMonitorDevices = ({ route }) => {
|
|
12
12
|
const t = useTranslations();
|
|
13
|
-
const {
|
|
14
|
-
unit,
|
|
15
|
-
automateId,
|
|
16
|
-
automate = {},
|
|
17
|
-
type,
|
|
18
|
-
scriptName,
|
|
19
|
-
isAutomateTab,
|
|
20
|
-
isCreateNewAction,
|
|
21
|
-
isMultiUnits,
|
|
22
|
-
oldType,
|
|
23
|
-
closeScreen,
|
|
24
|
-
} = route?.params || {};
|
|
13
|
+
const { automate = {}, isCreateNewAction, closeScreen } = route?.params || {};
|
|
25
14
|
|
|
26
15
|
const [stations, setStations] = useState([]);
|
|
27
16
|
const [listStation, setListStation] = useState([]);
|
|
@@ -33,11 +22,11 @@ const SelectMonitorDevices = ({ route }) => {
|
|
|
33
22
|
|
|
34
23
|
const fetchDetails = useCallback(async () => {
|
|
35
24
|
const configs = { params: {} };
|
|
36
|
-
if (type === AUTOMATE_TYPE.EVENT) {
|
|
25
|
+
if (automate?.type === AUTOMATE_TYPE.EVENT) {
|
|
37
26
|
configs.params.type = 'event';
|
|
38
27
|
}
|
|
39
28
|
await fetchWithCache(
|
|
40
|
-
API.UNIT.DEVICE_SENSOR(unit
|
|
29
|
+
API.UNIT.DEVICE_SENSOR(automate?.unit),
|
|
41
30
|
configs,
|
|
42
31
|
(response) => {
|
|
43
32
|
const { success, data } = response;
|
|
@@ -56,7 +45,7 @@ const SelectMonitorDevices = ({ route }) => {
|
|
|
56
45
|
}
|
|
57
46
|
);
|
|
58
47
|
setLoading(false);
|
|
59
|
-
}, [type, unit
|
|
48
|
+
}, [automate?.type, automate?.unit]);
|
|
60
49
|
|
|
61
50
|
useEffect(() => {
|
|
62
51
|
if (!automate?.sensor_id) {
|
|
@@ -86,9 +75,7 @@ const SelectMonitorDevices = ({ route }) => {
|
|
|
86
75
|
const onPressContinue = useCallback(
|
|
87
76
|
(selectedDevice, indexStation) => {
|
|
88
77
|
navigate(Routes.ChooseConfig, {
|
|
89
|
-
unit,
|
|
90
78
|
device: selectedDevice,
|
|
91
|
-
automateId: automateId,
|
|
92
79
|
automate: {
|
|
93
80
|
...automate,
|
|
94
81
|
sensor_id: selectedDevice?.id
|
|
@@ -96,29 +83,11 @@ const SelectMonitorDevices = ({ route }) => {
|
|
|
96
83
|
: automate.sensor_id,
|
|
97
84
|
},
|
|
98
85
|
stationName: stations[indexStation]?.name,
|
|
99
|
-
type,
|
|
100
|
-
scriptName,
|
|
101
|
-
isAutomateTab,
|
|
102
86
|
isCreateNewAction,
|
|
103
|
-
isMultiUnits,
|
|
104
|
-
oldType,
|
|
105
87
|
closeScreen,
|
|
106
88
|
});
|
|
107
89
|
},
|
|
108
|
-
[
|
|
109
|
-
navigate,
|
|
110
|
-
unit,
|
|
111
|
-
automateId,
|
|
112
|
-
automate,
|
|
113
|
-
stations,
|
|
114
|
-
type,
|
|
115
|
-
scriptName,
|
|
116
|
-
isAutomateTab,
|
|
117
|
-
isCreateNewAction,
|
|
118
|
-
isMultiUnits,
|
|
119
|
-
oldType,
|
|
120
|
-
closeScreen,
|
|
121
|
-
]
|
|
90
|
+
[navigate, automate, stations, isCreateNewAction, closeScreen]
|
|
122
91
|
);
|
|
123
92
|
|
|
124
93
|
if (loading) {
|
|
@@ -128,7 +97,6 @@ const SelectMonitorDevices = ({ route }) => {
|
|
|
128
97
|
return (
|
|
129
98
|
<SelectDevices
|
|
130
99
|
onPressContinue={onPressContinue}
|
|
131
|
-
automateId={automateId}
|
|
132
100
|
listStation={listStation}
|
|
133
101
|
listMenuItem={listMenuItem}
|
|
134
102
|
stations={stations}
|