@eohjsc/react-native-smart-city 0.2.42 → 0.2.46
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 +11 -2
- package/src/Images/Common/logo.png +0 -0
- package/src/Images/Common/logo@2x.png +0 -0
- package/src/Images/Common/logo@3x.png +0 -0
- package/src/commons/Device/ConnectedViewHeader.js +31 -21
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +3 -1
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +2 -0
- package/src/commons/SubUnit/ShortDetail.js +1 -1
- package/src/commons/UnitSummary/AirQuality/SegmentedRoundDisplay/index.js +4 -1
- package/src/configs/Constants.js +7 -0
- package/src/configs/Images.js +1 -0
- package/src/navigations/UnitStack.js +4 -1
- package/src/screens/AQIGuide/index.js +15 -4
- package/src/screens/AddNewAction/SelectAction.js +52 -4
- package/src/screens/AddNewAction/SelectSensorDevices.js +27 -5
- package/src/screens/AddNewAction/SetupSensor.js +1 -6
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +11 -1
- package/src/screens/AddNewAutoSmart/index.js +24 -13
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +4 -4
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +59 -1
- package/src/screens/AddNewOneTap/index.js +3 -0
- package/src/screens/Automate/MultiUnits.js +25 -12
- package/src/screens/Automate/__test__/MultiUnits.test.js +8 -5
- package/src/screens/Automate/__test__/index.test.js +5 -3
- package/src/screens/Automate/index.js +6 -10
- package/src/screens/Device/detail.js +9 -1
- package/src/screens/Notification/__test__/Notification.test.js +89 -0
- package/src/screens/Notification/components/NotificationItem.js +31 -14
- package/src/screens/Notification/styles/NotificationItemStyles.js +5 -0
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +12 -3
- package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +11 -2
- package/src/screens/ScanChipQR/components/QRScan/index.js +16 -0
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +12 -3
- package/src/screens/ScanSensorQR/index.js +6 -1
- package/src/screens/ScriptDetail/__test__/index.test.js +71 -0
- package/src/screens/ScriptDetail/index.js +56 -4
- package/src/screens/SetSchedule/__test__/index.test.js +8 -0
- package/src/screens/SetSchedule/index.js +28 -6
- package/src/screens/Sharing/Components/__test__/TitleCheckBox.test.js +38 -0
- package/src/screens/SyncLGDevice/AddLGDevice.js +1 -1
- package/src/screens/TDSGuide/index.js +15 -19
- package/src/screens/UVIndexGuide/index.js +15 -4
- package/src/screens/Unit/Detail.js +16 -26
- package/src/screens/Unit/__test__/Detail.test.js +0 -21
- package/src/screens/UnitSummary/components/UvIndex/index.js +3 -1
- package/src/screens/WaterQualityGuide/index.js +5 -1
- package/src/utils/I18n/translations/en.json +13 -2
- package/src/utils/I18n/translations/vi.json +26 -15
- package/src/utils/Route/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eohjsc/react-native-smart-city",
|
|
3
3
|
"title": "React Native Smart Home",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.46",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -39,7 +39,12 @@
|
|
|
39
39
|
"reset-cache": "react-native start --reset-cache",
|
|
40
40
|
"merge_conflict": "yarn jest && yarn update_coverage_result && yarn check_coverage_config",
|
|
41
41
|
"jest": "jest --detectOpenHandles",
|
|
42
|
-
"postinstall": "patch-package"
|
|
42
|
+
"postinstall": "patch-package",
|
|
43
|
+
"example": "yarn --cwd example",
|
|
44
|
+
"pods": "cd example && pod-install --quiet",
|
|
45
|
+
"bootstrap": "yarn example && yarn && yarn pods",
|
|
46
|
+
"build": "sync-files ./src ../EohMobile/node_modules/@eohjsc/react-native-smart-city/src",
|
|
47
|
+
"watch": "sync-files --watch ./src ../EohMobile/node_modules/@eohjsc/react-native-smart-city/src"
|
|
43
48
|
},
|
|
44
49
|
"repository": {
|
|
45
50
|
"type": "git",
|
|
@@ -49,6 +54,9 @@
|
|
|
49
54
|
"publishConfig": {
|
|
50
55
|
"registry": "https://registry.npmjs.org/"
|
|
51
56
|
},
|
|
57
|
+
"resolutions": {
|
|
58
|
+
"graceful-fs": "^4.2.4"
|
|
59
|
+
},
|
|
52
60
|
"keywords": [
|
|
53
61
|
"react-native"
|
|
54
62
|
],
|
|
@@ -187,6 +195,7 @@
|
|
|
187
195
|
"redux-persist": "^6.0.0",
|
|
188
196
|
"redux-saga": "^1.1.3",
|
|
189
197
|
"string-format": "^2.0.0",
|
|
198
|
+
"sync-files": "^1.0.3",
|
|
190
199
|
"timezone-mock": "^1.1.3",
|
|
191
200
|
"uuid-by-string": "^3.0.2",
|
|
192
201
|
"validator": "^13.1.1",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -21,27 +21,30 @@ const DisplayTextConnected = memo(({ type }) => {
|
|
|
21
21
|
return <Text style={styles.greenStatus}>{text}</Text>;
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
const ConnectedViewHeader = memo(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<View style={styles.
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{lastUpdatedStr && isDisplayTime && (
|
|
36
|
-
<View>
|
|
37
|
-
<Text color={Colors.Gray7} size={12} style={styles.txtLastUpdate}>
|
|
38
|
-
{`${t('last_updated')} ${lastUpdatedStr}`}
|
|
39
|
-
</Text>
|
|
24
|
+
const ConnectedViewHeader = memo(
|
|
25
|
+
({ lastUpdated, type, isDisplayTime, showWindDirection }) => {
|
|
26
|
+
const t = useTranslations();
|
|
27
|
+
const lastUpdatedStr = lastUpdated
|
|
28
|
+
? timeDifference(new Date(), lastUpdated)
|
|
29
|
+
: null;
|
|
30
|
+
return (
|
|
31
|
+
<View style={styles.statusContainer}>
|
|
32
|
+
<View style={styles.connectStatus}>
|
|
33
|
+
<IconOutline name={'wifi'} color={Colors.Green6} size={16} />
|
|
34
|
+
<DisplayTextConnected type={type} />
|
|
40
35
|
</View>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
36
|
+
{lastUpdatedStr && isDisplayTime && (
|
|
37
|
+
<View style={styles.showWindDirection}>
|
|
38
|
+
{showWindDirection && <Text>{t('current_wind_direction')} </Text>}
|
|
39
|
+
<Text color={Colors.Gray7} size={12} style={styles.txtLastUpdate}>
|
|
40
|
+
{`${t('last_updated')} ${lastUpdatedStr}`}
|
|
41
|
+
</Text>
|
|
42
|
+
</View>
|
|
43
|
+
)}
|
|
44
|
+
</View>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
);
|
|
45
48
|
|
|
46
49
|
const styles = StyleSheet.create({
|
|
47
50
|
statusContainer: {
|
|
@@ -52,7 +55,7 @@ const styles = StyleSheet.create({
|
|
|
52
55
|
connectStatus: {
|
|
53
56
|
flexDirection: 'row',
|
|
54
57
|
alignItems: 'center',
|
|
55
|
-
paddingVertical:
|
|
58
|
+
paddingVertical: 16,
|
|
56
59
|
},
|
|
57
60
|
greenStatus: {
|
|
58
61
|
marginLeft: 10,
|
|
@@ -62,6 +65,13 @@ const styles = StyleSheet.create({
|
|
|
62
65
|
txtLastUpdate: {
|
|
63
66
|
marginLeft: 8,
|
|
64
67
|
lineHeight: 20,
|
|
68
|
+
marginTop: 8,
|
|
69
|
+
},
|
|
70
|
+
showWindDirection: {
|
|
71
|
+
flexDirection: 'column',
|
|
72
|
+
justifyContent: 'center',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
marginBottom: 50,
|
|
65
75
|
},
|
|
66
76
|
});
|
|
67
77
|
|
|
@@ -20,7 +20,7 @@ import { useGetIdUser } from '../../../hooks/Common';
|
|
|
20
20
|
import { AUTOMATE_TYPE, TESTID } from '../../../configs/Constants';
|
|
21
21
|
|
|
22
22
|
const ItemOneTap = memo(
|
|
23
|
-
({ isOwner, automate, unit, wrapSyles, onPressItem }) => {
|
|
23
|
+
({ isOwner, automate = {}, unit, wrapSyles, onPressItem }) => {
|
|
24
24
|
const { navigate } = useNavigation();
|
|
25
25
|
const {
|
|
26
26
|
id,
|
|
@@ -54,6 +54,7 @@ const ItemOneTap = memo(
|
|
|
54
54
|
const goToDetail = useCallback(() => {
|
|
55
55
|
navigate(Routes.ScriptDetail, {
|
|
56
56
|
id,
|
|
57
|
+
automate,
|
|
57
58
|
name: script?.name,
|
|
58
59
|
type: type,
|
|
59
60
|
havePermission: isOwner || user === idUser,
|
|
@@ -61,6 +62,7 @@ const ItemOneTap = memo(
|
|
|
61
62
|
textCondition,
|
|
62
63
|
});
|
|
63
64
|
}, [
|
|
65
|
+
automate,
|
|
64
66
|
isOwner,
|
|
65
67
|
user,
|
|
66
68
|
idUser,
|
|
@@ -100,6 +100,7 @@ describe('test Item', () => {
|
|
|
100
100
|
type: 'one_tap',
|
|
101
101
|
unit: undefined,
|
|
102
102
|
textCondition: null,
|
|
103
|
+
automate: data.automates[0],
|
|
103
104
|
});
|
|
104
105
|
|
|
105
106
|
const handleScriptAction = instance.findAll(
|
|
@@ -196,6 +197,7 @@ describe('test Item', () => {
|
|
|
196
197
|
type: 'value_change',
|
|
197
198
|
unit: undefined,
|
|
198
199
|
textCondition: 'Temperature higher than 29',
|
|
200
|
+
automate: data.automates[0],
|
|
199
201
|
});
|
|
200
202
|
});
|
|
201
203
|
test('render SubUnitAutomate script schedule', async () => {
|
|
@@ -208,7 +208,7 @@ const SegmentedRoundDisplay = ({
|
|
|
208
208
|
...styles.boxTitle,
|
|
209
209
|
}}
|
|
210
210
|
>
|
|
211
|
-
<TextCustom size={14} color={Colors.White}>
|
|
211
|
+
<TextCustom size={14} color={Colors.White} style={styles.textTitle}>
|
|
212
212
|
{title}
|
|
213
213
|
</TextCustom>
|
|
214
214
|
</View>
|
|
@@ -269,4 +269,7 @@ const styles = StyleSheet.create({
|
|
|
269
269
|
paddingVertical: 2,
|
|
270
270
|
borderRadius: 100,
|
|
271
271
|
},
|
|
272
|
+
textTitle: {
|
|
273
|
+
lineHeight: 18,
|
|
274
|
+
},
|
|
272
275
|
});
|
package/src/configs/Constants.js
CHANGED
|
@@ -100,6 +100,12 @@ export const AUTOMATE_SELECT = {
|
|
|
100
100
|
SELECT_SENSOR: 'select_sensor',
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
+
export const CONDITION_TYPES = {
|
|
104
|
+
IS: 'IS',
|
|
105
|
+
IS_BELOW: 'IS_BELOW',
|
|
106
|
+
IS_ABOVE: 'IS_ABOVE',
|
|
107
|
+
};
|
|
108
|
+
|
|
103
109
|
export const AUTOMATES = {
|
|
104
110
|
one_tap: {
|
|
105
111
|
value: AUTOMATE_TYPE.ONE_TAP,
|
|
@@ -580,4 +586,5 @@ export const NOTIFICATION_TYPES = {
|
|
|
580
586
|
STOP_VIOLATION_FREE_PARKING_ZONE: 'STOP_VIOLATION_FREE_PARKING_ZONE',
|
|
581
587
|
PARKING_COMPLETED_DUE_TO_CAR_LEAVE: 'PARKING_COMPLETED_DUE_TO_CAR_LEAVE',
|
|
582
588
|
NOTIFY_INVITE_MEMBER: 'NOTIFY_INVITE_MEMBER',
|
|
589
|
+
REMINDER: 'REMINDER',
|
|
583
590
|
};
|
package/src/configs/Images.js
CHANGED
|
@@ -127,7 +127,10 @@ export const UnitStack = memo((props) => {
|
|
|
127
127
|
<Stack.Screen
|
|
128
128
|
name={Route.DeviceDetail}
|
|
129
129
|
component={DeviceDetail}
|
|
130
|
-
options={{
|
|
130
|
+
options={{
|
|
131
|
+
headerShown: false,
|
|
132
|
+
animationEnabled: false,
|
|
133
|
+
}}
|
|
131
134
|
/>
|
|
132
135
|
<Stack.Screen
|
|
133
136
|
name={Route.UVIndexGuide}
|
|
@@ -91,13 +91,17 @@ const AQIGuide = memo(() => {
|
|
|
91
91
|
<Text
|
|
92
92
|
testID={TESTID.AQI_GUIDE_MAIN_TITLE}
|
|
93
93
|
semibold
|
|
94
|
-
|
|
94
|
+
type="H3"
|
|
95
95
|
color={Colors.Gray9}
|
|
96
96
|
style={styles.titles}
|
|
97
97
|
>
|
|
98
98
|
{title}
|
|
99
99
|
</Text>
|
|
100
|
-
<Text
|
|
100
|
+
<Text
|
|
101
|
+
type="Body"
|
|
102
|
+
color={Colors.Gray8}
|
|
103
|
+
style={[styles.des, styles.lineHeight]}
|
|
104
|
+
>
|
|
101
105
|
{des}
|
|
102
106
|
</Text>
|
|
103
107
|
</View>
|
|
@@ -119,12 +123,16 @@ const AQIGuide = memo(() => {
|
|
|
119
123
|
<Text
|
|
120
124
|
testID={TESTID.AQI_GUIDE_UVINDEX_TITLE}
|
|
121
125
|
semibold
|
|
122
|
-
|
|
126
|
+
type="H4"
|
|
123
127
|
color={color}
|
|
124
128
|
>
|
|
125
129
|
{title}
|
|
126
130
|
</Text>
|
|
127
|
-
<Text
|
|
131
|
+
<Text
|
|
132
|
+
type="Body"
|
|
133
|
+
color={Colors.Gray8}
|
|
134
|
+
style={styles.lineHeight}
|
|
135
|
+
>
|
|
128
136
|
{des}
|
|
129
137
|
</Text>
|
|
130
138
|
</View>
|
|
@@ -152,6 +160,9 @@ const styles = StyleSheet.create({
|
|
|
152
160
|
des: {
|
|
153
161
|
marginHorizontal: 16,
|
|
154
162
|
},
|
|
163
|
+
lineHeight: {
|
|
164
|
+
lineHeight: 26,
|
|
165
|
+
},
|
|
155
166
|
containerUV: {
|
|
156
167
|
flexDirection: 'row',
|
|
157
168
|
marginTop: 16,
|
|
@@ -12,7 +12,7 @@ import OptionsDropdownActionTemplate from '../../commons/OneTapTemplate/OptionsD
|
|
|
12
12
|
import StatesGridActionTemplate from '../../commons/OneTapTemplate/StatesGridActionTemplate';
|
|
13
13
|
import { axiosGet, axiosPost } from '../../utils/Apis/axios';
|
|
14
14
|
import { API, Images } from '../../configs';
|
|
15
|
-
import { TESTID } from '../../configs/Constants';
|
|
15
|
+
import { CONDITION_TYPES, TESTID } from '../../configs/Constants';
|
|
16
16
|
import Routes from '../../utils/Route';
|
|
17
17
|
import styles from './Styles/SelectActionStyles';
|
|
18
18
|
import moment from 'moment';
|
|
@@ -30,6 +30,7 @@ const SelectAction = memo(({ route }) => {
|
|
|
30
30
|
unit,
|
|
31
31
|
device,
|
|
32
32
|
automateId,
|
|
33
|
+
automate = {},
|
|
33
34
|
scriptName,
|
|
34
35
|
isSelectSensor = false,
|
|
35
36
|
type,
|
|
@@ -42,9 +43,11 @@ const SelectAction = memo(({ route }) => {
|
|
|
42
43
|
const [sensorData, setSensorData] = useState([]);
|
|
43
44
|
const [checkedItem, setCheckedItem] = useState({});
|
|
44
45
|
const [isLoading, setIsLoading] = useState(false);
|
|
46
|
+
const [isfetched, setIsfetched] = useState(true);
|
|
45
47
|
|
|
46
48
|
const fetchData = useCallback(async () => {
|
|
47
49
|
isSelectSensor && setIsLoading(true);
|
|
50
|
+
setIsfetched(true);
|
|
48
51
|
const { success, data } = await axiosGet(
|
|
49
52
|
isSelectSensor
|
|
50
53
|
? API.AUTOMATE.GET_SENSOR_CONFIG(device.id)
|
|
@@ -53,13 +56,51 @@ const SelectAction = memo(({ route }) => {
|
|
|
53
56
|
isSelectSensor && true
|
|
54
57
|
);
|
|
55
58
|
if (success) {
|
|
56
|
-
|
|
59
|
+
if (isSelectSensor) {
|
|
60
|
+
if (automate?.config_id) {
|
|
61
|
+
const conditionType = [
|
|
62
|
+
{
|
|
63
|
+
title: `${t('is_below')} (<)`,
|
|
64
|
+
type: CONDITION_TYPES.IS_BELOW,
|
|
65
|
+
conditionValue: '<',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
title: `${t('is')} (=)`,
|
|
69
|
+
type: CONDITION_TYPES.IS,
|
|
70
|
+
conditionValue: '=',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
title: `${t('is_above')} (>)`,
|
|
74
|
+
type: CONDITION_TYPES.IS_ABOVE,
|
|
75
|
+
conditionValue: '>',
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
const condition = conditionType.find((item) => {
|
|
79
|
+
return item.conditionValue === automate.condition;
|
|
80
|
+
});
|
|
81
|
+
const updateSensorData = data.map((obj) =>
|
|
82
|
+
obj.id === automate.config_id
|
|
83
|
+
? { ...obj, value: automate.value, ...condition }
|
|
84
|
+
: obj
|
|
85
|
+
);
|
|
86
|
+
let selectSensor = data.find((config) => {
|
|
87
|
+
return config.id === automate.config_id;
|
|
88
|
+
});
|
|
89
|
+
setSensorData(updateSensorData);
|
|
90
|
+
setCheckedItem(selectSensor);
|
|
91
|
+
} else {
|
|
92
|
+
setSensorData(data);
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
setData(data);
|
|
96
|
+
}
|
|
57
97
|
}
|
|
98
|
+
setIsfetched(false);
|
|
58
99
|
const to = setTimeout(() => {
|
|
59
100
|
setIsLoading(false);
|
|
60
101
|
clearTimeout(to);
|
|
61
102
|
}, 1000);
|
|
62
|
-
}, [device.id, isSelectSensor]);
|
|
103
|
+
}, [automate, device.id, isSelectSensor, t]);
|
|
63
104
|
|
|
64
105
|
const checkConditionToContinue = useCallback(() => {
|
|
65
106
|
const itemTemp = sensorData?.find((i) => i.id === checkedItem?.id);
|
|
@@ -76,6 +117,13 @@ const SelectAction = memo(({ route }) => {
|
|
|
76
117
|
isSelectSensor,
|
|
77
118
|
isMultiUnits,
|
|
78
119
|
automateId,
|
|
120
|
+
automate: {
|
|
121
|
+
...automate,
|
|
122
|
+
condition: itemTemp?.conditionValue || '<',
|
|
123
|
+
value: itemTemp?.value,
|
|
124
|
+
config_id: itemTemp?.id,
|
|
125
|
+
config_name: itemTemp?.name,
|
|
126
|
+
},
|
|
79
127
|
scriptName,
|
|
80
128
|
});
|
|
81
129
|
} else {
|
|
@@ -302,7 +350,7 @@ const SelectAction = memo(({ route }) => {
|
|
|
302
350
|
testID={TESTID.ACTION_ITEM}
|
|
303
351
|
/>
|
|
304
352
|
)}
|
|
305
|
-
{data?.length === 0 && (
|
|
353
|
+
{data?.length === 0 && sensorData?.length === 0 && !isfetched && (
|
|
306
354
|
<View style={styles.noneData}>
|
|
307
355
|
<Text center>
|
|
308
356
|
{t('you_do_not_have_the_device_or_have_share_control_device')}
|
|
@@ -21,6 +21,7 @@ const SelectSensorDevices = memo(({ route }) => {
|
|
|
21
21
|
const {
|
|
22
22
|
unit,
|
|
23
23
|
automateId,
|
|
24
|
+
automate = {},
|
|
24
25
|
title = AUTOMATE_SELECT.SELECT_DEVICE,
|
|
25
26
|
type,
|
|
26
27
|
scriptName,
|
|
@@ -59,13 +60,29 @@ const SelectSensorDevices = memo(({ route }) => {
|
|
|
59
60
|
station: item,
|
|
60
61
|
index: index,
|
|
61
62
|
}));
|
|
63
|
+
if (isSelectSensor) {
|
|
64
|
+
if (automate.sensor_id) {
|
|
65
|
+
let selectSensor = {};
|
|
66
|
+
data.map((item) => {
|
|
67
|
+
item.sensors.map((sensor) => {
|
|
68
|
+
if (sensor.id === automate.sensor_id) {
|
|
69
|
+
selectSensor = sensor;
|
|
70
|
+
return;
|
|
71
|
+
} else if (selectSensor) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
setSelectedDevice(selectSensor);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
62
79
|
setStation(data);
|
|
63
80
|
setListMenuItem(listMenu);
|
|
64
81
|
setListStation(listMenu.concat([{ text: '' }]));
|
|
65
82
|
}
|
|
66
83
|
}
|
|
67
84
|
);
|
|
68
|
-
}, [isSelectSensor, unit
|
|
85
|
+
}, [automate.sensor_id, isSelectSensor, unit]);
|
|
69
86
|
|
|
70
87
|
useEffect(() => {
|
|
71
88
|
fetchDetails();
|
|
@@ -84,6 +101,10 @@ const SelectSensorDevices = memo(({ route }) => {
|
|
|
84
101
|
unit,
|
|
85
102
|
device: selectedDevice,
|
|
86
103
|
automateId: automateId,
|
|
104
|
+
automate: {
|
|
105
|
+
...automate,
|
|
106
|
+
sensor_id: selectedDevice?.id ? selectedDevice.id : automate.sensor_id,
|
|
107
|
+
},
|
|
87
108
|
stationName: station[indexStation]?.name,
|
|
88
109
|
isSelectSensor,
|
|
89
110
|
type,
|
|
@@ -93,18 +114,19 @@ const SelectSensorDevices = memo(({ route }) => {
|
|
|
93
114
|
isMultiUnits,
|
|
94
115
|
});
|
|
95
116
|
}, [
|
|
117
|
+
navigate,
|
|
118
|
+
unit,
|
|
96
119
|
selectedDevice,
|
|
97
120
|
automateId,
|
|
121
|
+
automate,
|
|
98
122
|
station,
|
|
99
123
|
indexStation,
|
|
100
|
-
navigate,
|
|
101
|
-
unit,
|
|
102
|
-
type,
|
|
103
124
|
isSelectSensor,
|
|
125
|
+
type,
|
|
104
126
|
scriptName,
|
|
105
|
-
isMultiUnits,
|
|
106
127
|
isAutomateTab,
|
|
107
128
|
isCreateNewAction,
|
|
129
|
+
isMultiUnits,
|
|
108
130
|
]);
|
|
109
131
|
|
|
110
132
|
const onPressClose = useCallback(() => {
|
|
@@ -13,12 +13,7 @@ import BottomButtonView from '../../commons/BottomButtonView';
|
|
|
13
13
|
import { HorizontalPicker } from '../../commons';
|
|
14
14
|
import { popAction } from '../../navigations/utils';
|
|
15
15
|
import { useStatusBarPreview } from '../../hooks/Common/useStatusBar';
|
|
16
|
-
|
|
17
|
-
const CONDITION_TYPES = {
|
|
18
|
-
IS: 'IS',
|
|
19
|
-
IS_BELOW: 'IS_BELOW',
|
|
20
|
-
IS_ABOVE: 'IS_ABOVE',
|
|
21
|
-
};
|
|
16
|
+
import { CONDITION_TYPES } from '../../configs/Constants';
|
|
22
17
|
|
|
23
18
|
const SetUpSensor = () => {
|
|
24
19
|
const t = useTranslations();
|
|
@@ -39,6 +39,10 @@ describe('test AddNewAutoSmart', () => {
|
|
|
39
39
|
},
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
mockNavigate.mockClear();
|
|
44
|
+
});
|
|
45
|
+
|
|
42
46
|
test('AddNewAutoSmart select sensor device', async () => {
|
|
43
47
|
await act(async () => {
|
|
44
48
|
tree = await create(wrapComponent(route));
|
|
@@ -62,8 +66,11 @@ describe('test AddNewAutoSmart', () => {
|
|
|
62
66
|
});
|
|
63
67
|
|
|
64
68
|
expect(mockNavigate).toBeCalledWith(Routes.SelectSensorDevices, {
|
|
69
|
+
automate: {},
|
|
70
|
+
automateId: undefined,
|
|
65
71
|
title: 'select_sensor',
|
|
66
72
|
type: 'value_change',
|
|
73
|
+
scriptName: undefined,
|
|
67
74
|
unit: { id: 1 },
|
|
68
75
|
isAutomateTab: undefined,
|
|
69
76
|
isMultiUnits: undefined,
|
|
@@ -92,11 +99,14 @@ describe('test AddNewAutoSmart', () => {
|
|
|
92
99
|
await bottomButton.props.onPress();
|
|
93
100
|
});
|
|
94
101
|
expect(mockNavigate).toHaveBeenCalledWith(Routes.SetSchedule, {
|
|
102
|
+
automate: {},
|
|
103
|
+
automateId: undefined,
|
|
95
104
|
type: 'schedule',
|
|
105
|
+
routeName: 'SetSchedule',
|
|
106
|
+
scriptName: undefined,
|
|
96
107
|
unit: route.params.unit,
|
|
97
108
|
isAutomateTab: undefined,
|
|
98
109
|
isMultiUnits: undefined,
|
|
99
|
-
routeName: 'SetSchedule',
|
|
100
110
|
});
|
|
101
111
|
});
|
|
102
112
|
});
|
|
@@ -17,8 +17,14 @@ import Routes from '../../utils/Route';
|
|
|
17
17
|
const AddNewAutoSmart = memo(({ route }) => {
|
|
18
18
|
const t = useTranslations();
|
|
19
19
|
const { navigate, goBack } = useNavigation();
|
|
20
|
-
const {
|
|
21
|
-
|
|
20
|
+
const {
|
|
21
|
+
type,
|
|
22
|
+
unit,
|
|
23
|
+
isAutomateTab,
|
|
24
|
+
isMultiUnits,
|
|
25
|
+
automate = {},
|
|
26
|
+
scriptName,
|
|
27
|
+
} = route.params;
|
|
22
28
|
const typeAutoSmart = {
|
|
23
29
|
[AUTOMATE_TYPE.AUTOMATE]: [
|
|
24
30
|
{
|
|
@@ -57,26 +63,31 @@ const AddNewAutoSmart = memo(({ route }) => {
|
|
|
57
63
|
},
|
|
58
64
|
],
|
|
59
65
|
};
|
|
60
|
-
const [data] = useState(
|
|
61
|
-
|
|
66
|
+
const [data] = useState(
|
|
67
|
+
automate?.id ? typeAutoSmart[AUTOMATE_TYPE.AUTOMATE] : typeAutoSmart[type]
|
|
68
|
+
);
|
|
69
|
+
const [selectedIndex, setSelectedIndex] = useState(
|
|
70
|
+
automate?.id ? data.findIndex((obj) => obj.type === type) : -1
|
|
71
|
+
);
|
|
62
72
|
|
|
63
73
|
const handleOnContinue = useCallback(() => {
|
|
64
|
-
const
|
|
74
|
+
const dataAutomate = data[selectedIndex];
|
|
65
75
|
const params = {
|
|
66
|
-
type:
|
|
76
|
+
type: dataAutomate?.type,
|
|
67
77
|
unit: unit,
|
|
68
|
-
...(
|
|
78
|
+
...(dataAutomate?.data || {}),
|
|
69
79
|
isAutomateTab,
|
|
70
80
|
isMultiUnits,
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
automateId: automate?.id,
|
|
82
|
+
routeName: dataAutomate?.route,
|
|
83
|
+
automate,
|
|
73
84
|
scriptName,
|
|
74
85
|
};
|
|
75
86
|
|
|
76
|
-
if (
|
|
87
|
+
if (dataAutomate.type === AUTOMATE_TYPE.VALUE_CHANGE && isMultiUnits) {
|
|
77
88
|
navigate(Routes.SelectUnit, params);
|
|
78
89
|
} else {
|
|
79
|
-
navigate(
|
|
90
|
+
navigate(dataAutomate.route, params);
|
|
80
91
|
}
|
|
81
92
|
}, [
|
|
82
93
|
navigate,
|
|
@@ -85,7 +96,7 @@ const AddNewAutoSmart = memo(({ route }) => {
|
|
|
85
96
|
unit,
|
|
86
97
|
isAutomateTab,
|
|
87
98
|
isMultiUnits,
|
|
88
|
-
|
|
99
|
+
automate,
|
|
89
100
|
scriptName,
|
|
90
101
|
]);
|
|
91
102
|
|
|
@@ -107,7 +118,7 @@ const AddNewAutoSmart = memo(({ route }) => {
|
|
|
107
118
|
<HeaderCustom isShowClose onClose={onClose} />
|
|
108
119
|
<View style={styles.container}>
|
|
109
120
|
<Text semibold type={'H2'} style={styles.titleCreate}>
|
|
110
|
-
{
|
|
121
|
+
{automate?.id ? t('update_smart') : t('create_smart')}
|
|
111
122
|
</Text>
|
|
112
123
|
<Text type={'Body'} style={styles.titleChoose}>
|
|
113
124
|
{t('choose_the_automation_method_you_want')}
|
|
@@ -107,11 +107,11 @@ const SetupGatewayWifi = memo(({ route }) => {
|
|
|
107
107
|
setDisplayLoadingConnect(true);
|
|
108
108
|
|
|
109
109
|
const timeoutId = setTimeout(async () => {
|
|
110
|
-
subcription.remove();
|
|
111
|
-
await device.cancelConnection();
|
|
112
110
|
setDisplayLoadingConnect(false);
|
|
113
111
|
setDisplayConnectFail(true);
|
|
114
|
-
|
|
112
|
+
subcription.remove();
|
|
113
|
+
await device.cancelConnection();
|
|
114
|
+
}, 7000);
|
|
115
115
|
setTimeoutSubcribtion(timeoutId);
|
|
116
116
|
}, [navigate, unit_id, wifiName, wifiPass]);
|
|
117
117
|
|
|
@@ -172,7 +172,7 @@ const SetupGatewayWifi = memo(({ route }) => {
|
|
|
172
172
|
</ScrollView>
|
|
173
173
|
|
|
174
174
|
<DisplayChecking
|
|
175
|
-
isOpacityLayout
|
|
175
|
+
isOpacityLayout={false} // conflict with AlertAction Modal
|
|
176
176
|
visible={displayLoadingConnect}
|
|
177
177
|
onClose={onHideDisplayLoading}
|
|
178
178
|
message={t('push_and_wait_chip_response')}
|