@eohjsc/react-native-smart-city 0.7.10 → 0.7.12
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 +2 -2
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +3 -7
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +2 -5
- package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +2 -6
- package/src/screens/Automate/AddNewAction/SetupScriptReceiverEmail.js +1 -1
- package/src/screens/Automate/AddNewAction/__test__/ChooseAction.test.js +1 -1
- package/src/screens/Automate/EditActionsList/UpdateReceiverEmailScript.js +1 -1
- package/src/screens/Automate/ScriptDetail/Styles/indexStyles.js +10 -0
- package/src/screens/Automate/ScriptDetail/index.js +2 -2
- package/src/screens/SubUnit/ManageSubUnit.js +12 -9
- package/src/screens/SubUnit/RearrageSubUnit.js +8 -7
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +24 -9
- package/src/screens/SubUnit/__test__/RearrangeSubUnit.test.js +20 -10
- package/src/utils/I18n/translations/en.js +0 -1
- package/src/utils/I18n/translations/vi.js +0 -1
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.7.
|
|
4
|
+
"version": "0.7.12",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
"react-native-geocoder": "^0.5.0",
|
|
156
156
|
"react-native-gesture-handler": "^2.17.1",
|
|
157
157
|
"react-native-get-location": "^2.0.0",
|
|
158
|
-
"react-native-image-crop-picker": "
|
|
158
|
+
"react-native-image-crop-picker": "0.41.2",
|
|
159
159
|
"react-native-image-resizer": "^1.4.5",
|
|
160
160
|
"react-native-input-credit-card": "^0.5.5",
|
|
161
161
|
"react-native-iphone-x-helper": "^1.2.1",
|
|
@@ -38,15 +38,11 @@ const GridItem = ({ item, doAction, sensor }) => {
|
|
|
38
38
|
|
|
39
39
|
const doActionAndWatchConfig = useCallback(
|
|
40
40
|
(actionData) => {
|
|
41
|
-
let data =
|
|
41
|
+
let data = null;
|
|
42
42
|
if (allow_config_store_value && config) {
|
|
43
|
-
data = {
|
|
44
|
-
config_id: config,
|
|
45
|
-
config_value: is_on_value,
|
|
46
|
-
value: is_on_value,
|
|
47
|
-
};
|
|
43
|
+
data = JSON.stringify({ config_id: config, config_value: is_on_value });
|
|
48
44
|
}
|
|
49
|
-
doAction(actionData,
|
|
45
|
+
doAction(actionData, data);
|
|
50
46
|
if (sensor?.is_managed_by_backend) {
|
|
51
47
|
if (config && sensor.device_type === DEVICE_TYPE.LG_THINQ) {
|
|
52
48
|
watchMultiConfigs([config]);
|
|
@@ -75,10 +75,7 @@ describe('Test StatesGridActionTemplate', () => {
|
|
|
75
75
|
await act(async () => {
|
|
76
76
|
await touchableOpacities[0].props.onPress();
|
|
77
77
|
});
|
|
78
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
79
|
-
mockActionData,
|
|
80
|
-
JSON.stringify({ value: 1 })
|
|
81
|
-
);
|
|
78
|
+
expect(mockDoAction).toHaveBeenCalledWith(mockActionData, null);
|
|
82
79
|
});
|
|
83
80
|
|
|
84
81
|
it('test trigger special action', async () => {
|
|
@@ -102,7 +99,7 @@ describe('Test StatesGridActionTemplate', () => {
|
|
|
102
99
|
});
|
|
103
100
|
expect(mockDoAction).toHaveBeenCalledWith(
|
|
104
101
|
mockActionData,
|
|
105
|
-
JSON.stringify({ config_id: 1, config_value: 1
|
|
102
|
+
JSON.stringify({ config_id: 1, config_value: 1 })
|
|
106
103
|
);
|
|
107
104
|
});
|
|
108
105
|
});
|
|
@@ -16,14 +16,10 @@ const ActionItem = ({
|
|
|
16
16
|
item,
|
|
17
17
|
}) => {
|
|
18
18
|
const handleSelectAction = useCallback(() => {
|
|
19
|
-
let actionData =
|
|
19
|
+
let actionData = null;
|
|
20
20
|
const { allow_config_store_value, config, is_on_value } = item;
|
|
21
21
|
if (allow_config_store_value && config) {
|
|
22
|
-
actionData = {
|
|
23
|
-
config_id: config,
|
|
24
|
-
config_value: is_on_value,
|
|
25
|
-
value: is_on_value,
|
|
26
|
-
};
|
|
22
|
+
actionData = { config_id: config, config_value: is_on_value };
|
|
27
23
|
}
|
|
28
24
|
setActionName(item.text);
|
|
29
25
|
|
|
@@ -11,9 +11,9 @@ import { API, Colors } from '../../../configs';
|
|
|
11
11
|
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
12
12
|
import Routes from '../../../utils/Route';
|
|
13
13
|
import moment from 'moment';
|
|
14
|
-
import { Image } from 'react-native-svg';
|
|
15
14
|
import CheckBox from '@react-native-community/checkbox';
|
|
16
15
|
import { useSCContextSelector } from '../../../context';
|
|
16
|
+
import { Image } from 'react-native';
|
|
17
17
|
|
|
18
18
|
const SetupScriptReceiverEmail = ({ route }) => {
|
|
19
19
|
const t = useTranslations();
|
|
@@ -11,9 +11,9 @@ import { API, Colors } from '../../../configs';
|
|
|
11
11
|
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
12
12
|
import Routes from '../../../utils/Route';
|
|
13
13
|
import moment from 'moment';
|
|
14
|
-
import { Image } from 'react-native-svg';
|
|
15
14
|
import CheckBox from '@react-native-community/checkbox';
|
|
16
15
|
import { useSCContextSelector } from '../../../context';
|
|
16
|
+
import { Image } from 'react-native';
|
|
17
17
|
|
|
18
18
|
const UpdateReceiverEmailScript = ({ route }) => {
|
|
19
19
|
const t = useTranslations();
|
|
@@ -80,6 +80,16 @@ export default StyleSheet.create({
|
|
|
80
80
|
height: 100,
|
|
81
81
|
marginBottom: 16,
|
|
82
82
|
},
|
|
83
|
+
rightItemAction: {
|
|
84
|
+
flex: 1,
|
|
85
|
+
borderColor: Colors.Gray4,
|
|
86
|
+
borderWidth: 1,
|
|
87
|
+
borderRadius: 4,
|
|
88
|
+
paddingVertical: 15,
|
|
89
|
+
paddingHorizontal: 16,
|
|
90
|
+
marginLeft: 4,
|
|
91
|
+
flexDirection: 'row',
|
|
92
|
+
},
|
|
83
93
|
leftItem: {
|
|
84
94
|
width: 41,
|
|
85
95
|
height: '100%',
|
|
@@ -311,7 +311,7 @@ const ScriptDetail = ({ route }) => {
|
|
|
311
311
|
|
|
312
312
|
<View style={styles.row}>
|
|
313
313
|
<Text type="H3" color={Colors.Gray9} semibold>
|
|
314
|
-
{t('
|
|
314
|
+
{t('actions_list')}
|
|
315
315
|
</Text>
|
|
316
316
|
{data.length > 0 && !!can_edit && !!enableScript && (
|
|
317
317
|
<TouchableOpacity
|
|
@@ -414,7 +414,7 @@ const Item = ({ item, index, enableScript, t }) => {
|
|
|
414
414
|
{paddedIndex}
|
|
415
415
|
</Text>
|
|
416
416
|
</View>
|
|
417
|
-
<View style={styles.
|
|
417
|
+
<View style={styles.rightItemAction}>
|
|
418
418
|
<IconComponent icon={sensor_icon_kit} style={styles.iconEndDevice} />
|
|
419
419
|
<View style={styles.contentItem}>
|
|
420
420
|
<View style={styles.titleItem}>
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
import { Image, TouchableOpacity, View } from 'react-native';
|
|
1
2
|
import React, { useEffect } from 'react';
|
|
2
|
-
import { View, TouchableOpacity, Image } from 'react-native';
|
|
3
3
|
import { useIsFocused, useNavigation } from '@react-navigation/native';
|
|
4
|
+
|
|
5
|
+
import { AccessibilityLabel } from '../../configs/Constants';
|
|
4
6
|
import { Colors } from '../../configs';
|
|
5
|
-
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
6
|
-
import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
|
|
7
|
-
import Text from '../../commons/Text';
|
|
8
|
-
import styles from './ManageSubUnitStyles';
|
|
9
7
|
import { IconOutline } from '@ant-design/icons-react-native';
|
|
10
8
|
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
|
11
|
-
import Routes from '../../utils/Route';
|
|
12
9
|
import NoSubUnitImage from '../../../assets/images/Illustrations.svg';
|
|
13
|
-
import
|
|
14
|
-
import { AccessibilityLabel } from '../../configs/Constants';
|
|
10
|
+
import Routes from '../../utils/Route';
|
|
15
11
|
import { RowItem } from '../../commons/RowItem';
|
|
12
|
+
import Text from '../../commons/Text';
|
|
13
|
+
import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
|
|
14
|
+
import styles from './ManageSubUnitStyles';
|
|
15
|
+
import useManageSubUnit from './hooks/useManageSubUnit';
|
|
16
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
16
17
|
|
|
17
18
|
const RightComponent = ({ onAddSubUnit, onRearrangeSubUnit }) => (
|
|
18
19
|
<View style={styles.rightComponent}>
|
|
@@ -50,7 +51,9 @@ const StationList = ({ stations, onEditSubUnit }) => {
|
|
|
50
51
|
/>
|
|
51
52
|
}
|
|
52
53
|
text={item.name}
|
|
53
|
-
subtext={`${item.devices
|
|
54
|
+
subtext={`${item.devices?.length || 0} ${t(
|
|
55
|
+
'devices'
|
|
56
|
+
).toLowerCase()}`}
|
|
54
57
|
onPress={() => onEditSubUnit(item)}
|
|
55
58
|
rightComponent={
|
|
56
59
|
<IconOutline name="right" size={20} color={Colors.Gray6} />
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
3
|
+
|
|
4
4
|
import { API } from '../../configs';
|
|
5
|
-
import { axiosPost } from '../../utils/Apis/axios';
|
|
6
|
-
import styles from './RearrrageSubUnitStyle';
|
|
7
|
-
import Text from '../../commons/Text';
|
|
8
5
|
import FlatListDnD from '../../commons/FlatListDnD';
|
|
9
|
-
import ViewButtonBottom from '../../commons/ViewButtonBottom';
|
|
10
6
|
import { HeaderCustom } from '../../commons/Header';
|
|
11
7
|
import Rearrange from '../../../assets/images/Rearrange.svg';
|
|
8
|
+
import Text from '../../commons/Text';
|
|
12
9
|
import { ToastBottomHelper } from '../../utils/Utils';
|
|
10
|
+
import ViewButtonBottom from '../../commons/ViewButtonBottom';
|
|
11
|
+
import { axiosPost } from '../../utils/Apis/axios';
|
|
12
|
+
import { isEqual } from 'lodash';
|
|
13
|
+
import styles from './RearrrageSubUnitStyle';
|
|
13
14
|
import { useNavigation } from '@react-navigation/native';
|
|
14
15
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
15
16
|
|
|
@@ -55,7 +56,7 @@ const RearrangeSubUnit = ({ route }) => {
|
|
|
55
56
|
>
|
|
56
57
|
<Text style={styles.indexText}>{item.name}</Text>
|
|
57
58
|
<Text style={styles.deviceText}>
|
|
58
|
-
{`${item.devices
|
|
59
|
+
{`${item.devices?.length || 0} ${t('devices').toLowerCase()}`}
|
|
59
60
|
</Text>
|
|
60
61
|
</View>
|
|
61
62
|
</View>
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { ScrollView, TouchableOpacity } from 'react-native';
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import ManageSubUnit from '../ManageSubUnit';
|
|
6
|
-
import { SCProvider } from '../../../context';
|
|
7
|
-
import { mockSCStore } from '../../../context/mockStore';
|
|
8
|
-
import { RowItem } from '../../../commons/RowItem';
|
|
9
|
-
import Routes from '../../../utils/Route';
|
|
2
|
+
|
|
3
|
+
import API from '../../../configs/API';
|
|
10
4
|
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
5
|
+
import ManageSubUnit from '../ManageSubUnit';
|
|
11
6
|
import MockAdapter from 'axios-mock-adapter';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import Routes from '../../../utils/Route';
|
|
9
|
+
import { RowItem } from '../../../commons/RowItem';
|
|
10
|
+
import { SCProvider } from '../../../context';
|
|
11
|
+
import { act } from '@testing-library/react-hooks';
|
|
12
12
|
import api from '../../../utils/Apis/axios';
|
|
13
|
+
import { create } from 'react-test-renderer';
|
|
14
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
13
15
|
import { useNavigation } from '@react-navigation/native';
|
|
14
|
-
import API from '../../../configs/API';
|
|
15
16
|
|
|
16
17
|
const mock = new MockAdapter(api.axiosInstance);
|
|
17
18
|
|
|
@@ -58,6 +59,20 @@ describe('Test ManageSubUnit', () => {
|
|
|
58
59
|
screen: Routes.EditSubUnit,
|
|
59
60
|
});
|
|
60
61
|
});
|
|
62
|
+
|
|
63
|
+
it('render ManageSubUnit station without device', async () => {
|
|
64
|
+
data = [{ id: 1, name: 'station' }];
|
|
65
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, { stations: data });
|
|
66
|
+
await act(async () => {
|
|
67
|
+
tree = await create(wrapComponent(route));
|
|
68
|
+
});
|
|
69
|
+
const instance = tree.root;
|
|
70
|
+
const subUnitScrollViews = instance.findAllByType(ScrollView);
|
|
71
|
+
expect(subUnitScrollViews).toHaveLength(1);
|
|
72
|
+
const rowItem = instance.findAllByType(RowItem);
|
|
73
|
+
expect(rowItem).toHaveLength(1);
|
|
74
|
+
});
|
|
75
|
+
|
|
61
76
|
it('ManageSubUnit add sub unit', async () => {
|
|
62
77
|
await act(async () => {
|
|
63
78
|
tree = await create(wrapComponent(route));
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { create } from 'react-test-renderer';
|
|
3
|
-
import { act } from '@testing-library/react-hooks';
|
|
4
1
|
import { API } from '../../../configs';
|
|
5
|
-
import
|
|
2
|
+
import DraggableFlatList from 'react-native-draggable-flatlist';
|
|
3
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import RearrageSubUnit from '../RearrageSubUnit';
|
|
6
6
|
import { SCProvider } from '../../../context';
|
|
7
|
-
import {
|
|
7
|
+
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
8
|
+
import { ViewButtonBottom } from '../../../commons';
|
|
9
|
+
import { act } from '@testing-library/react-hooks';
|
|
8
10
|
import api from '../../../utils/Apis/axios';
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
+
import { create } from 'react-test-renderer';
|
|
12
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
11
13
|
import { useNavigation } from '@react-navigation/native';
|
|
12
|
-
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
13
|
-
import DraggableFlatList from 'react-native-draggable-flatlist';
|
|
14
14
|
|
|
15
15
|
const mock = new MockAdapter(api.axiosInstance);
|
|
16
16
|
|
|
@@ -93,6 +93,16 @@ describe('Test RearrangeSubUnit', () => {
|
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
it('test call api error', async () => {
|
|
96
|
+
route = {
|
|
97
|
+
params: {
|
|
98
|
+
unit: { id: 1, name: 'unit 1' },
|
|
99
|
+
stations: [
|
|
100
|
+
{ id: 1, name: 'station 1', devices: [{ id: 1, name: 'device 1' }] },
|
|
101
|
+
{ id: 2, name: 'station 2' },
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
|
|
96
106
|
await act(async () => {
|
|
97
107
|
tree = await create(wrapComponent(route));
|
|
98
108
|
});
|
|
@@ -106,7 +116,7 @@ describe('Test RearrangeSubUnit', () => {
|
|
|
106
116
|
expect(flatListDnD.props.data).toEqual(route.params.stations);
|
|
107
117
|
|
|
108
118
|
const swappedStations = [
|
|
109
|
-
{ id: 2, name: 'station 2'
|
|
119
|
+
{ id: 2, name: 'station 2' },
|
|
110
120
|
{ id: 1, name: 'station 1', devices: [{ id: 1, name: 'device 1' }] },
|
|
111
121
|
];
|
|
112
122
|
|
|
@@ -267,7 +267,6 @@ export default {
|
|
|
267
267
|
setup_the_conditions: 'Setup the conditions',
|
|
268
268
|
setup_the_schedule: 'Setup the Schedule',
|
|
269
269
|
des_launch_one_tap: 'Quick button create at the dashboard',
|
|
270
|
-
active_list: 'Actions List',
|
|
271
270
|
text_very_good_level: 'Very good',
|
|
272
271
|
text_good_level: 'Good',
|
|
273
272
|
text_moderate_level: 'Moderate',
|
|
@@ -50,7 +50,6 @@ export default {
|
|
|
50
50
|
schedule: 'Lịch trình',
|
|
51
51
|
event: 'Sự kiện',
|
|
52
52
|
des_launch_one_tap: 'Tạo nút nhanh trên trang tổng quan',
|
|
53
|
-
active_list: 'Danh sách hành động',
|
|
54
53
|
filtering: 'Đang sục rửa',
|
|
55
54
|
insufficient_water_input: 'Thiếu nước đầu vào.',
|
|
56
55
|
check_water_leak: 'Kiểm tra rò rỉ nước.',
|