@eohjsc/react-native-smart-city 0.4.86 → 0.4.88
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/Delay.svg +14 -0
- package/package.json +1 -1
- package/src/commons/Action/ItemQuickAction.js +104 -123
- 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/Device/ItemDevice.js +14 -1
- package/src/commons/Device/RainningSensor/CurrentRainSensor.js +1 -5
- package/src/commons/IconComponent/index.js +6 -7
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +1 -0
- package/src/configs/API.js +2 -0
- package/src/configs/AccessibilityLabel.js +1 -1
- package/src/configs/Constants.js +1 -0
- package/src/navigations/UnitStack.js +8 -0
- package/src/screens/Automate/AddNewAction/SetupScriptDelay.js +81 -0
- package/src/screens/Automate/AddNewAction/Styles/SetupScriptDelayStyles.js +30 -0
- package/src/screens/Automate/AddNewAction/Styles/SetupScriptNotifyStyles.js +0 -21
- package/src/screens/Automate/AddNewAction/__test__/SetupScriptDelay.test.js +95 -0
- package/src/screens/Automate/AddNewAction/__test__/SetupScriptNotify.test.js +4 -3
- package/src/screens/Automate/EditActionsList/Styles/indexStyles.js +5 -3
- package/src/screens/Automate/EditActionsList/__tests__/index.test.js +9 -1
- package/src/screens/Automate/EditActionsList/index.js +36 -5
- package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +16 -1
- package/src/screens/Automate/ScriptDetail/Styles/indexStyles.js +3 -1
- package/src/screens/Automate/ScriptDetail/__test__/index.test.js +16 -1
- package/src/screens/Automate/ScriptDetail/index.js +36 -6
- package/src/screens/Automate/ScriptDetail/utils.js +12 -11
- package/src/screens/Notification/__test__/Notification.test.js +26 -0
- package/src/screens/Notification/components/NotificationItem.js +73 -41
- package/src/screens/Unit/components/MyUnitDevice/index.js +1 -0
- package/src/utils/I18n/translations/en.js +4 -0
- package/src/utils/I18n/translations/vi.js +4 -0
- package/src/utils/Route/index.js +1 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<svg width="21" height="34" viewBox="0 0 21 34" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M0 0L0.0175004 10.2L7 17L0.0175004 23.817L0 34H21V23.8L14 17L21 10.217V0H0ZM17.5 24.65V30.6H3.5V24.65L10.5 17.85L17.5 24.65Z" fill="url(#paint0_linear_1913_17610)"/>
|
|
3
|
+
<path d="M7.35 30.26H13.65C13.4294 28.5299 12.1032 27.2 10.5 27.2C8.89685 27.2 7.57059 28.5299 7.35 30.26Z" fill="url(#paint1_linear_1913_17610)"/>
|
|
4
|
+
<defs>
|
|
5
|
+
<linearGradient id="paint0_linear_1913_17610" x1="0" y1="0" x2="30.3834" y2="18.787" gradientUnits="userSpaceOnUse">
|
|
6
|
+
<stop stop-color="#2B6B9F"/>
|
|
7
|
+
<stop offset="1" stop-color="#D5FFCB"/>
|
|
8
|
+
</linearGradient>
|
|
9
|
+
<linearGradient id="paint1_linear_1913_17610" x1="0" y1="0" x2="30.3834" y2="18.787" gradientUnits="userSpaceOnUse">
|
|
10
|
+
<stop stop-color="#2B6B9F"/>
|
|
11
|
+
<stop offset="1" stop-color="#D5FFCB"/>
|
|
12
|
+
</linearGradient>
|
|
13
|
+
</defs>
|
|
14
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -5,140 +5,121 @@ 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={20}
|
|
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>
|
|
@@ -117,7 +117,11 @@ const ItemDevice = memo(
|
|
|
117
117
|
<IconComponent icon={sensor?.icon_kit || sensor?.icon} />
|
|
118
118
|
</TouchableOpacity>
|
|
119
119
|
{!!canRenderQuickAction && (
|
|
120
|
-
<ItemQuickAction
|
|
120
|
+
<ItemQuickAction
|
|
121
|
+
sensor={sensor}
|
|
122
|
+
unit={unit}
|
|
123
|
+
wrapperStyle={styles.quickAction}
|
|
124
|
+
/>
|
|
121
125
|
)}
|
|
122
126
|
</View>
|
|
123
127
|
<TouchableOpacity onPress={goToSensorDisplay}>
|
|
@@ -179,4 +183,13 @@ const styles = StyleSheet.create({
|
|
|
179
183
|
height: 40,
|
|
180
184
|
resizeMode: 'contain',
|
|
181
185
|
},
|
|
186
|
+
quickAction: {
|
|
187
|
+
width: 32,
|
|
188
|
+
height: 32,
|
|
189
|
+
backgroundColor: Colors.Gray3,
|
|
190
|
+
borderRadius: 16,
|
|
191
|
+
justifyContent: 'center',
|
|
192
|
+
alignItems: 'center',
|
|
193
|
+
marginLeft: 5,
|
|
194
|
+
},
|
|
182
195
|
});
|
|
@@ -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,15 +10,14 @@ 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,
|
|
17
16
|
colorInActive,
|
|
18
17
|
}) => {
|
|
19
18
|
let extraStyle = {
|
|
20
|
-
width: size,
|
|
21
|
-
height: size,
|
|
19
|
+
width: size + 10,
|
|
20
|
+
height: size + 10,
|
|
22
21
|
};
|
|
23
22
|
const displayIcon = useMemo(() => {
|
|
24
23
|
let newIcon = `${icon}`;
|
|
@@ -66,8 +65,8 @@ const IconComponent = memo(
|
|
|
66
65
|
<IconFill
|
|
67
66
|
name={displayIcon}
|
|
68
67
|
color={colorIcon}
|
|
69
|
-
size={
|
|
70
|
-
style={[
|
|
68
|
+
size={size}
|
|
69
|
+
style={[antIconStyle || style]}
|
|
71
70
|
/>
|
|
72
71
|
);
|
|
73
72
|
} else {
|
|
@@ -80,8 +79,8 @@ const IconComponent = memo(
|
|
|
80
79
|
<IconOutline
|
|
81
80
|
name={iconCT}
|
|
82
81
|
color={colorIcon}
|
|
83
|
-
size={
|
|
84
|
-
style={[
|
|
82
|
+
size={size}
|
|
83
|
+
style={[antIconStyle || style]}
|
|
85
84
|
/>
|
|
86
85
|
);
|
|
87
86
|
}
|
package/src/configs/API.js
CHANGED
|
@@ -100,6 +100,8 @@ const API = {
|
|
|
100
100
|
`/property_manager/automate/${id}/add_script_action/`,
|
|
101
101
|
ADD_SCRIPT_NOTIFY: (id) =>
|
|
102
102
|
`/property_manager/automate/${id}/add_script_notify/`,
|
|
103
|
+
ADD_SCRIPT_DELAY: (id) =>
|
|
104
|
+
`/property_manager/automate/${id}/add_script_delay/`,
|
|
103
105
|
|
|
104
106
|
FETCH_AUTOMATE: (automateId) => `/property_manager/automate/${automateId}/`,
|
|
105
107
|
CREATE_AUTOMATE: () => '/property_manager/automate/',
|
|
@@ -244,7 +244,7 @@ export default {
|
|
|
244
244
|
AUTOMATE_LIST_SCRIPT_ACTION: 'AUTOMATE_LIST_SCRIPT_ACTION',
|
|
245
245
|
AUTOMATE_TITLE_NOTIFY: 'AUTOMATE_TITLE_NOTIFY',
|
|
246
246
|
AUTOMATE_MESSAGE_NOTIFY: 'AUTOMATE_MESSAGE_NOTIFY',
|
|
247
|
-
|
|
247
|
+
AUTOMATE_INPUT_DELAY: 'AUTOMATE_INPUT_DELAY',
|
|
248
248
|
// Parking input maunaly spot
|
|
249
249
|
PARKING_SPOT_INFO_BUTTON: 'PARKING_SPOT_INFO_BUTTON',
|
|
250
250
|
PARKING_SPOT_CONFIRM_SPOT: 'PARKING_SPOT_CONFIRM_SPOT',
|
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 = {
|
|
@@ -67,6 +67,7 @@ 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
69
|
import SetupScriptNotify from '../screens/Automate/AddNewAction/SetupScriptNotify';
|
|
70
|
+
import SetupScriptDelay from '../screens/Automate/AddNewAction/SetupScriptDelay';
|
|
70
71
|
|
|
71
72
|
const Stack = createStackNavigator();
|
|
72
73
|
|
|
@@ -414,6 +415,13 @@ export const UnitStack = memo((props) => {
|
|
|
414
415
|
headerShown: false,
|
|
415
416
|
}}
|
|
416
417
|
/>
|
|
418
|
+
<Stack.Screen
|
|
419
|
+
name={Route.SetupScriptDelay}
|
|
420
|
+
component={SetupScriptDelay}
|
|
421
|
+
options={{
|
|
422
|
+
headerShown: false,
|
|
423
|
+
}}
|
|
424
|
+
/>
|
|
417
425
|
<Stack.Screen
|
|
418
426
|
name={Route.AddAutomationTypeSmart}
|
|
419
427
|
component={AddAutomationTypeSmart}
|
|
@@ -0,0 +1,81 @@
|
|
|
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/SetupScriptDelayStyles';
|
|
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 SetupScriptDelay = ({ route }) => {
|
|
18
|
+
const t = useTranslations();
|
|
19
|
+
const { goBack, navigate } = useNavigation();
|
|
20
|
+
const { automate = {} } = route?.params || {};
|
|
21
|
+
const { id: automateId } = automate;
|
|
22
|
+
const [delay, setDelay] = useState();
|
|
23
|
+
|
|
24
|
+
const onChangeTitle = (value) => {
|
|
25
|
+
setDelay(value);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const onNext = useCallback(async () => {
|
|
29
|
+
const { success } = await axiosPost(
|
|
30
|
+
API.AUTOMATE.ADD_SCRIPT_DELAY(automateId),
|
|
31
|
+
{
|
|
32
|
+
delay,
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
if (success) {
|
|
36
|
+
ToastBottomHelper.success(t('text_done'));
|
|
37
|
+
navigate({
|
|
38
|
+
name: Routes.ScriptDetail,
|
|
39
|
+
merge: true,
|
|
40
|
+
params: { saveAt: moment().valueOf() },
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
ToastBottomHelper.error(t('text_done'));
|
|
44
|
+
}
|
|
45
|
+
}, [automateId, navigate, delay, t]);
|
|
46
|
+
|
|
47
|
+
const canSave = useMemo(() => {
|
|
48
|
+
const value = parseInt(delay);
|
|
49
|
+
if (!Number.isInteger(value) || value <= 0 || value > 3600) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}, [delay]);
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<View style={styles.wrap}>
|
|
57
|
+
<HeaderCustom isShowClose onClose={goBack} title={t('wait')} />
|
|
58
|
+
<View style={styles.container}>
|
|
59
|
+
<_TextInput
|
|
60
|
+
label={t('set_timeout_seconds')}
|
|
61
|
+
placeholder={t('maximum_3600_seconds')}
|
|
62
|
+
keyboardType="numeric"
|
|
63
|
+
textInputStyle={styles.inputNumber}
|
|
64
|
+
value={delay}
|
|
65
|
+
onChange={onChangeTitle}
|
|
66
|
+
maxLength={4}
|
|
67
|
+
accessibilityLabel={AccessibilityLabel.AUTOMATE_INPUT_DELAY}
|
|
68
|
+
autoFocus
|
|
69
|
+
/>
|
|
70
|
+
<BottomButtonView
|
|
71
|
+
style={styles.bottomButtonView}
|
|
72
|
+
mainTitle={t('save')}
|
|
73
|
+
onPressMain={onNext}
|
|
74
|
+
typeMain={canSave ? 'primary' : 'disabled'}
|
|
75
|
+
/>
|
|
76
|
+
</View>
|
|
77
|
+
</View>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default SetupScriptDelay;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors } from '../../../../configs';
|
|
3
|
+
import { getBottomSpace } from 'react-native-iphone-x-helper';
|
|
4
|
+
|
|
5
|
+
export default StyleSheet.create({
|
|
6
|
+
wrap: {
|
|
7
|
+
flex: 1,
|
|
8
|
+
backgroundColor: Colors.White,
|
|
9
|
+
},
|
|
10
|
+
container: {
|
|
11
|
+
flex: 1,
|
|
12
|
+
paddingHorizontal: 16,
|
|
13
|
+
paddingTop: 10,
|
|
14
|
+
paddingBottom: getBottomSpace() + 10,
|
|
15
|
+
},
|
|
16
|
+
inputNumber: {
|
|
17
|
+
borderWidth: 1,
|
|
18
|
+
borderColor: Colors.Gray4,
|
|
19
|
+
borderStyle: 'solid',
|
|
20
|
+
borderRadius: 10,
|
|
21
|
+
},
|
|
22
|
+
bottomButtonView: {
|
|
23
|
+
paddingTop: 24,
|
|
24
|
+
paddingBottom: 32,
|
|
25
|
+
|
|
26
|
+
backgroundColor: Colors.White,
|
|
27
|
+
borderColor: Colors.ShadownTransparent,
|
|
28
|
+
borderTopWidth: 1,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -7,16 +7,6 @@ export default StyleSheet.create({
|
|
|
7
7
|
flex: 1,
|
|
8
8
|
backgroundColor: Colors.White,
|
|
9
9
|
},
|
|
10
|
-
titleCreate: {
|
|
11
|
-
fontStyle: 'normal',
|
|
12
|
-
fontWeight: '600',
|
|
13
|
-
color: Colors.Gray9,
|
|
14
|
-
},
|
|
15
|
-
titleChoose: {
|
|
16
|
-
fontStyle: 'normal',
|
|
17
|
-
fontWeight: '400',
|
|
18
|
-
color: Colors.Gray8,
|
|
19
|
-
},
|
|
20
10
|
container: {
|
|
21
11
|
flex: 1,
|
|
22
12
|
paddingHorizontal: 16,
|
|
@@ -39,19 +29,8 @@ export default StyleSheet.create({
|
|
|
39
29
|
bottomButtonView: {
|
|
40
30
|
paddingTop: 24,
|
|
41
31
|
paddingBottom: 32,
|
|
42
|
-
|
|
43
32
|
backgroundColor: Colors.White,
|
|
44
33
|
borderColor: Colors.ShadownTransparent,
|
|
45
34
|
borderTopWidth: 1,
|
|
46
35
|
},
|
|
47
|
-
bottomButton: {
|
|
48
|
-
borderWidth: 0,
|
|
49
|
-
borderColor: Colors.Gray4,
|
|
50
|
-
paddingTop: 24,
|
|
51
|
-
paddingBottom: 24,
|
|
52
|
-
borderTopWidth: 1,
|
|
53
|
-
borderStyle: 'solid',
|
|
54
|
-
position: 'absolute',
|
|
55
|
-
bottom: 0,
|
|
56
|
-
},
|
|
57
36
|
});
|