@eohjsc/react-native-smart-city 0.2.68 → 0.2.72
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/buttonLeftCurtain@2x.png +0 -0
- package/src/Images/Common/buttonLeftCurtain@3x.png +0 -0
- package/src/Images/Common/{buttonPause-center-curtain.png → buttonPauseCurtain.png} +0 -0
- package/src/Images/Common/buttonPauseCurtain@2x.png +0 -0
- package/src/Images/Common/buttonPauseCurtain@3x.png +0 -0
- package/src/Images/Common/buttonRightCurtain@2x.png +0 -0
- package/src/Images/Common/buttonRightCurtain@3x.png +0 -0
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +0 -30
- package/src/commons/ActionGroup/CurtainButtonTemplateStyle.js +0 -12
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +1 -1
- package/src/commons/AlertAction/index.js +4 -3
- package/src/commons/CameraDevice/index.js +1 -1
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +1 -1
- package/src/commons/SubUnit/OneTap/OneTapStyles.js +14 -5
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +5 -68
- package/src/commons/SubUnit/OneTap/index.js +24 -33
- package/src/commons/ViewButtonBottom/index.js +4 -0
- package/src/configs/Constants.js +2 -0
- package/src/configs/Images.js +1 -1
- package/src/context/SCContext.tsx +2 -0
- package/src/context/actionType.ts +2 -0
- package/src/context/reducer.ts +10 -0
- package/src/navigations/utils.js +3 -0
- package/src/screens/AddCommon/SelectSubUnit.js +10 -2
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +0 -22
- package/src/screens/AddNewOneTap/index.js +15 -13
- package/src/screens/Notification/components/NotificationItem.js +24 -1
- package/src/screens/Notification/styles/NotificationItemStyles.js +1 -1
- package/src/screens/SharedUnit/index.js +7 -5
- package/src/screens/Sharing/Components/SensorItem.js +27 -12
- package/src/screens/Sharing/Components/Styles/SensorItemStyles.js +4 -0
- package/src/screens/Sharing/SelectPermission.js +44 -32
- package/src/screens/Sharing/SelectUser.js +13 -1
- package/src/screens/Sharing/__test__/SelectPermission.test.js +2 -1
- package/src/screens/SubUnit/AddSubUnit.js +4 -1
- package/src/screens/Unit/Detail.js +8 -5
- package/src/screens/Unit/SmartAccount.js +36 -15
- package/src/screens/Unit/SmartAccountStyles.js +20 -0
- package/src/screens/Unit/hook/useStateAlertRemove.js +4 -6
- package/src/utils/I18n/translations/en.json +9 -2
- package/src/utils/I18n/translations/vi.json +10 -2
- package/src/utils/Route/index.js +1 -0
- package/src/commons/ActionGroup/__test__/MenuActionAddSchedule.test.js +0 -71
- package/src/commons/ActionGroup/hooks/AccessScheduleDetailStyles.js +0 -41
- package/src/commons/ActionGroup/hooks/MenuActionAddSchedule.js +0 -110
- package/src/commons/ActionGroup/hooks/MenuActionAddScheduleStyle.js +0 -69
- package/src/commons/ActionGroup/hooks/RecurringDetail.js +0 -97
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
import React, { memo, useCallback, useState } from 'react';
|
|
2
2
|
import { TouchableOpacity, View, Switch, Image } from 'react-native';
|
|
3
3
|
import { Icon } from '@ant-design/react-native';
|
|
4
|
-
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
5
4
|
import styles from './CurtainButtonTemplateStyle';
|
|
6
5
|
import Text from '../Text';
|
|
7
6
|
import { TESTID } from '../../configs/Constants';
|
|
8
7
|
import { Colors, Images } from '../../configs';
|
|
9
|
-
import { Section } from '../../commons/Section';
|
|
10
|
-
import { IconOutline } from '@ant-design/icons-react-native';
|
|
11
|
-
import MenuActionAddSchedule from './hooks/MenuActionAddSchedule';
|
|
12
|
-
import { useBoolean } from '../../hooks/Common';
|
|
13
8
|
|
|
14
9
|
const CurtainButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
15
|
-
const t = useTranslations();
|
|
16
10
|
const { configuration } = actionGroup;
|
|
17
11
|
const [lock, setLock] = useState(false);
|
|
18
|
-
const [isShowModal, setShowModal, setHideModal] = useBoolean(false);
|
|
19
|
-
|
|
20
12
|
const onButtonOpenPress = useCallback(
|
|
21
13
|
() => doAction(configuration.open_action_data),
|
|
22
14
|
[configuration.open_action_data, doAction]
|
|
@@ -118,28 +110,6 @@ const CurtainButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
|
118
110
|
lock ? Colors.Primary : Colors.Gray6
|
|
119
111
|
)}
|
|
120
112
|
</View>
|
|
121
|
-
<Section style={styles.section}>
|
|
122
|
-
<View style={styles.reminderOption}>
|
|
123
|
-
<Text type="H4" color={Colors.Gray8}>
|
|
124
|
-
{t('schedule')}
|
|
125
|
-
</Text>
|
|
126
|
-
<TouchableOpacity onPress={setShowModal}>
|
|
127
|
-
<IconOutline name="plus" size={20} />
|
|
128
|
-
</TouchableOpacity>
|
|
129
|
-
</View>
|
|
130
|
-
<View>
|
|
131
|
-
<TouchableOpacity
|
|
132
|
-
onPress={setShowModal}
|
|
133
|
-
style={styles.tapToAddSchedule}
|
|
134
|
-
>
|
|
135
|
-
<Text type="Body" color={Colors.Gray6} center>
|
|
136
|
-
{t('tap_to_add_new_schedule')}
|
|
137
|
-
</Text>
|
|
138
|
-
</TouchableOpacity>
|
|
139
|
-
</View>
|
|
140
|
-
|
|
141
|
-
<MenuActionAddSchedule visible={isShowModal} hideModal={setHideModal} />
|
|
142
|
-
</Section>
|
|
143
113
|
</>
|
|
144
114
|
);
|
|
145
115
|
});
|
|
@@ -29,18 +29,6 @@ export default StyleSheet.create({
|
|
|
29
29
|
alignItems: 'flex-end',
|
|
30
30
|
paddingLeft: 5,
|
|
31
31
|
},
|
|
32
|
-
section: {
|
|
33
|
-
marginHorizontal: 20,
|
|
34
|
-
borderRadius: 10,
|
|
35
|
-
},
|
|
36
|
-
reminderOption: {
|
|
37
|
-
flex: 1,
|
|
38
|
-
flexDirection: 'row',
|
|
39
|
-
justifyContent: 'space-between',
|
|
40
|
-
},
|
|
41
|
-
tapToAddSchedule: {
|
|
42
|
-
paddingVertical: 50,
|
|
43
|
-
},
|
|
44
32
|
buttonActionCurtain: {
|
|
45
33
|
flex: 1,
|
|
46
34
|
aspectRatio: 1,
|
|
@@ -67,6 +67,6 @@ describe('Test CurtainButtonTemplate', () => {
|
|
|
67
67
|
});
|
|
68
68
|
const instance = wrapper.root;
|
|
69
69
|
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
70
|
-
expect(touchableOpacities.length).toEqual(
|
|
70
|
+
expect(touchableOpacities.length).toEqual(3);
|
|
71
71
|
});
|
|
72
72
|
});
|
|
@@ -22,6 +22,8 @@ const AlertAction = ({
|
|
|
22
22
|
children,
|
|
23
23
|
testIDPrefix = '',
|
|
24
24
|
animatedStyle,
|
|
25
|
+
boxLeftButtonStyle,
|
|
26
|
+
boxRightButtonStyle,
|
|
25
27
|
}) => {
|
|
26
28
|
return (
|
|
27
29
|
<ModalCustom
|
|
@@ -54,6 +56,8 @@ const AlertAction = ({
|
|
|
54
56
|
onRightClick={rightButtonClick}
|
|
55
57
|
styleButtonLeftText={leftButtonStyle}
|
|
56
58
|
styleButtonRightText={rightButtonStyle}
|
|
59
|
+
styleButtonLeft={boxLeftButtonStyle}
|
|
60
|
+
styleButtonRight={boxRightButtonStyle}
|
|
57
61
|
testIDPrefix={testIDPrefix}
|
|
58
62
|
/>
|
|
59
63
|
</View>
|
|
@@ -85,10 +89,8 @@ const styles = StyleSheet.create({
|
|
|
85
89
|
modalHeader: {
|
|
86
90
|
padding: 16,
|
|
87
91
|
backgroundColor: Colors.White,
|
|
88
|
-
borderBottomWidth: 1,
|
|
89
92
|
borderTopLeftRadius: 20,
|
|
90
93
|
borderTopRightRadius: 20,
|
|
91
|
-
borderColor: Colors.Gray4,
|
|
92
94
|
},
|
|
93
95
|
modalHeaderText: {
|
|
94
96
|
fontSize: 16,
|
|
@@ -97,7 +99,6 @@ const styles = StyleSheet.create({
|
|
|
97
99
|
},
|
|
98
100
|
descriptionText: {
|
|
99
101
|
paddingHorizontal: 16,
|
|
100
|
-
paddingTop: 16,
|
|
101
102
|
},
|
|
102
103
|
});
|
|
103
104
|
|
|
@@ -33,13 +33,19 @@ export default StyleSheet.create({
|
|
|
33
33
|
alignItems: 'center',
|
|
34
34
|
paddingBottom: 3,
|
|
35
35
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
borderSelection: {
|
|
37
|
+
flexDirection: 'row',
|
|
38
|
+
justifyContent: 'center',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
paddingHorizontal: 5,
|
|
41
|
+
paddingLeft: 15,
|
|
39
42
|
borderRadius: 30,
|
|
40
43
|
backgroundColor: Colors.Gray3,
|
|
41
44
|
},
|
|
42
|
-
|
|
45
|
+
notShowBorder: {
|
|
46
|
+
paddingLeft: 15,
|
|
47
|
+
},
|
|
48
|
+
boxTextScenarito: {
|
|
43
49
|
justifyContent: 'center',
|
|
44
50
|
flexDirection: 'row',
|
|
45
51
|
alignItems: 'center',
|
|
@@ -48,8 +54,11 @@ export default StyleSheet.create({
|
|
|
48
54
|
android: 6,
|
|
49
55
|
}),
|
|
50
56
|
},
|
|
51
|
-
|
|
57
|
+
textSelection: {
|
|
52
58
|
color: Colors.Primary,
|
|
53
59
|
marginRight: 10,
|
|
54
60
|
},
|
|
61
|
+
boxScenario: {
|
|
62
|
+
flexDirection: 'row',
|
|
63
|
+
},
|
|
55
64
|
});
|
|
@@ -267,82 +267,19 @@ describe('test Item', () => {
|
|
|
267
267
|
expect(goDetail).toHaveLength(1);
|
|
268
268
|
});
|
|
269
269
|
|
|
270
|
-
test('render click select option
|
|
271
|
-
data.isOwner = false;
|
|
272
|
-
data.type = 'schedule';
|
|
273
|
-
data.listAutomate = [
|
|
274
|
-
{
|
|
275
|
-
text: AUTOMATE_TYPE.SCENARIO,
|
|
276
|
-
type: AUTOMATE_TYPE.ONE_TAP,
|
|
277
|
-
data: [
|
|
278
|
-
{
|
|
279
|
-
id: 1,
|
|
280
|
-
user: 6,
|
|
281
|
-
type: 'one_tap',
|
|
282
|
-
activate_at: null,
|
|
283
|
-
script: {
|
|
284
|
-
name: 'One-tap',
|
|
285
|
-
icon: '',
|
|
286
|
-
icon_kit: '',
|
|
287
|
-
},
|
|
288
|
-
},
|
|
289
|
-
],
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
text: AUTOMATE_TYPE.AUTOMATION,
|
|
293
|
-
type: AUTOMATE_TYPE.AUTOMATION,
|
|
294
|
-
data: [
|
|
295
|
-
{
|
|
296
|
-
id: 2,
|
|
297
|
-
user: 6,
|
|
298
|
-
type: 'schedule',
|
|
299
|
-
activate_at: null,
|
|
300
|
-
script: {
|
|
301
|
-
name: 'Rain',
|
|
302
|
-
icon: '',
|
|
303
|
-
icon_kit: '',
|
|
304
|
-
},
|
|
305
|
-
},
|
|
306
|
-
],
|
|
307
|
-
},
|
|
308
|
-
];
|
|
309
|
-
const response = {
|
|
310
|
-
status: 200,
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
await axios.post.mockImplementation(async () => {
|
|
314
|
-
return response;
|
|
315
|
-
});
|
|
316
|
-
|
|
270
|
+
test('render click select option by automation', async () => {
|
|
317
271
|
await act(async () => {
|
|
318
272
|
tree = await create(wrapComponent(data));
|
|
319
273
|
});
|
|
320
|
-
|
|
321
274
|
const instance = tree.root;
|
|
322
|
-
const
|
|
275
|
+
const touchableOpacity = instance.findAll(
|
|
323
276
|
(el) =>
|
|
324
277
|
el.props.testID === TESTID.SUB_UNIT_SELECT_AUTOMATE_TYPE &&
|
|
325
278
|
el.type === TouchableOpacity
|
|
326
279
|
);
|
|
327
|
-
|
|
328
|
-
|
|
280
|
+
act(() => {
|
|
281
|
+
touchableOpacity[0].props.onPress();
|
|
329
282
|
});
|
|
330
|
-
|
|
331
|
-
const menu = instance.find(
|
|
332
|
-
(el) => el.props.testID === TESTID.NAVBAR_MENU_ACTION_MORE
|
|
333
|
-
);
|
|
334
|
-
|
|
335
|
-
expect(menu.props.isVisible).toBeTruthy();
|
|
336
|
-
|
|
337
|
-
const automation = menu.props.listMenuItem[1];
|
|
338
|
-
|
|
339
|
-
await act(async () => {
|
|
340
|
-
await menu.props.onItemClick(automation, 1);
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
const text = instance.find(
|
|
344
|
-
(el) => el.props.testID === TESTID.SUB_UNIT_TEXT_DROPDOWN
|
|
345
|
-
);
|
|
346
|
-
expect(text.props.children).toEqual(AUTOMATE_TYPE.AUTOMATION);
|
|
283
|
+
expect(touchableOpacity).toHaveLength(1);
|
|
347
284
|
});
|
|
348
285
|
});
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { TouchableOpacity, View } from 'react-native';
|
|
3
|
-
import { Icon } from '@ant-design/react-native';
|
|
4
3
|
|
|
5
|
-
import {
|
|
4
|
+
import { Section } from '../..';
|
|
6
5
|
import ItemAddNew from '../../Device/ItemAddNew';
|
|
7
6
|
import ItemOneTap from './ItemOneTap';
|
|
8
7
|
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
9
8
|
import { useNavigation } from '@react-navigation/native';
|
|
10
9
|
import Routes from '../../../utils/Route/index.js';
|
|
11
10
|
import { AUTOMATE_TYPE, TESTID } from '../../../configs/Constants';
|
|
12
|
-
import { Colors } from '../../../configs/Colors.js';
|
|
13
|
-
import usePopover from '../../../hooks/Common/usePopover.js';
|
|
14
11
|
import Text from '../../Text/index.js';
|
|
15
12
|
|
|
16
13
|
import styles from './OneTapStyles.js';
|
|
@@ -33,11 +30,8 @@ const SubUnitAutomate = ({ isOwner, listAutomate, unit, wrapItemStyle }) => {
|
|
|
33
30
|
break;
|
|
34
31
|
}
|
|
35
32
|
};
|
|
36
|
-
const { childRef, showingPopover, showPopoverWithRef, hidePopover } =
|
|
37
|
-
usePopover();
|
|
38
33
|
|
|
39
34
|
const refMenuAction = useRef();
|
|
40
|
-
const handleShowMenuAction = () => showPopoverWithRef(refMenuAction);
|
|
41
35
|
|
|
42
36
|
const onItemClick = useCallback((item, index) => {
|
|
43
37
|
setAutomates(item);
|
|
@@ -50,23 +44,30 @@ const SubUnitAutomate = ({ isOwner, listAutomate, unit, wrapItemStyle }) => {
|
|
|
50
44
|
|
|
51
45
|
return (
|
|
52
46
|
<Section style={styles.noShadow}>
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
47
|
+
<View style={styles.boxScenario}>
|
|
48
|
+
{listAutomate.map((item, index) => (
|
|
49
|
+
<TouchableOpacity
|
|
50
|
+
style={
|
|
51
|
+
indexAutomate === index
|
|
52
|
+
? styles.borderSelection
|
|
53
|
+
: styles.notShowBorder
|
|
54
|
+
}
|
|
55
|
+
onPress={() => onItemClick(item, index)}
|
|
56
|
+
ref={refMenuAction}
|
|
57
|
+
testID={TESTID.SUB_UNIT_SELECT_AUTOMATE_TYPE}
|
|
64
58
|
>
|
|
65
|
-
{
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
<View style={styles.boxTextScenarito}>
|
|
60
|
+
<Text
|
|
61
|
+
testID={TESTID.SUB_UNIT_TEXT_DROPDOWN}
|
|
62
|
+
style={styles.textSelection}
|
|
63
|
+
semibold
|
|
64
|
+
>
|
|
65
|
+
{item?.text}
|
|
66
|
+
</Text>
|
|
67
|
+
</View>
|
|
68
|
+
</TouchableOpacity>
|
|
69
|
+
))}
|
|
70
|
+
</View>
|
|
70
71
|
<View style={styles.boxDevices}>
|
|
71
72
|
{automates?.data &&
|
|
72
73
|
automates.data.map((item) => (
|
|
@@ -78,16 +79,6 @@ const SubUnitAutomate = ({ isOwner, listAutomate, unit, wrapItemStyle }) => {
|
|
|
78
79
|
wrapStyle={wrapItemStyle}
|
|
79
80
|
/>
|
|
80
81
|
</View>
|
|
81
|
-
<MenuActionMore
|
|
82
|
-
isVisible={showingPopover}
|
|
83
|
-
hideMore={hidePopover}
|
|
84
|
-
listMenuItem={listAutomate}
|
|
85
|
-
childRef={childRef}
|
|
86
|
-
onItemClick={onItemClick}
|
|
87
|
-
isTextCenter={false}
|
|
88
|
-
testID={TESTID.NAVBAR_MENU_ACTION_MORE}
|
|
89
|
-
wrapStyle={styles.wrapStyle}
|
|
90
|
-
/>
|
|
91
82
|
</Section>
|
|
92
83
|
);
|
|
93
84
|
};
|
|
@@ -16,6 +16,8 @@ const ViewButtonBottom = ({
|
|
|
16
16
|
styleButton,
|
|
17
17
|
styleButtonLeftText,
|
|
18
18
|
styleButtonRightText,
|
|
19
|
+
styleButtonLeft,
|
|
20
|
+
styleButtonRight,
|
|
19
21
|
testIDPrefix = '',
|
|
20
22
|
}) => {
|
|
21
23
|
const useTwoButton = leftTitle && rightTitle;
|
|
@@ -27,6 +29,7 @@ const ViewButtonBottom = ({
|
|
|
27
29
|
style={[
|
|
28
30
|
styles.button,
|
|
29
31
|
styleButton,
|
|
32
|
+
styleButtonLeft,
|
|
30
33
|
useTwoButton && styles.buttonMarginRight,
|
|
31
34
|
]}
|
|
32
35
|
onPress={onLeftClick}
|
|
@@ -48,6 +51,7 @@ const ViewButtonBottom = ({
|
|
|
48
51
|
style={[
|
|
49
52
|
styles.button,
|
|
50
53
|
styleButton,
|
|
54
|
+
styleButtonRight,
|
|
51
55
|
useTwoButton && styles.buttonMarginLeft,
|
|
52
56
|
]}
|
|
53
57
|
onPress={onRightClick}
|
package/src/configs/Constants.js
CHANGED
|
@@ -610,6 +610,8 @@ export const NOTIFICATION_TYPES = {
|
|
|
610
610
|
PARKING_COMPLETED_DUE_TO_CAR_LEAVE: 'PARKING_COMPLETED_DUE_TO_CAR_LEAVE',
|
|
611
611
|
NOTIFY_INVITE_MEMBER: 'NOTIFY_INVITE_MEMBER',
|
|
612
612
|
REMINDER: 'REMINDER',
|
|
613
|
+
NOTIFY_REMOVE_UNIT: 'NOTIFY_REMOVE_UNIT',
|
|
614
|
+
NOTIFY_REMOVE_MEMBER: 'NOTIFY_REMOVE_MEMBER',
|
|
613
615
|
};
|
|
614
616
|
|
|
615
617
|
export const ACTIVITY_LOG_TYPES = {
|
package/src/configs/Images.js
CHANGED
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
file: require('../Images/Common/file.png'),
|
|
8
8
|
activeButton: require('../Images/Common/ActiveButton.png'),
|
|
9
9
|
logo: require('../Images/Common/logo.png'),
|
|
10
|
-
buttonPauseCurtain: require('../Images/Common/
|
|
10
|
+
buttonPauseCurtain: require('../Images/Common/buttonPauseCurtain.png'),
|
|
11
11
|
buttonLeftCurtain: require('../Images/Common/buttonLeftCurtain.png'),
|
|
12
12
|
buttonRightCurtain: require('../Images/Common/buttonRightCurtain.png'),
|
|
13
13
|
};
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from './actionType';
|
|
10
10
|
import { initialState, Action, ContextData, reducer } from './reducer';
|
|
11
11
|
import { setConfigGlobalState } from '../iot/states.js';
|
|
12
|
+
import { setAxiosDefaultLanguage } from '../utils/Utils';
|
|
12
13
|
|
|
13
14
|
type SCContextType = {
|
|
14
15
|
stateData: ContextData;
|
|
@@ -46,6 +47,7 @@ export const SCProvider = ({ children, initState = initialState }) => {
|
|
|
46
47
|
const setLocale = (language: Language) => {
|
|
47
48
|
setConfigGlobalState('lang', language);
|
|
48
49
|
setAction('UPDATE_LANGUAGE', language);
|
|
50
|
+
setAxiosDefaultLanguage(language);
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
const setAction = <T extends ActionType>(
|
|
@@ -5,6 +5,7 @@ export const Action = {
|
|
|
5
5
|
LIST_DEVICE_TYPES: 'LIST_DEVICE_TYPES',
|
|
6
6
|
LIST_ACTION: 'LIST_ACTION',
|
|
7
7
|
IS_FIRST_OPEN_CAMERA: 'IS_FIRST_OPEN_CAMERA',
|
|
8
|
+
IS_LAVIDA_SOURCE: 'IS_LAVIDA_SOURCE',
|
|
8
9
|
};
|
|
9
10
|
|
|
10
11
|
export type AuthData = {
|
|
@@ -48,4 +49,5 @@ export type ActionDataMap = {
|
|
|
48
49
|
|
|
49
50
|
export type AppType = {
|
|
50
51
|
isFirstOpenCamera: boolean;
|
|
52
|
+
isLavidaSource: boolean;
|
|
51
53
|
};
|
package/src/context/reducer.ts
CHANGED
|
@@ -39,6 +39,7 @@ export const initialState = {
|
|
|
39
39
|
listAction: [] as ListAction,
|
|
40
40
|
app: {
|
|
41
41
|
isFirstOpenCamera: true,
|
|
42
|
+
isLavidaSource: false,
|
|
42
43
|
},
|
|
43
44
|
};
|
|
44
45
|
|
|
@@ -97,6 +98,15 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
97
98
|
isFirstOpenCamera: payload,
|
|
98
99
|
},
|
|
99
100
|
};
|
|
101
|
+
case Action.IS_LAVIDA_SOURCE: {
|
|
102
|
+
return {
|
|
103
|
+
...currentState,
|
|
104
|
+
app: {
|
|
105
|
+
...currentState.app,
|
|
106
|
+
isLavidaSource: payload,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
100
110
|
default:
|
|
101
111
|
return currentState;
|
|
102
112
|
}
|
package/src/navigations/utils.js
CHANGED
|
@@ -17,8 +17,14 @@ const AddCommonSelectSubUnit = ({ route }) => {
|
|
|
17
17
|
const t = useTranslations();
|
|
18
18
|
const navigation = useNavigation();
|
|
19
19
|
const isFocused = useIsFocused();
|
|
20
|
-
const {
|
|
21
|
-
|
|
20
|
+
const {
|
|
21
|
+
addType,
|
|
22
|
+
unit_id,
|
|
23
|
+
sensor_data,
|
|
24
|
+
listSelectDevice,
|
|
25
|
+
smart_account_id,
|
|
26
|
+
smart_account_id_from_backend,
|
|
27
|
+
} = route.params;
|
|
22
28
|
const [selectedIndex, setSelectedIndex] = useState(-1);
|
|
23
29
|
const [unit, setUnit] = useState([]);
|
|
24
30
|
const [title, setTitle] = useState('');
|
|
@@ -79,6 +85,7 @@ const AddCommonSelectSubUnit = ({ route }) => {
|
|
|
79
85
|
listSelectDevice: listSelectDevice,
|
|
80
86
|
smart_account_id: smart_account_id,
|
|
81
87
|
unit_id: unit_id,
|
|
88
|
+
smart_account_id_from_backend: smart_account_id_from_backend,
|
|
82
89
|
});
|
|
83
90
|
break;
|
|
84
91
|
case 'AddVconnexDevice':
|
|
@@ -107,6 +114,7 @@ const AddCommonSelectSubUnit = ({ route }) => {
|
|
|
107
114
|
listSelectDevice,
|
|
108
115
|
smart_account_id,
|
|
109
116
|
unit_id,
|
|
117
|
+
smart_account_id_from_backend,
|
|
110
118
|
]);
|
|
111
119
|
|
|
112
120
|
const handleSelectIndex = (index) => {
|
|
@@ -99,28 +99,6 @@ describe('test AddNewOneTap', () => {
|
|
|
99
99
|
await act(async () => {
|
|
100
100
|
await item[0].props.onPress();
|
|
101
101
|
});
|
|
102
|
-
expect(mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail, {
|
|
103
|
-
havePermission: true,
|
|
104
|
-
id: 1,
|
|
105
|
-
type: 'one_tap',
|
|
106
|
-
name: 'Tap to up',
|
|
107
|
-
unit: {
|
|
108
|
-
id: 1,
|
|
109
|
-
},
|
|
110
|
-
isCreateScriptSuccess: true,
|
|
111
|
-
automate: {
|
|
112
|
-
id: 1,
|
|
113
|
-
script: {
|
|
114
|
-
id: 1,
|
|
115
|
-
name: 'William Miller',
|
|
116
|
-
},
|
|
117
|
-
type: 'one_tap',
|
|
118
|
-
unit: 1,
|
|
119
|
-
weekday_repeat: [],
|
|
120
|
-
},
|
|
121
|
-
isAutomateTab: false,
|
|
122
|
-
isMultiUnits: false,
|
|
123
|
-
});
|
|
124
102
|
});
|
|
125
103
|
test('create AddNewOneTap fail', async () => {
|
|
126
104
|
Platform.OS = 'android';
|
|
@@ -12,7 +12,7 @@ import Text from '../../commons/Text';
|
|
|
12
12
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
13
13
|
import { axiosPost, axiosPut } from '../../utils/Apis/axios';
|
|
14
14
|
import Routes from '../../utils/Route';
|
|
15
|
-
import { popAction } from '../../navigations/utils';
|
|
15
|
+
import { popAction, replace } from '../../navigations/utils';
|
|
16
16
|
import { AUTOMATE_TYPE } from '../../configs/Constants';
|
|
17
17
|
|
|
18
18
|
const AddNewOneTap = memo(({ route }) => {
|
|
@@ -41,17 +41,19 @@ const AddNewOneTap = memo(({ route }) => {
|
|
|
41
41
|
? await axiosPut(API.AUTOMATE.UPDATE_AUTOMATE(automateId), params)
|
|
42
42
|
: await axiosPost(API.AUTOMATE.CREATE_AUTOMATE(), params);
|
|
43
43
|
if (success) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
dispatch(
|
|
45
|
+
replace(Routes.ScriptDetail, {
|
|
46
|
+
unit: unit,
|
|
47
|
+
id: data.id,
|
|
48
|
+
name: name,
|
|
49
|
+
type: type,
|
|
50
|
+
automate: { ...automate, ...data },
|
|
51
|
+
havePermission: true,
|
|
52
|
+
isCreateScriptSuccess: true,
|
|
53
|
+
isAutomateTab: isAutomateTab,
|
|
54
|
+
isMultiUnits,
|
|
55
|
+
})
|
|
56
|
+
);
|
|
55
57
|
}
|
|
56
58
|
}, [
|
|
57
59
|
isMultiUnits,
|
|
@@ -61,7 +63,7 @@ const AddNewOneTap = memo(({ route }) => {
|
|
|
61
63
|
automateData,
|
|
62
64
|
automate,
|
|
63
65
|
automateId,
|
|
64
|
-
|
|
66
|
+
dispatch,
|
|
65
67
|
isAutomateTab,
|
|
66
68
|
]);
|
|
67
69
|
|
|
@@ -67,7 +67,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
67
67
|
iconContent: (
|
|
68
68
|
<IconComponent
|
|
69
69
|
icon_outlined={'usergroup-add'}
|
|
70
|
-
style={styles.
|
|
70
|
+
style={styles.backgroundSummer}
|
|
71
71
|
/>
|
|
72
72
|
),
|
|
73
73
|
};
|
|
@@ -220,6 +220,29 @@ const NotificationItem = memo(({ item }) => {
|
|
|
220
220
|
params: { id: booking_id },
|
|
221
221
|
}),
|
|
222
222
|
};
|
|
223
|
+
case NOTIFICATION_TYPES.NOTIFY_REMOVE_UNIT:
|
|
224
|
+
const unitOwerName = paramsJSON?.unit_owner_name;
|
|
225
|
+
const textNotify = unitOwerName
|
|
226
|
+
? t('text_notification_content_remove_unit_to_member')
|
|
227
|
+
: t('text_notification_content_remove_unit_to_owner');
|
|
228
|
+
return {
|
|
229
|
+
content: customColorText(textNotify, arrParams),
|
|
230
|
+
redirect: () => null,
|
|
231
|
+
iconContent: (
|
|
232
|
+
<IconComponent icon={'home'} style={styles.backgroundSummer} />
|
|
233
|
+
),
|
|
234
|
+
};
|
|
235
|
+
case NOTIFICATION_TYPES.NOTIFY_REMOVE_MEMBER:
|
|
236
|
+
return {
|
|
237
|
+
content: customColorText(
|
|
238
|
+
t('text_notification_content_remove_member'),
|
|
239
|
+
arrParams
|
|
240
|
+
),
|
|
241
|
+
redirect: () => null,
|
|
242
|
+
iconContent: (
|
|
243
|
+
<IconComponent icon={'home'} style={styles.backgroundSummer} />
|
|
244
|
+
),
|
|
245
|
+
};
|
|
223
246
|
default:
|
|
224
247
|
return {
|
|
225
248
|
content: customColorText(t('this_notification_will_be_updated_soon')),
|