@eohjsc/react-native-smart-city 0.4.85 → 0.4.87
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/Notify.svg +9 -0
- package/package.json +1 -1
- package/src/commons/Action/ItemQuickAction.js +105 -124
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +1 -1
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +0 -1
- package/src/commons/ActionGroup/ThreeButtonTemplate/components/ThreeButtonDefault.js +2 -2
- package/src/commons/ActionGroup/ThreeButtonTemplate/index.js +1 -1
- package/src/commons/Automate/ItemAutomate.js +6 -1
- package/src/commons/Device/RainningSensor/CurrentRainSensor.js +1 -5
- package/src/commons/IconComponent/index.js +2 -3
- package/src/commons/MenuActionAddnew/index.js +6 -0
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +4 -3
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +14 -1
- package/src/configs/API.js +10 -0
- package/src/configs/AccessibilityLabel.js +3 -0
- package/src/configs/Constants.js +1 -0
- package/src/navigations/UnitStack.js +10 -2
- package/src/screens/Automate/AddNewAction/SetupScriptNotify.js +92 -0
- package/src/screens/Automate/AddNewAction/Styles/SetupScriptNotifyStyles.js +57 -0
- package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +13 -0
- package/src/screens/Automate/AddNewAction/__test__/SetupScriptNotify.test.js +84 -0
- package/src/screens/Automate/EditActionsList/__tests__/index.test.js +15 -4
- package/src/screens/Automate/EditActionsList/index.js +130 -72
- package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +168 -0
- package/src/screens/Automate/ScriptDetail/__test__/index.test.js +75 -6
- package/src/screens/Automate/ScriptDetail/index.js +147 -84
- package/src/screens/Automate/ScriptDetail/utils.js +12 -11
- package/src/screens/Device/detail.js +0 -2
- package/src/screens/Notification/__test__/Notification.test.js +25 -0
- package/src/screens/Notification/components/NotificationItem.js +58 -36
- package/src/screens/Sharing/{MemberList.js → UnitMemberList.js} +4 -4
- package/src/screens/Sharing/__test__/{MemberList.test.js → UnitMemberList.test.js} +2 -2
- package/src/utils/I18n/translations/en.js +14 -1
- package/src/utils/I18n/translations/vi.js +13 -1
- package/src/utils/Route/index.js +1 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<svg width="28" height="33" viewBox="0 0 28 33" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M14.0003 32.6666C15.8337 32.6666 17.3337 31.1666 17.3337 29.3333H10.667C10.667 31.1666 12.1503 32.6666 14.0003 32.6666ZM24.0003 22.6666V14.3333C24.0003 9.21663 21.267 4.93329 16.5003 3.79996V2.66663C16.5003 1.28329 15.3837 0.166626 14.0003 0.166626C12.617 0.166626 11.5003 1.28329 11.5003 2.66663V3.79996C6.71699 4.93329 4.00033 9.19996 4.00033 14.3333V22.6666L0.666992 26V27.6666H27.3337V26L24.0003 22.6666Z" fill="url(#paint0_linear_2168_1847)"/>
|
|
3
|
+
<defs>
|
|
4
|
+
<linearGradient id="paint0_linear_2168_1847" x1="0.666992" y1="0.166626" x2="32.5129" y2="26.3255" gradientUnits="userSpaceOnUse">
|
|
5
|
+
<stop stop-color="#2B6B9F"/>
|
|
6
|
+
<stop offset="1" stop-color="#D5FFCB"/>
|
|
7
|
+
</linearGradient>
|
|
8
|
+
</defs>
|
|
9
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,144 +1,125 @@
|
|
|
1
1
|
import React, { memo, useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import { TouchableOpacity, View } from 'react-native';
|
|
2
|
+
import { Platform, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import { AccessibilityLabel } from '../../configs/Constants';
|
|
4
4
|
import { useSCContextSelector } from '../../context';
|
|
5
5
|
import { useRemoteControl } from '../../hooks/IoT';
|
|
6
6
|
import { useConfigGlobalState } from '../../iot/states';
|
|
7
7
|
import IconComponent from '../IconComponent';
|
|
8
|
-
import { Colors } from '../../configs';
|
|
9
8
|
|
|
10
|
-
const ItemQuickAction = memo(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const isFault = currentValue === 2; // phukhaco fault value
|
|
28
|
-
const [isOn, setIsOn] = useState(currentValue);
|
|
9
|
+
const ItemQuickAction = memo(({ sensor, wrapperStyle, setStatus }) => {
|
|
10
|
+
const { quick_action } = sensor || {};
|
|
11
|
+
const {
|
|
12
|
+
config_id,
|
|
13
|
+
off_action,
|
|
14
|
+
on_status,
|
|
15
|
+
on_action,
|
|
16
|
+
off_status,
|
|
17
|
+
interval,
|
|
18
|
+
will_auto_update_status,
|
|
19
|
+
on_state_values,
|
|
20
|
+
} = quick_action || {};
|
|
21
|
+
const [action, setAction] = useState(sensor?.action);
|
|
22
|
+
// eslint-disable-next-line no-unused-vars
|
|
23
|
+
const [configValues, _] = useConfigGlobalState('configValues');
|
|
24
|
+
const currentValue = configValues[config_id]?.value || 0;
|
|
25
|
+
const [isOn, setIsOn] = useState(currentValue);
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const sendRemoteCommand = useRemoteControl();
|
|
28
|
+
const [processing, setProcessing] = useState(false);
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
setIsOn(getIsOnValue());
|
|
42
|
-
}, [getIsOnValue]);
|
|
30
|
+
const getIsOnValue = useCallback(() => {
|
|
31
|
+
if (on_state_values && on_state_values.length > 0) {
|
|
32
|
+
return on_state_values.includes(currentValue);
|
|
33
|
+
}
|
|
34
|
+
return !!currentValue;
|
|
35
|
+
}, [currentValue, on_state_values]);
|
|
43
36
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
setIsOn(getIsOnValue());
|
|
39
|
+
}, [getIsOnValue]);
|
|
48
40
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
setAction(on_action);
|
|
54
|
-
setStatus && setStatus(off_status);
|
|
55
|
-
}
|
|
56
|
-
}, [
|
|
57
|
-
isOn,
|
|
58
|
-
setStatus,
|
|
59
|
-
quick_action,
|
|
60
|
-
off_action,
|
|
61
|
-
on_status,
|
|
62
|
-
on_action,
|
|
63
|
-
off_status,
|
|
64
|
-
]);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!quick_action) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
65
45
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
config_value: 0,
|
|
83
|
-
};
|
|
84
|
-
} else {
|
|
85
|
-
data = {
|
|
86
|
-
config_id: action?.allow_config_store_value_id,
|
|
87
|
-
config_value: 1,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
data = JSON.stringify(data);
|
|
91
|
-
}
|
|
92
|
-
await sendRemoteCommand(sensor, action, data, userId);
|
|
46
|
+
if (isOn) {
|
|
47
|
+
setAction(off_action);
|
|
48
|
+
setStatus && setStatus(on_status);
|
|
49
|
+
} else {
|
|
50
|
+
setAction(on_action);
|
|
51
|
+
setStatus && setStatus(off_status);
|
|
52
|
+
}
|
|
53
|
+
}, [
|
|
54
|
+
isOn,
|
|
55
|
+
setStatus,
|
|
56
|
+
quick_action,
|
|
57
|
+
off_action,
|
|
58
|
+
on_status,
|
|
59
|
+
on_action,
|
|
60
|
+
off_status,
|
|
61
|
+
]);
|
|
93
62
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
63
|
+
const userId = useSCContextSelector((state) => state?.auth.account.user.id);
|
|
64
|
+
const onActionPress = useCallback(async () => {
|
|
65
|
+
if (processing || !action) {
|
|
66
|
+
/* istanbul ignore next */
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
setProcessing(true);
|
|
70
|
+
let data = null;
|
|
71
|
+
if (action?.allow_config_store_value_id === config_id) {
|
|
72
|
+
if (action?.name?.toLowerCase().includes('off')) {
|
|
73
|
+
data = {
|
|
74
|
+
config_id: action?.allow_config_store_value_id,
|
|
75
|
+
config_value: 0,
|
|
76
|
+
};
|
|
77
|
+
} else {
|
|
78
|
+
data = {
|
|
79
|
+
config_id: action?.allow_config_store_value_id,
|
|
80
|
+
config_value: 1,
|
|
81
|
+
};
|
|
98
82
|
}
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
processing,
|
|
103
|
-
action,
|
|
104
|
-
config_id,
|
|
105
|
-
sendRemoteCommand,
|
|
106
|
-
sensor,
|
|
107
|
-
userId,
|
|
108
|
-
will_auto_update_status,
|
|
109
|
-
interval,
|
|
110
|
-
on_action?.id,
|
|
111
|
-
]);
|
|
83
|
+
data = JSON.stringify(data);
|
|
84
|
+
}
|
|
85
|
+
await sendRemoteCommand(sensor, action, data, userId);
|
|
112
86
|
|
|
113
|
-
if (!
|
|
114
|
-
|
|
87
|
+
if (!will_auto_update_status) {
|
|
88
|
+
setTimeout(() => {
|
|
89
|
+
setIsOn(action.id === on_action.id);
|
|
90
|
+
}, interval);
|
|
115
91
|
}
|
|
92
|
+
setProcessing(false);
|
|
93
|
+
}, [
|
|
94
|
+
processing,
|
|
95
|
+
action,
|
|
96
|
+
config_id,
|
|
97
|
+
sendRemoteCommand,
|
|
98
|
+
sensor,
|
|
99
|
+
userId,
|
|
100
|
+
will_auto_update_status,
|
|
101
|
+
interval,
|
|
102
|
+
on_action?.id,
|
|
103
|
+
]);
|
|
116
104
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
accessibilityLabel={`${AccessibilityLabel.ITEM_QUICK_ACTION_PRESS}-${sensor?.id}`}
|
|
120
|
-
onPress={onActionPress}
|
|
121
|
-
>
|
|
122
|
-
<View style={wrapperStyle}>
|
|
123
|
-
{isFault ? (
|
|
124
|
-
<IconComponent
|
|
125
|
-
icon={'WarningOutlined'}
|
|
126
|
-
color={Colors.Red}
|
|
127
|
-
iconSize={iconSize}
|
|
128
|
-
size={iconSize}
|
|
129
|
-
/>
|
|
130
|
-
) : (
|
|
131
|
-
<IconComponent
|
|
132
|
-
icon={action?.icon_kit || action?.icon || 'PoweroffOutlined'}
|
|
133
|
-
isOn={isOn}
|
|
134
|
-
iconSize={iconSize}
|
|
135
|
-
size={iconSize}
|
|
136
|
-
/>
|
|
137
|
-
)}
|
|
138
|
-
</View>
|
|
139
|
-
</TouchableOpacity>
|
|
140
|
-
);
|
|
105
|
+
if (!config_id) {
|
|
106
|
+
return <View />;
|
|
141
107
|
}
|
|
142
|
-
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<TouchableOpacity
|
|
111
|
+
accessibilityLabel={`${AccessibilityLabel.ITEM_QUICK_ACTION_PRESS}-${sensor?.id}`}
|
|
112
|
+
onPress={onActionPress}
|
|
113
|
+
>
|
|
114
|
+
<View style={wrapperStyle}>
|
|
115
|
+
<IconComponent
|
|
116
|
+
icon={action?.icon_kit || action?.icon || 'PoweroffOutlined'}
|
|
117
|
+
isOn={isOn}
|
|
118
|
+
size={Platform.OS === 'ios' ? 20 : 30}
|
|
119
|
+
/>
|
|
120
|
+
</View>
|
|
121
|
+
</TouchableOpacity>
|
|
122
|
+
);
|
|
123
|
+
});
|
|
143
124
|
|
|
144
125
|
export default ItemQuickAction;
|
|
@@ -22,7 +22,7 @@ const ThreeButtonDefault = memo(
|
|
|
22
22
|
return icon2 === 'stop' ? (
|
|
23
23
|
<View style={styles.squareStop} />
|
|
24
24
|
) : (
|
|
25
|
-
<IconComponent icon={icon2}
|
|
25
|
+
<IconComponent icon={icon2} size={30} />
|
|
26
26
|
);
|
|
27
27
|
};
|
|
28
28
|
|
|
@@ -87,7 +87,7 @@ const ThreeButtonDefault = memo(
|
|
|
87
87
|
{item?.id === 2 ? (
|
|
88
88
|
<Icon2CT />
|
|
89
89
|
) : (
|
|
90
|
-
<IconComponent icon={item?.icon}
|
|
90
|
+
<IconComponent icon={item?.icon} size={30} />
|
|
91
91
|
)}
|
|
92
92
|
</View>
|
|
93
93
|
<Text style={styles.text}>{item?.text}</Text>
|
|
@@ -15,6 +15,7 @@ const ItemAutomate = ({
|
|
|
15
15
|
index,
|
|
16
16
|
setSelectedIndex,
|
|
17
17
|
onPress,
|
|
18
|
+
enableScript = true,
|
|
18
19
|
}) => {
|
|
19
20
|
const t = useTranslations();
|
|
20
21
|
const item = AUTOMATES[automate?.type];
|
|
@@ -57,7 +58,11 @@ const ItemAutomate = ({
|
|
|
57
58
|
<View style={styles.row}>
|
|
58
59
|
<View style={styles.wrapIcon}>{!!Icon && <Icon />}</View>
|
|
59
60
|
<View style={styles.wrapTitle}>
|
|
60
|
-
<Text
|
|
61
|
+
<Text
|
|
62
|
+
type="H4"
|
|
63
|
+
bold
|
|
64
|
+
color={enableScript ? Colors.Black : Colors.Gray7}
|
|
65
|
+
>
|
|
61
66
|
{t(item?.title)}
|
|
62
67
|
</Text>
|
|
63
68
|
<Text type="Label" color={Colors.Gray8} numberOfLines={1}>
|
|
@@ -41,11 +41,7 @@ const CurrentRainSensor = memo(
|
|
|
41
41
|
end={{ x: 1, y: 1 }}
|
|
42
42
|
/>
|
|
43
43
|
{icon_kit_data?.icon || icon ? (
|
|
44
|
-
<IconComponent
|
|
45
|
-
size={iconSize}
|
|
46
|
-
iconSize={iconSize}
|
|
47
|
-
icon={icon_kit_data?.icon || icon}
|
|
48
|
-
/>
|
|
44
|
+
<IconComponent size={iconSize} icon={icon_kit_data?.icon || icon} />
|
|
49
45
|
) : (
|
|
50
46
|
<FImage
|
|
51
47
|
source={images.activeCurrentSensor}
|
|
@@ -10,7 +10,6 @@ const IconComponent = memo(
|
|
|
10
10
|
icon,
|
|
11
11
|
isOn = false,
|
|
12
12
|
size = 30,
|
|
13
|
-
iconSize = 30,
|
|
14
13
|
style,
|
|
15
14
|
antIconStyle,
|
|
16
15
|
color,
|
|
@@ -66,7 +65,7 @@ const IconComponent = memo(
|
|
|
66
65
|
<IconFill
|
|
67
66
|
name={displayIcon}
|
|
68
67
|
color={colorIcon}
|
|
69
|
-
size={
|
|
68
|
+
size={size}
|
|
70
69
|
style={[extraStyle, antIconStyle || style]}
|
|
71
70
|
/>
|
|
72
71
|
);
|
|
@@ -80,7 +79,7 @@ const IconComponent = memo(
|
|
|
80
79
|
<IconOutline
|
|
81
80
|
name={iconCT}
|
|
82
81
|
color={colorIcon}
|
|
83
|
-
size={
|
|
82
|
+
size={size}
|
|
84
83
|
style={[extraStyle, antIconStyle || style]}
|
|
85
84
|
/>
|
|
86
85
|
);
|
|
@@ -6,6 +6,7 @@ import { Colors } from '../../configs';
|
|
|
6
6
|
import Text from '../Text';
|
|
7
7
|
import ImageButton from '../ImageButton';
|
|
8
8
|
import { ModalCustom } from '../Modal';
|
|
9
|
+
import packageJson from '../../../package.json';
|
|
9
10
|
|
|
10
11
|
const keyExtractor = (item) => item.id.toString();
|
|
11
12
|
const MenuActionAddnew = memo(
|
|
@@ -61,6 +62,11 @@ const MenuActionAddnew = memo(
|
|
|
61
62
|
renderItem={renderItem}
|
|
62
63
|
scrollIndicatorInsets={{ right: 1 }}
|
|
63
64
|
/>
|
|
65
|
+
<View style={styles.modalHeader}>
|
|
66
|
+
<Text
|
|
67
|
+
style={styles.modalHeaderText}
|
|
68
|
+
>{`v ${packageJson.version}`}</Text>
|
|
69
|
+
</View>
|
|
64
70
|
</View>
|
|
65
71
|
</View>
|
|
66
72
|
</ModalCustom>
|
|
@@ -22,6 +22,7 @@ import { AccessibilityLabel, AUTOMATE_TYPE } from '../../../configs/Constants';
|
|
|
22
22
|
const ItemOneTap = memo(({ automate = {}, wrapSyles, onPressItem }) => {
|
|
23
23
|
const { navigate } = useNavigation();
|
|
24
24
|
const { id, type, script, activate_at, author = '' } = automate;
|
|
25
|
+
const { enable } = script;
|
|
25
26
|
const t = useTranslations();
|
|
26
27
|
|
|
27
28
|
const goToDetail = useCallback(() => {
|
|
@@ -69,7 +70,7 @@ const ItemOneTap = memo(({ automate = {}, wrapSyles, onPressItem }) => {
|
|
|
69
70
|
<View style={[styles.container, wrapSyles]}>
|
|
70
71
|
<View style={styles.boxIcon}>
|
|
71
72
|
{displayIcon()}
|
|
72
|
-
{type === AUTOMATE_TYPE.ONE_TAP && (
|
|
73
|
+
{type === AUTOMATE_TYPE.ONE_TAP && enable && (
|
|
73
74
|
<TouchableOpacity
|
|
74
75
|
accessibilityLabel={AccessibilityLabel.AUTOMATE_SCRIPT_ACTION}
|
|
75
76
|
onPress={handleScriptAction}
|
|
@@ -86,7 +87,7 @@ const ItemOneTap = memo(({ automate = {}, wrapSyles, onPressItem }) => {
|
|
|
86
87
|
numberOfLines={1}
|
|
87
88
|
semibold
|
|
88
89
|
size={14}
|
|
89
|
-
color={Colors.Gray9}
|
|
90
|
+
color={enable ? Colors.Gray9 : Colors.Gray}
|
|
90
91
|
type="Body"
|
|
91
92
|
style={styles.name}
|
|
92
93
|
accessibilityLabel={AccessibilityLabel.TEXT_AUTOMATE_NAME}
|
|
@@ -101,7 +102,7 @@ const ItemOneTap = memo(({ automate = {}, wrapSyles, onPressItem }) => {
|
|
|
101
102
|
numberOfLines={1}
|
|
102
103
|
semibold
|
|
103
104
|
size={12}
|
|
104
|
-
color={Colors.Gray8}
|
|
105
|
+
color={enable ? Colors.Gray8 : Colors.Gray}
|
|
105
106
|
type="Label"
|
|
106
107
|
>
|
|
107
108
|
{activateAt && t('activated_time', { time: activateAt })}
|
|
@@ -49,6 +49,19 @@ describe('test Item', () => {
|
|
|
49
49
|
name: 'Joshua Ray',
|
|
50
50
|
icon: '',
|
|
51
51
|
icon_kit: '',
|
|
52
|
+
enable: true,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 2,
|
|
57
|
+
user: 6,
|
|
58
|
+
type: 'one_tap',
|
|
59
|
+
activate_at: '2021-09-17T05:30:00Z',
|
|
60
|
+
script: {
|
|
61
|
+
name: 'Test',
|
|
62
|
+
icon: '',
|
|
63
|
+
icon_kit: '',
|
|
64
|
+
enable: false,
|
|
52
65
|
},
|
|
53
66
|
},
|
|
54
67
|
],
|
|
@@ -89,7 +102,7 @@ describe('test Item', () => {
|
|
|
89
102
|
el.props.accessibilityLabel === AccessibilityLabel.GO_DETAIL &&
|
|
90
103
|
el.type === TouchableOpacity
|
|
91
104
|
);
|
|
92
|
-
expect(goDetail).toHaveLength(
|
|
105
|
+
expect(goDetail).toHaveLength(2);
|
|
93
106
|
await act(async () => {
|
|
94
107
|
await goDetail[0].props.onPress();
|
|
95
108
|
});
|
package/src/configs/API.js
CHANGED
|
@@ -87,16 +87,26 @@ const API = {
|
|
|
87
87
|
AUTOMATE: {
|
|
88
88
|
ACTION_ONE_TAP: (id) => `/property_manager/automate/${id}/action_one_tap/`,
|
|
89
89
|
SCRIPT: (id) => `/property_manager/automate/${id}/script/`,
|
|
90
|
+
SCRIPT_ITEMS: (id) => `/property_manager/automate/${id}/script_items/`,
|
|
90
91
|
ORDER_SCRIPT_ACTION: (id) =>
|
|
91
92
|
`/property_manager/automate/${id}/order_script_action/`,
|
|
93
|
+
ORDER_SCRIPT_ITEMS: (id) =>
|
|
94
|
+
`/property_manager/automate/${id}/order_script_items/`,
|
|
92
95
|
DELETE_SCRIPT_ACTION: (automateId, actionId) =>
|
|
93
96
|
`/property_manager/automate/${automateId}/script_action/${actionId}/`,
|
|
97
|
+
DELETE_SCRIPT_ITEM: (automateId, itemId) =>
|
|
98
|
+
`/property_manager/automate/${automateId}/script_item/${itemId}/`,
|
|
94
99
|
ADD_SCRIPT_ACTION: (id) =>
|
|
95
100
|
`/property_manager/automate/${id}/add_script_action/`,
|
|
101
|
+
ADD_SCRIPT_NOTIFY: (id) =>
|
|
102
|
+
`/property_manager/automate/${id}/add_script_notify/`,
|
|
103
|
+
|
|
96
104
|
FETCH_AUTOMATE: (automateId) => `/property_manager/automate/${automateId}/`,
|
|
97
105
|
CREATE_AUTOMATE: () => '/property_manager/automate/',
|
|
98
106
|
UPDATE_AUTOMATE: (automateId) =>
|
|
99
107
|
`/property_manager/automate/${automateId}/`,
|
|
108
|
+
ENABLE_SCRIPT: (automateId) =>
|
|
109
|
+
`/property_manager/automate/${automateId}/enable_script/`,
|
|
100
110
|
STAR_SCRIPT: (id) => `/property_manager/automate/${id}/star_script/`,
|
|
101
111
|
UNSTAR_SCRIPT: (id) => `/property_manager/automate/${id}/unstar_script/`,
|
|
102
112
|
GET_SMART: () => '/property_manager/automate/smart/',
|
|
@@ -241,6 +241,9 @@ export default {
|
|
|
241
241
|
ICON_MORE: 'ICON_MORE',
|
|
242
242
|
ICON_ARROW_RIGHT: 'ICON_ARROW_RIGHT',
|
|
243
243
|
TEXT_AUTOMATE_NAME: 'TEXT_AUTOMATE_NAME',
|
|
244
|
+
AUTOMATE_LIST_SCRIPT_ACTION: 'AUTOMATE_LIST_SCRIPT_ACTION',
|
|
245
|
+
AUTOMATE_TITLE_NOTIFY: 'AUTOMATE_TITLE_NOTIFY',
|
|
246
|
+
AUTOMATE_MESSAGE_NOTIFY: 'AUTOMATE_MESSAGE_NOTIFY',
|
|
244
247
|
|
|
245
248
|
// Parking input maunaly spot
|
|
246
249
|
PARKING_SPOT_INFO_BUTTON: 'PARKING_SPOT_INFO_BUTTON',
|
package/src/configs/Constants.js
CHANGED
|
@@ -233,6 +233,7 @@ export const NOTIFICATION_TYPES = {
|
|
|
233
233
|
LOW_BATTERY: 'LOW_BATTERY',
|
|
234
234
|
BROADCAST_NOTIFICATION: 'BROADCAST_NOTIFICATION',
|
|
235
235
|
SUBSCRIBE_SUCCESS: 'SUBSCRIBE_SUCCESS',
|
|
236
|
+
TRIGGER_SCRIPT_NOTIFY: 'TRIGGER_SCRIPT_NOTIFY',
|
|
236
237
|
};
|
|
237
238
|
|
|
238
239
|
export const ACTIVITY_LOG_TYPES = {
|
|
@@ -19,7 +19,7 @@ import { Action } from '../context/actionType';
|
|
|
19
19
|
import AQIGuide from '../screens/AQIGuide';
|
|
20
20
|
import DeviceDetail from '../screens/Device/detail';
|
|
21
21
|
import ChangePosition from '../screens/ChangePosition';
|
|
22
|
-
import
|
|
22
|
+
import UnitMemberList from '../screens/Sharing/UnitMemberList';
|
|
23
23
|
import ManageSubUnit from '../screens/SubUnit/ManageSubUnit';
|
|
24
24
|
import SelectAddress from '../screens/Unit/SelectAddress';
|
|
25
25
|
import ChooseLocation from '../screens/Unit/ChooseLocation';
|
|
@@ -66,6 +66,7 @@ import ChooseAction from '../screens/Automate/AddNewAction/ChooseAction';
|
|
|
66
66
|
import ScenarioName from '../screens/Automate/Scenario/ScenarioName';
|
|
67
67
|
import ValueChangeName from '../screens/Automate/ValueChange/ValueChangeName';
|
|
68
68
|
import AddAutomationTypeSmart from '../screens/Automate/AddNewAutoSmart/AddAutomationTypeSmart';
|
|
69
|
+
import SetupScriptNotify from '../screens/Automate/AddNewAction/SetupScriptNotify';
|
|
69
70
|
|
|
70
71
|
const Stack = createStackNavigator();
|
|
71
72
|
|
|
@@ -331,7 +332,7 @@ export const UnitStack = memo((props) => {
|
|
|
331
332
|
/>
|
|
332
333
|
<Stack.Screen
|
|
333
334
|
name={Route.UnitMemberList}
|
|
334
|
-
component={
|
|
335
|
+
component={UnitMemberList}
|
|
335
336
|
options={{
|
|
336
337
|
headerShown: false,
|
|
337
338
|
}}
|
|
@@ -406,6 +407,13 @@ export const UnitStack = memo((props) => {
|
|
|
406
407
|
headerShown: false,
|
|
407
408
|
}}
|
|
408
409
|
/>
|
|
410
|
+
<Stack.Screen
|
|
411
|
+
name={Route.SetupScriptNotify}
|
|
412
|
+
component={SetupScriptNotify}
|
|
413
|
+
options={{
|
|
414
|
+
headerShown: false,
|
|
415
|
+
}}
|
|
416
|
+
/>
|
|
409
417
|
<Stack.Screen
|
|
410
418
|
name={Route.AddAutomationTypeSmart}
|
|
411
419
|
component={AddAutomationTypeSmart}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { useNavigation } from '@react-navigation/native';
|
|
4
|
+
import styles from './Styles/SetupScriptNotifyStyles';
|
|
5
|
+
import { HeaderCustom } from '../../../commons';
|
|
6
|
+
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
7
|
+
|
|
8
|
+
import _TextInput from '../../../commons/Form/TextInput';
|
|
9
|
+
import AccessibilityLabel from '../../../configs/AccessibilityLabel';
|
|
10
|
+
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
11
|
+
import { axiosPost } from '../../../utils/Apis/axios';
|
|
12
|
+
import { API } from '../../../configs';
|
|
13
|
+
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
14
|
+
import Routes from '../../../utils/Route';
|
|
15
|
+
import moment from 'moment';
|
|
16
|
+
|
|
17
|
+
const SetupScriptNotify = ({ route }) => {
|
|
18
|
+
const t = useTranslations();
|
|
19
|
+
const { goBack, navigate } = useNavigation();
|
|
20
|
+
const { automate = {}, unitId } = route?.params || {};
|
|
21
|
+
const { id: automateId } = automate;
|
|
22
|
+
const [notify, setNotify] = useState({ unit: unitId });
|
|
23
|
+
|
|
24
|
+
const onChangeTitle = (value) => {
|
|
25
|
+
setNotify((state) => ({
|
|
26
|
+
...state,
|
|
27
|
+
title: value,
|
|
28
|
+
}));
|
|
29
|
+
};
|
|
30
|
+
const onChangeMessage = (value) => {
|
|
31
|
+
setNotify((state) => ({
|
|
32
|
+
...state,
|
|
33
|
+
message: value,
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const onNext = useCallback(async () => {
|
|
38
|
+
const { success } = await axiosPost(
|
|
39
|
+
API.AUTOMATE.ADD_SCRIPT_NOTIFY(automateId),
|
|
40
|
+
notify
|
|
41
|
+
);
|
|
42
|
+
if (success) {
|
|
43
|
+
ToastBottomHelper.success(t('text_done'));
|
|
44
|
+
navigate({
|
|
45
|
+
name: Routes.ScriptDetail,
|
|
46
|
+
merge: true,
|
|
47
|
+
params: { saveAt: moment().valueOf() },
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
ToastBottomHelper.error(t('text_done'));
|
|
51
|
+
}
|
|
52
|
+
}, [automateId, navigate, notify, t]);
|
|
53
|
+
|
|
54
|
+
const canSave = useMemo(() => {
|
|
55
|
+
const { title, message } = notify || {};
|
|
56
|
+
return !!title && !!message;
|
|
57
|
+
}, [notify]);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<View style={styles.wrap}>
|
|
61
|
+
<HeaderCustom isShowClose onClose={goBack} title={t('notification')} />
|
|
62
|
+
<View style={styles.container}>
|
|
63
|
+
<_TextInput
|
|
64
|
+
placeholder={t('title_notification')}
|
|
65
|
+
onChange={onChangeTitle}
|
|
66
|
+
textInputStyle={styles.textTitle}
|
|
67
|
+
value={notify?.title}
|
|
68
|
+
accessibilityLabel={AccessibilityLabel.AUTOMATE_TITLE_NOTIFY}
|
|
69
|
+
autoFocus
|
|
70
|
+
/>
|
|
71
|
+
<_TextInput
|
|
72
|
+
placeholder={t('message_notification')}
|
|
73
|
+
onChange={onChangeMessage}
|
|
74
|
+
textInputStyle={styles.textMessage}
|
|
75
|
+
value={notify?.message}
|
|
76
|
+
accessibilityLabel={AccessibilityLabel.AUTOMATE_MESSAGE_NOTIFY}
|
|
77
|
+
multiline={true}
|
|
78
|
+
maxLength={255}
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
<BottomButtonView
|
|
82
|
+
style={styles.bottomButtonView}
|
|
83
|
+
mainTitle={t('save')}
|
|
84
|
+
onPressMain={onNext}
|
|
85
|
+
typeMain={canSave ? 'primary' : 'disabled'}
|
|
86
|
+
/>
|
|
87
|
+
</View>
|
|
88
|
+
</View>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export default SetupScriptNotify;
|