@eohjsc/react-native-smart-city 0.7.37 → 0.7.39
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 +4 -1
- package/src/commons/Unit/HeaderUnit/index.js +1 -1
- package/src/commons/WrapParallaxScrollView/index.js +1 -1
- package/src/screens/Automate/AddNewAction/ChooseAction.js +7 -1
- package/src/screens/Automate/AddNewAction/NewActionWrapper.js +4 -2
- package/src/screens/Automate/AddNewAction/SetupScriptDelay.js +3 -3
- package/src/screens/Automate/AddNewAction/SetupScriptEmail.js +3 -2
- package/src/screens/Automate/AddNewAction/SetupScriptNotify.js +3 -2
- package/src/screens/Automate/AddNewAction/SetupScriptReceiverEmail.js +3 -3
- package/src/screens/Automate/AddNewAction/SetupScriptReceiverNotify.js +3 -3
- package/src/screens/Automate/AddNewAction/SetupScriptReceiverSms.js +3 -3
- package/src/screens/Automate/AddNewAction/SetupScriptSms.js +3 -2
- package/src/screens/Automate/AddNewAction/__test__/SetupScriptEmail.test.js +1 -0
- package/src/screens/Automate/AddNewAction/__test__/SetupScriptNotify.test.js +2 -0
- package/src/screens/Automate/AddNewAction/__test__/SetupScriptSms.test.js +1 -0
- package/src/screens/Automate/EditActionsList/UpdateReceiverEmailScript.js +1 -1
- package/src/screens/Automate/EditActionsList/UpdateReceiverSmsScript.js +1 -1
- package/src/screens/Automate/EditActionsList/index.js +4 -3
- package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +19 -2
- package/src/screens/Automate/ScriptDetail/Components/ModalAddCondition.js +12 -3
- package/src/screens/Automate/ScriptDetail/__test__/index.test.js +1 -1
- package/src/screens/Automate/ScriptDetail/index.js +77 -22
- package/src/screens/Automate/SetSchedule/AddEditConditionSchedule.js +3 -3
- package/src/screens/Automate/SetSchedule/__test__/AddEditConditionSchedule.test.js +8 -5
- package/src/screens/Automate/index.js +0 -1
- package/src/screens/HanetCamera/CaptureFaceID.js +3 -11
- package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +0 -1
- package/src/screens/HanetCamera/styles/captureFaceIDStyles.js +6 -1
- package/src/screens/Notification/components/NotificationItem.js +4 -1
- package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +0 -1
- package/src/screens/ScanChipQR/components/QRScan/index.js +2 -15
- package/src/screens/Unit/__test__/Detail.test.js +0 -1
- package/src/utils/Route/index.js +2 -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.7.
|
|
4
|
+
"version": "0.7.39",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -221,5 +221,8 @@
|
|
|
221
221
|
"*.{js, ts}": [
|
|
222
222
|
"yarn lint"
|
|
223
223
|
]
|
|
224
|
+
},
|
|
225
|
+
"devDependencies": {
|
|
226
|
+
"@react-native/babel-preset": "0.76.5"
|
|
224
227
|
}
|
|
225
228
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { memo, useCallback, useMemo, useRef } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import { IconOutline } from '@ant-design/icons-react-native';
|
|
4
4
|
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
|
5
5
|
import { useNavigation, useRoute } from '@react-navigation/native';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { View, StyleSheet, RefreshControl } from 'react-native';
|
|
3
3
|
import LinearGradient from 'react-native-linear-gradient';
|
|
4
4
|
|
|
5
5
|
import { Colors, Device, Images, SCConfig } from '../../configs';
|
|
@@ -17,6 +17,7 @@ const ChooseAction = ({ route }) => {
|
|
|
17
17
|
unitId,
|
|
18
18
|
device,
|
|
19
19
|
automateId,
|
|
20
|
+
closeScreen,
|
|
20
21
|
scriptItems,
|
|
21
22
|
numberActionCanAdd,
|
|
22
23
|
multiUnit = {},
|
|
@@ -43,11 +44,16 @@ const ChooseAction = ({ route }) => {
|
|
|
43
44
|
navigate({
|
|
44
45
|
name: Routes.ScriptDetail,
|
|
45
46
|
merge: true,
|
|
46
|
-
params: {
|
|
47
|
+
params: {
|
|
48
|
+
saveAt: moment().valueOf(),
|
|
49
|
+
automate: { id: automateId },
|
|
50
|
+
closeScreen,
|
|
51
|
+
},
|
|
47
52
|
});
|
|
48
53
|
}, [
|
|
49
54
|
numberActionCanAdd,
|
|
50
55
|
automateId,
|
|
56
|
+
closeScreen,
|
|
51
57
|
saveActions.length,
|
|
52
58
|
unitId,
|
|
53
59
|
multiUnit.id,
|
|
@@ -22,11 +22,13 @@ const NewActionWrapper = ({
|
|
|
22
22
|
canNext !== undefined || onNext !== undefined || nextTitle !== undefined;
|
|
23
23
|
const { navigate } = useNavigation();
|
|
24
24
|
const { params = {} } = useRoute();
|
|
25
|
+
const { automateId } = params;
|
|
26
|
+
|
|
25
27
|
const { closeScreen } = params;
|
|
26
28
|
|
|
27
29
|
const handleClose = useCallback(() => {
|
|
28
|
-
navigate(closeScreen, params);
|
|
29
|
-
}, [closeScreen, navigate, params]);
|
|
30
|
+
navigate(closeScreen, { ...params, automate: { id: automateId } });
|
|
31
|
+
}, [closeScreen, navigate, params, automateId]);
|
|
30
32
|
|
|
31
33
|
const rightComponent = useMemo(
|
|
32
34
|
() => (
|
|
@@ -17,7 +17,7 @@ import moment from 'moment';
|
|
|
17
17
|
const SetupScriptDelay = ({ route }) => {
|
|
18
18
|
const t = useTranslations();
|
|
19
19
|
const { goBack, navigate } = useNavigation();
|
|
20
|
-
const { automate = {} } = route?.params || {};
|
|
20
|
+
const { automate = {}, closeScreen } = route?.params || {};
|
|
21
21
|
const { id: automateId } = automate;
|
|
22
22
|
const [delay, setDelay] = useState();
|
|
23
23
|
|
|
@@ -37,12 +37,12 @@ const SetupScriptDelay = ({ route }) => {
|
|
|
37
37
|
navigate({
|
|
38
38
|
name: Routes.ScriptDetail,
|
|
39
39
|
merge: true,
|
|
40
|
-
params: { saveAt: moment().valueOf() },
|
|
40
|
+
params: { saveAt: moment().valueOf(), automate, closeScreen },
|
|
41
41
|
});
|
|
42
42
|
} else {
|
|
43
43
|
ToastBottomHelper.error(t('error_please_try_later'));
|
|
44
44
|
}
|
|
45
|
-
}, [automateId, navigate, delay, t]);
|
|
45
|
+
}, [automateId, navigate, delay, t, automate, closeScreen]);
|
|
46
46
|
|
|
47
47
|
const canSave = useMemo(() => {
|
|
48
48
|
const value = parseInt(delay, 10);
|
|
@@ -13,7 +13,7 @@ import Routes from '../../../utils/Route';
|
|
|
13
13
|
const SetupScriptEmail = ({ route }) => {
|
|
14
14
|
const t = useTranslations();
|
|
15
15
|
const { goBack, navigate } = useNavigation();
|
|
16
|
-
const { automate, unitId, multiUnit } = route.params || {};
|
|
16
|
+
const { automate, closeScreen, unitId, multiUnit } = route.params || {};
|
|
17
17
|
const initialUnitId = useMemo(
|
|
18
18
|
() => unitId || multiUnit.id,
|
|
19
19
|
[unitId, multiUnit?.id]
|
|
@@ -36,10 +36,11 @@ const SetupScriptEmail = ({ route }) => {
|
|
|
36
36
|
const onNext = useCallback(async () => {
|
|
37
37
|
navigate(Routes.SetupScriptReceiverEmail, {
|
|
38
38
|
automate,
|
|
39
|
+
closeScreen,
|
|
39
40
|
unitId: initialUnitId,
|
|
40
41
|
formData,
|
|
41
42
|
});
|
|
42
|
-
}, [navigate, automate, initialUnitId, formData]);
|
|
43
|
+
}, [navigate, automate, closeScreen, initialUnitId, formData]);
|
|
43
44
|
|
|
44
45
|
const canSave = useMemo(() => {
|
|
45
46
|
const { title, message } = formData;
|
|
@@ -13,7 +13,7 @@ import Routes from '../../../utils/Route';
|
|
|
13
13
|
const SetupScriptNotify = ({ route }) => {
|
|
14
14
|
const t = useTranslations();
|
|
15
15
|
const { goBack, navigate } = useNavigation();
|
|
16
|
-
const { automate, unitId, multiUnit } = route.params || {};
|
|
16
|
+
const { automate, closeScreen, unitId, multiUnit } = route.params || {};
|
|
17
17
|
const initialUnitId = useMemo(
|
|
18
18
|
() => unitId || multiUnit.id,
|
|
19
19
|
[unitId, multiUnit?.id]
|
|
@@ -36,10 +36,11 @@ const SetupScriptNotify = ({ route }) => {
|
|
|
36
36
|
const onNext = useCallback(async () => {
|
|
37
37
|
navigate(Routes.SetupScriptReceiverNotify, {
|
|
38
38
|
automate,
|
|
39
|
+
closeScreen,
|
|
39
40
|
unitId: initialUnitId,
|
|
40
41
|
formData,
|
|
41
42
|
});
|
|
42
|
-
}, [navigate, automate, initialUnitId, formData]);
|
|
43
|
+
}, [navigate, automate, closeScreen, initialUnitId, formData]);
|
|
43
44
|
|
|
44
45
|
const canSave = useMemo(() => {
|
|
45
46
|
const { title, message } = formData;
|
|
@@ -12,7 +12,7 @@ import moment from 'moment';
|
|
|
12
12
|
const SetupScriptReceiverEmail = ({ route }) => {
|
|
13
13
|
const t = useTranslations();
|
|
14
14
|
const { navigate } = useNavigation();
|
|
15
|
-
const { automate = {}, unitId, formData } = route.params;
|
|
15
|
+
const { automate = {}, closeScreen, unitId, formData } = route.params;
|
|
16
16
|
const { id: automateId } = automate;
|
|
17
17
|
const [listUser, setListUser] = useState([]);
|
|
18
18
|
|
|
@@ -27,12 +27,12 @@ const SetupScriptReceiverEmail = ({ route }) => {
|
|
|
27
27
|
navigate({
|
|
28
28
|
name: Routes.ScriptDetail,
|
|
29
29
|
merge: true,
|
|
30
|
-
params: { saveAt: moment().valueOf() },
|
|
30
|
+
params: { saveAt: moment().valueOf(), automate, closeScreen },
|
|
31
31
|
});
|
|
32
32
|
} else {
|
|
33
33
|
ToastBottomHelper.error(t('error_please_try_later'));
|
|
34
34
|
}
|
|
35
|
-
}, [automateId, formData, listUser, navigate, t]);
|
|
35
|
+
}, [automate, automateId, closeScreen, formData, listUser, navigate, t]);
|
|
36
36
|
|
|
37
37
|
const onLoadOption = useCallback(
|
|
38
38
|
(item) => {
|
|
@@ -12,7 +12,7 @@ import moment from 'moment';
|
|
|
12
12
|
const SetupScriptReceiverNotify = ({ route }) => {
|
|
13
13
|
const t = useTranslations();
|
|
14
14
|
const { navigate } = useNavigation();
|
|
15
|
-
const { automate = {}, unitId, formData } = route.params;
|
|
15
|
+
const { automate = {}, closeScreen, unitId, formData } = route.params;
|
|
16
16
|
const { id: automateId } = automate;
|
|
17
17
|
const [listUser, setListUser] = useState([]);
|
|
18
18
|
|
|
@@ -27,12 +27,12 @@ const SetupScriptReceiverNotify = ({ route }) => {
|
|
|
27
27
|
navigate({
|
|
28
28
|
name: Routes.ScriptDetail,
|
|
29
29
|
merge: true,
|
|
30
|
-
params: { saveAt: moment().valueOf() },
|
|
30
|
+
params: { saveAt: moment().valueOf(), automate, closeScreen },
|
|
31
31
|
});
|
|
32
32
|
} else {
|
|
33
33
|
ToastBottomHelper.error(t('error_please_try_later'));
|
|
34
34
|
}
|
|
35
|
-
}, [automateId, formData, listUser, navigate, t]);
|
|
35
|
+
}, [automate, automateId, closeScreen, formData, listUser, navigate, t]);
|
|
36
36
|
|
|
37
37
|
const onLoadOption = useCallback(
|
|
38
38
|
(item) => {
|
|
@@ -12,7 +12,7 @@ import moment from 'moment';
|
|
|
12
12
|
const SetupScriptReceiverSms = ({ route }) => {
|
|
13
13
|
const t = useTranslations();
|
|
14
14
|
const { navigate } = useNavigation();
|
|
15
|
-
const { automate = {}, unitId, formData } = route.params;
|
|
15
|
+
const { automate = {}, closeScreen, unitId, formData } = route.params;
|
|
16
16
|
const { id: automateId } = automate;
|
|
17
17
|
const [listUser, setListUser] = useState([]);
|
|
18
18
|
|
|
@@ -27,12 +27,12 @@ const SetupScriptReceiverSms = ({ route }) => {
|
|
|
27
27
|
navigate({
|
|
28
28
|
name: Routes.ScriptDetail,
|
|
29
29
|
merge: true,
|
|
30
|
-
params: { saveAt: moment().valueOf() },
|
|
30
|
+
params: { saveAt: moment().valueOf(), automate, closeScreen },
|
|
31
31
|
});
|
|
32
32
|
} else {
|
|
33
33
|
ToastBottomHelper.error(t('error_please_try_later'));
|
|
34
34
|
}
|
|
35
|
-
}, [automateId, formData, listUser, navigate, t]);
|
|
35
|
+
}, [automate, automateId, closeScreen, formData, listUser, navigate, t]);
|
|
36
36
|
|
|
37
37
|
const onLoadOption = useCallback(
|
|
38
38
|
(item) => {
|
|
@@ -14,7 +14,7 @@ import { Colors } from '../../../configs';
|
|
|
14
14
|
const SetupScriptSms = ({ route }) => {
|
|
15
15
|
const t = useTranslations();
|
|
16
16
|
const { goBack, navigate } = useNavigation();
|
|
17
|
-
const { automate, unitId, multiUnit } = route.params || {};
|
|
17
|
+
const { automate, closeScreen, unitId, multiUnit } = route.params || {};
|
|
18
18
|
const initialUnitId = useMemo(
|
|
19
19
|
() => unitId || multiUnit.id,
|
|
20
20
|
[unitId, multiUnit?.id]
|
|
@@ -31,10 +31,11 @@ const SetupScriptSms = ({ route }) => {
|
|
|
31
31
|
const onNext = useCallback(async () => {
|
|
32
32
|
navigate(Routes.SetupScriptReceiverSms, {
|
|
33
33
|
automate,
|
|
34
|
+
closeScreen,
|
|
34
35
|
unitId: initialUnitId,
|
|
35
36
|
formData,
|
|
36
37
|
});
|
|
37
|
-
}, [navigate, automate, initialUnitId, formData]);
|
|
38
|
+
}, [navigate, automate, closeScreen, initialUnitId, formData]);
|
|
38
39
|
|
|
39
40
|
const canSave = useMemo(() => {
|
|
40
41
|
const { message } = formData;
|
|
@@ -63,6 +63,7 @@ describe('Test SetupScriptNotify', () => {
|
|
|
63
63
|
{
|
|
64
64
|
automate: route.params.automate,
|
|
65
65
|
unitId: 1,
|
|
66
|
+
closeScreen: 'ScriptDetail',
|
|
66
67
|
formData: { message: 'Message', title: 'Title', unit: 1 },
|
|
67
68
|
}
|
|
68
69
|
);
|
|
@@ -97,6 +98,7 @@ describe('Test SetupScriptNotify', () => {
|
|
|
97
98
|
{
|
|
98
99
|
automate: route.params.automate,
|
|
99
100
|
unitId: 1,
|
|
101
|
+
closeScreen: 'ScriptDetail',
|
|
100
102
|
formData: { message: 'Message', title: 'Title', unit: 1 },
|
|
101
103
|
}
|
|
102
104
|
);
|
|
@@ -58,15 +58,16 @@ const EditActionsList = () => {
|
|
|
58
58
|
[id, t]
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
-
const
|
|
61
|
+
const onGoBack = useCallback(() => {
|
|
62
62
|
navigate({
|
|
63
63
|
name: Routes.ScriptDetail,
|
|
64
64
|
merge: true,
|
|
65
65
|
params: {
|
|
66
66
|
newActionsList: actionsList,
|
|
67
|
+
automate: { id: id },
|
|
67
68
|
},
|
|
68
69
|
});
|
|
69
|
-
}, [actionsList, navigate]);
|
|
70
|
+
}, [actionsList, navigate, id]);
|
|
70
71
|
|
|
71
72
|
const onPressRemove = (item) => {
|
|
72
73
|
setIsVisible(true);
|
|
@@ -478,7 +479,7 @@ const EditActionsList = () => {
|
|
|
478
479
|
|
|
479
480
|
return (
|
|
480
481
|
<GestureHandlerRootView style={styles.wrap}>
|
|
481
|
-
<HeaderCustom title={t('edit_actions_list')} onGoBack={
|
|
482
|
+
<HeaderCustom title={t('edit_actions_list')} onGoBack={onGoBack} />
|
|
482
483
|
<View style={styles.wrapContent}>
|
|
483
484
|
<Text type="Body" color={Colors.Gray8}>
|
|
484
485
|
{t('des_edit_actions_list')}
|
|
@@ -20,7 +20,15 @@ import AccessibilityLabel from '../../../../configs/AccessibilityLabel';
|
|
|
20
20
|
import { AUTOMATE_TYPE } from '../../../../configs/Constants';
|
|
21
21
|
|
|
22
22
|
const AddActionScript = memo(
|
|
23
|
-
({
|
|
23
|
+
({
|
|
24
|
+
automate,
|
|
25
|
+
closeScreen,
|
|
26
|
+
isVisible,
|
|
27
|
+
setIsVisible,
|
|
28
|
+
scriptItems,
|
|
29
|
+
type,
|
|
30
|
+
navigate,
|
|
31
|
+
}) => {
|
|
24
32
|
const t = useTranslations();
|
|
25
33
|
const { id, unit } = automate;
|
|
26
34
|
|
|
@@ -29,6 +37,7 @@ const AddActionScript = memo(
|
|
|
29
37
|
const { max_actions_per_automation } = permissions || {};
|
|
30
38
|
|
|
31
39
|
const listItem = useMemo(() => {
|
|
40
|
+
const finalCloseScreen = closeScreen || currentScreenName;
|
|
32
41
|
return [
|
|
33
42
|
{
|
|
34
43
|
id: 'control_device',
|
|
@@ -40,7 +49,7 @@ const AddActionScript = memo(
|
|
|
40
49
|
unitId: unit,
|
|
41
50
|
automateId: id,
|
|
42
51
|
scriptItems: scriptItems,
|
|
43
|
-
closeScreen:
|
|
52
|
+
closeScreen: finalCloseScreen,
|
|
44
53
|
numberActionCanAdd:
|
|
45
54
|
max_actions_per_automation - scriptItems.length,
|
|
46
55
|
routeName: unit ? null : Routes.SelectControlDevices,
|
|
@@ -62,11 +71,13 @@ const AddActionScript = memo(
|
|
|
62
71
|
navigate(Routes.SetupScriptNotify, {
|
|
63
72
|
automate,
|
|
64
73
|
unitId: unit,
|
|
74
|
+
closeScreen: finalCloseScreen,
|
|
65
75
|
});
|
|
66
76
|
} else {
|
|
67
77
|
navigate(Routes.SelectUnit, {
|
|
68
78
|
automate,
|
|
69
79
|
routeName: Routes.SetupScriptNotify,
|
|
80
|
+
closeScreen: finalCloseScreen,
|
|
70
81
|
});
|
|
71
82
|
}
|
|
72
83
|
},
|
|
@@ -79,6 +90,7 @@ const AddActionScript = memo(
|
|
|
79
90
|
setIsVisible(false);
|
|
80
91
|
navigate(Routes.SetupScriptDelay, {
|
|
81
92
|
automate,
|
|
93
|
+
closeScreen: finalCloseScreen,
|
|
82
94
|
});
|
|
83
95
|
},
|
|
84
96
|
},
|
|
@@ -92,11 +104,13 @@ const AddActionScript = memo(
|
|
|
92
104
|
navigate(Routes.SetupScriptEmail, {
|
|
93
105
|
automate,
|
|
94
106
|
unitId: unit,
|
|
107
|
+
closeScreen: finalCloseScreen,
|
|
95
108
|
});
|
|
96
109
|
} else {
|
|
97
110
|
navigate(Routes.SelectUnit, {
|
|
98
111
|
automate,
|
|
99
112
|
routeName: Routes.SetupScriptEmail,
|
|
113
|
+
closeScreen: finalCloseScreen,
|
|
100
114
|
});
|
|
101
115
|
}
|
|
102
116
|
},
|
|
@@ -112,11 +126,13 @@ const AddActionScript = memo(
|
|
|
112
126
|
navigate(Routes.SetupScriptSms, {
|
|
113
127
|
automate,
|
|
114
128
|
unitId: unit,
|
|
129
|
+
closeScreen: finalCloseScreen,
|
|
115
130
|
});
|
|
116
131
|
} else {
|
|
117
132
|
navigate(Routes.SelectUnit, {
|
|
118
133
|
automate,
|
|
119
134
|
routeName: Routes.SetupScriptSms,
|
|
135
|
+
closeScreen: finalCloseScreen,
|
|
120
136
|
});
|
|
121
137
|
}
|
|
122
138
|
},
|
|
@@ -124,6 +140,7 @@ const AddActionScript = memo(
|
|
|
124
140
|
];
|
|
125
141
|
}, [
|
|
126
142
|
automate,
|
|
143
|
+
closeScreen,
|
|
127
144
|
currentScreenName,
|
|
128
145
|
id,
|
|
129
146
|
max_actions_per_automation,
|
|
@@ -17,7 +17,14 @@ import { SCContext } from '../../../../context';
|
|
|
17
17
|
import { Action } from '../../../../context/actionType';
|
|
18
18
|
|
|
19
19
|
const ModalAddCondition = memo(
|
|
20
|
-
({
|
|
20
|
+
({
|
|
21
|
+
automate,
|
|
22
|
+
closeScreen,
|
|
23
|
+
isVisible,
|
|
24
|
+
setIsVisible,
|
|
25
|
+
numberActionAdded,
|
|
26
|
+
navigate,
|
|
27
|
+
}) => {
|
|
21
28
|
const t = useTranslations();
|
|
22
29
|
const { setAction } = useContext(SCContext);
|
|
23
30
|
const { unit } = automate;
|
|
@@ -26,6 +33,7 @@ const ModalAddCondition = memo(
|
|
|
26
33
|
const { max_actions_per_automation } = permissions || {};
|
|
27
34
|
|
|
28
35
|
const listItem = useMemo(() => {
|
|
36
|
+
const finalCloseScreen = closeScreen || currentScreenName;
|
|
29
37
|
return [
|
|
30
38
|
{
|
|
31
39
|
id: 'time_frame',
|
|
@@ -36,7 +44,7 @@ const ModalAddCondition = memo(
|
|
|
36
44
|
setIsVisible(false);
|
|
37
45
|
navigate(Routes.AddEditConditionSchedule, {
|
|
38
46
|
automate: automate,
|
|
39
|
-
closeScreen:
|
|
47
|
+
closeScreen: finalCloseScreen,
|
|
40
48
|
});
|
|
41
49
|
},
|
|
42
50
|
},
|
|
@@ -49,7 +57,7 @@ const ModalAddCondition = memo(
|
|
|
49
57
|
setIsVisible(false);
|
|
50
58
|
const navParams = {
|
|
51
59
|
automate: automate,
|
|
52
|
-
closeScreen:
|
|
60
|
+
closeScreen: finalCloseScreen,
|
|
53
61
|
numberActionCanAdd:
|
|
54
62
|
max_actions_per_automation - numberActionAdded,
|
|
55
63
|
routeName: unit ? null : Routes.SelectControlDevices,
|
|
@@ -70,6 +78,7 @@ const ModalAddCondition = memo(
|
|
|
70
78
|
];
|
|
71
79
|
}, [
|
|
72
80
|
automate,
|
|
81
|
+
closeScreen,
|
|
73
82
|
currentScreenName,
|
|
74
83
|
max_actions_per_automation,
|
|
75
84
|
navigate,
|
|
@@ -902,9 +902,9 @@ describe('Test ScriptDetail', () => {
|
|
|
902
902
|
params: {
|
|
903
903
|
unitId: route.params.preAutomate.unit,
|
|
904
904
|
automateId: route.params.preAutomate.id,
|
|
905
|
+
closeScreen: 'UnitDetail',
|
|
905
906
|
numberActionCanAdd: 2,
|
|
906
907
|
scriptItems: [],
|
|
907
|
-
closeScreen: undefined,
|
|
908
908
|
routeName: null,
|
|
909
909
|
},
|
|
910
910
|
},
|
|
@@ -59,7 +59,8 @@ import { Action } from '../../../context/actionType';
|
|
|
59
59
|
const PreventDoubleTouch = withPreventDoubleClick(TouchableOpacity);
|
|
60
60
|
|
|
61
61
|
const ScriptDetail = ({ route }) => {
|
|
62
|
-
const { dispatch, navigate, goBack, getState } =
|
|
62
|
+
const { dispatch, navigate, goBack, getState, popToTop, reset } =
|
|
63
|
+
useNavigation();
|
|
63
64
|
const { params = {} } = route;
|
|
64
65
|
const refMenuAction = useRef();
|
|
65
66
|
const { setAction } = useContext(SCContext);
|
|
@@ -143,20 +144,16 @@ const ScriptDetail = ({ route }) => {
|
|
|
143
144
|
const index = state.routes.findIndex((r) => r.name === closeScreen);
|
|
144
145
|
let routes = [];
|
|
145
146
|
if (!closeScreen) {
|
|
146
|
-
routes = state.routes;
|
|
147
|
+
routes = [...state.routes];
|
|
147
148
|
} else if (index >= 0) {
|
|
148
149
|
routes = state.routes.slice(0, index + 1);
|
|
149
150
|
}
|
|
150
|
-
|
|
151
|
-
(r) => r.name === Routes.ScriptDetail
|
|
152
|
-
);
|
|
151
|
+
routes = routes.filter((r) => r.name !== Routes.ScriptDetail);
|
|
153
152
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
});
|
|
159
|
-
}
|
|
153
|
+
routes.push({
|
|
154
|
+
name: Routes.ScriptDetail,
|
|
155
|
+
params: route.params,
|
|
156
|
+
});
|
|
160
157
|
|
|
161
158
|
routes.push({
|
|
162
159
|
name: screen,
|
|
@@ -317,21 +314,77 @@ const ScriptDetail = ({ route }) => {
|
|
|
317
314
|
}
|
|
318
315
|
}, [automateId, t]);
|
|
319
316
|
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
317
|
+
const customNavigate = useCallback(
|
|
318
|
+
(screen, screenParams = {}) => {
|
|
319
|
+
const state = getState();
|
|
320
|
+
const index = state.routes.findIndex((r) => r.name === screen);
|
|
321
|
+
|
|
322
|
+
if (index > 0) {
|
|
323
|
+
const existingRoute = state.routes[index];
|
|
324
|
+
|
|
325
|
+
reset({
|
|
326
|
+
routes: [
|
|
327
|
+
...state.routes.slice(0, index),
|
|
328
|
+
{
|
|
329
|
+
name: screen,
|
|
330
|
+
params: {
|
|
331
|
+
...existingRoute.params,
|
|
332
|
+
...screenParams,
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
],
|
|
336
|
+
index,
|
|
337
|
+
});
|
|
338
|
+
} else if (index === 0) {
|
|
339
|
+
popToTop();
|
|
340
|
+
} else {
|
|
341
|
+
navigate(screen, screenParams);
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
[navigate, getState, popToTop, reset]
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
const customGoOtherStack = useCallback(
|
|
348
|
+
(stack, screen) => {
|
|
349
|
+
const state = getState();
|
|
350
|
+
if (state.routes.length > 1) {
|
|
351
|
+
navigate(Routes.Main, {
|
|
352
|
+
screen: Routes.DrawerMain,
|
|
353
|
+
params: { screen: stack, params: { screen: screen } },
|
|
354
|
+
});
|
|
355
|
+
} else {
|
|
356
|
+
goBack();
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
[navigate, getState, goBack]
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
const customGoBack = useCallback(() => {
|
|
363
|
+
const state = getState();
|
|
364
|
+
const index = state.routes.findIndex((r) => r.name === Routes.ScriptDetail);
|
|
365
|
+
if (index > 0) {
|
|
366
|
+
reset({
|
|
367
|
+
routes: state.routes.slice(0, index),
|
|
368
|
+
index: index - 1,
|
|
330
369
|
});
|
|
331
370
|
} else {
|
|
332
371
|
goBack();
|
|
333
372
|
}
|
|
334
|
-
}, [
|
|
373
|
+
}, [getState, goBack, reset]);
|
|
374
|
+
|
|
375
|
+
const handleGoBack = useCallback(async () => {
|
|
376
|
+
if (closeScreen === Routes.UnitDetail) {
|
|
377
|
+
customNavigate(Routes.UnitDetail, { unitId: unit });
|
|
378
|
+
} else if (closeScreen === Routes.MultiUnits) {
|
|
379
|
+
customNavigate(Routes.MultiUnits);
|
|
380
|
+
} else if (closeScreen === Routes.Automate) {
|
|
381
|
+
customGoOtherStack(Routes.AutomateStack, Routes.Automate);
|
|
382
|
+
} else if (closeScreen === Routes.Notification) {
|
|
383
|
+
customGoOtherStack(Routes.NotificationStack, Routes.Notification);
|
|
384
|
+
} else {
|
|
385
|
+
customGoBack();
|
|
386
|
+
}
|
|
387
|
+
}, [closeScreen, customNavigate, customGoOtherStack, customGoBack, unit]);
|
|
335
388
|
|
|
336
389
|
const onChangeSwitch = useCallback(
|
|
337
390
|
async (checked) => {
|
|
@@ -808,6 +861,7 @@ const ScriptDetail = ({ route }) => {
|
|
|
808
861
|
/>
|
|
809
862
|
<AddActionScript
|
|
810
863
|
automate={automate}
|
|
864
|
+
closeScreen={closeScreen}
|
|
811
865
|
scriptItems={data}
|
|
812
866
|
isVisible={isShowAddAction}
|
|
813
867
|
setIsVisible={setIsShowAddAction}
|
|
@@ -816,6 +870,7 @@ const ScriptDetail = ({ route }) => {
|
|
|
816
870
|
/>
|
|
817
871
|
<ModalAddCondition
|
|
818
872
|
automate={automate}
|
|
873
|
+
closeScreen={closeScreen}
|
|
819
874
|
numberActionAdded={data.length}
|
|
820
875
|
isVisible={isShowAddCondition}
|
|
821
876
|
setIsVisible={setIsShowAddCondition}
|
|
@@ -6,7 +6,7 @@ import { axiosPost, axiosPut } from '../../../utils/Apis/axios';
|
|
|
6
6
|
import { API } from '../../../configs';
|
|
7
7
|
|
|
8
8
|
const AddEditConditionSchedule = ({ route }) => {
|
|
9
|
-
const { automate, condition, isUpdateCondition } = route.params;
|
|
9
|
+
const { automate, condition, isUpdateCondition, closeScreen } = route.params;
|
|
10
10
|
const { navigate } = useNavigation();
|
|
11
11
|
|
|
12
12
|
const handleOnSave = useCallback(
|
|
@@ -27,11 +27,11 @@ const AddEditConditionSchedule = ({ route }) => {
|
|
|
27
27
|
if (success) {
|
|
28
28
|
navigate({
|
|
29
29
|
name: Routes.ScriptDetail,
|
|
30
|
-
params: { preAutomate: automate },
|
|
30
|
+
params: { preAutomate: automate, closeScreen },
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
-
[isUpdateCondition, automate, condition?.id, navigate]
|
|
34
|
+
[isUpdateCondition, automate, closeScreen, condition?.id, navigate]
|
|
35
35
|
);
|
|
36
36
|
|
|
37
37
|
return <EditSchedule condition={condition} onSave={handleOnSave} />;
|
|
@@ -182,7 +182,10 @@ describe('Test AddEditConditionSchedule', () => {
|
|
|
182
182
|
});
|
|
183
183
|
expect(global.mockedNavigate).toHaveBeenCalledWith({
|
|
184
184
|
name: 'ScriptDetail',
|
|
185
|
-
params: {
|
|
185
|
+
params: {
|
|
186
|
+
preAutomate: { id: 1, type: 'schedule', unit: 1 },
|
|
187
|
+
closeScreen: 'ScriptDetail',
|
|
188
|
+
},
|
|
186
189
|
});
|
|
187
190
|
});
|
|
188
191
|
|
|
@@ -234,7 +237,7 @@ describe('Test AddEditConditionSchedule', () => {
|
|
|
234
237
|
);
|
|
235
238
|
expect(global.mockedNavigate).toHaveBeenCalledWith({
|
|
236
239
|
name: 'ScriptDetail',
|
|
237
|
-
params: { preAutomate: { id: 1 } },
|
|
240
|
+
params: { preAutomate: { id: 1 }, closeScreen: 'ScriptDetail' },
|
|
238
241
|
});
|
|
239
242
|
});
|
|
240
243
|
|
|
@@ -332,7 +335,7 @@ describe('Test AddEditConditionSchedule', () => {
|
|
|
332
335
|
);
|
|
333
336
|
expect(global.mockedNavigate).toHaveBeenCalledWith({
|
|
334
337
|
name: 'ScriptDetail',
|
|
335
|
-
params: { preAutomate: { id: 1 } },
|
|
338
|
+
params: { preAutomate: { id: 1 }, closeScreen: 'ScriptDetail' },
|
|
336
339
|
});
|
|
337
340
|
});
|
|
338
341
|
|
|
@@ -447,7 +450,7 @@ describe('Test AddEditConditionSchedule', () => {
|
|
|
447
450
|
);
|
|
448
451
|
expect(global.mockedNavigate).toHaveBeenCalledWith({
|
|
449
452
|
name: 'ScriptDetail',
|
|
450
|
-
params: { preAutomate: { id: 1 } },
|
|
453
|
+
params: { preAutomate: { id: 1 }, closeScreen: 'ScriptDetail' },
|
|
451
454
|
});
|
|
452
455
|
});
|
|
453
456
|
|
|
@@ -510,7 +513,7 @@ describe('Test AddEditConditionSchedule', () => {
|
|
|
510
513
|
);
|
|
511
514
|
expect(global.mockedNavigate).toHaveBeenCalledWith({
|
|
512
515
|
name: 'ScriptDetail',
|
|
513
|
-
params: { preAutomate: { id: 1 } },
|
|
516
|
+
params: { preAutomate: { id: 1 }, closeScreen: 'ScriptDetail' },
|
|
514
517
|
});
|
|
515
518
|
});
|
|
516
519
|
});
|
|
@@ -25,7 +25,6 @@ import { axiosGet } from '../../utils/Apis/axios';
|
|
|
25
25
|
import { useBackendPermission } from '../../utils/Permission/backend';
|
|
26
26
|
import Routes from '../../utils/Route';
|
|
27
27
|
import { keyExtractor, ToastBottomHelper } from '../../utils/Utils';
|
|
28
|
-
import Loading from './Components/Loading';
|
|
29
28
|
import styles from './Styles/indexStyles';
|
|
30
29
|
|
|
31
30
|
const Automate = () => {
|
|
@@ -63,6 +63,7 @@ const CaptureFaceID = ({ route }) => {
|
|
|
63
63
|
setCapturing(false);
|
|
64
64
|
setIsCameraActive(false);
|
|
65
65
|
} catch (error) {
|
|
66
|
+
// eslint-disable-next-line no-console
|
|
66
67
|
console.error('Failed to take photo:', error);
|
|
67
68
|
}
|
|
68
69
|
}
|
|
@@ -143,14 +144,7 @@ const CaptureFaceID = ({ route }) => {
|
|
|
143
144
|
</View>
|
|
144
145
|
)}
|
|
145
146
|
{!isCameraActive && imageUri && (
|
|
146
|
-
<Image
|
|
147
|
-
source={{ uri: imageUri }}
|
|
148
|
-
style={{
|
|
149
|
-
position: 'absolute',
|
|
150
|
-
height: Constants.height,
|
|
151
|
-
width: Constants.width,
|
|
152
|
-
}}
|
|
153
|
-
/>
|
|
147
|
+
<Image source={{ uri: imageUri }} style={styles.imageStyle} />
|
|
154
148
|
)}
|
|
155
149
|
</>
|
|
156
150
|
);
|
|
@@ -160,9 +154,7 @@ const CaptureFaceID = ({ route }) => {
|
|
|
160
154
|
<View style={styles.container}>
|
|
161
155
|
<HeaderCustom title={title} isShowSeparator />
|
|
162
156
|
{openCamera && (
|
|
163
|
-
<View style={styles.wrapCamera}>
|
|
164
|
-
{renderCameraContent()}
|
|
165
|
-
</View>
|
|
157
|
+
<View style={styles.wrapCamera}>{renderCameraContent()}</View>
|
|
166
158
|
)}
|
|
167
159
|
{!openCamera && (
|
|
168
160
|
<View style={styles.center}>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { Colors } from '../../../configs';
|
|
2
|
+
import { Colors, Constants } from '../../../configs';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
container: {
|
|
@@ -47,4 +47,9 @@ export default StyleSheet.create({
|
|
|
47
47
|
backgroundColor: Colors.White,
|
|
48
48
|
marginTop: 8,
|
|
49
49
|
},
|
|
50
|
+
imageStyle: {
|
|
51
|
+
position: 'absolute',
|
|
52
|
+
height: Constants.height,
|
|
53
|
+
width: Constants.width,
|
|
54
|
+
},
|
|
50
55
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useNavigation } from '@react-navigation/native';
|
|
1
|
+
import { useNavigation, useRoute } from '@react-navigation/native';
|
|
2
2
|
import moment from 'moment';
|
|
3
3
|
import React, { memo, useCallback, useState } from 'react';
|
|
4
4
|
import { Image, TouchableOpacity, View } from 'react-native';
|
|
@@ -21,6 +21,7 @@ import styles from '../styles/NotificationItemStyles';
|
|
|
21
21
|
const NotificationItem = memo(({ item }) => {
|
|
22
22
|
const t = useTranslations();
|
|
23
23
|
const navigation = useNavigation();
|
|
24
|
+
const { name: currentScreen } = useRoute();
|
|
24
25
|
const language = useSCContextSelector((state) => state.language);
|
|
25
26
|
const { id, icon, created_at, is_read, params, content_code } = item;
|
|
26
27
|
const [isRead, setIsRead] = useState(is_read);
|
|
@@ -438,6 +439,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
438
439
|
navigation.navigate(Routes.UnitStack, {
|
|
439
440
|
screen: Routes.ScriptDetail,
|
|
440
441
|
params: {
|
|
442
|
+
closeScreen: currentScreen,
|
|
441
443
|
preAutomate: { id: automate_id },
|
|
442
444
|
},
|
|
443
445
|
});
|
|
@@ -450,6 +452,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
450
452
|
}, [
|
|
451
453
|
params,
|
|
452
454
|
content_code,
|
|
455
|
+
currentScreen,
|
|
453
456
|
customColorText,
|
|
454
457
|
t,
|
|
455
458
|
logo,
|
|
@@ -102,11 +102,7 @@ const QRScan = ({ isScanReady = true, onScan }) => {
|
|
|
102
102
|
/>
|
|
103
103
|
<View style={styles.maskOuter}>
|
|
104
104
|
<View
|
|
105
|
-
style={[
|
|
106
|
-
{ flex: maskRowHeight },
|
|
107
|
-
styles.maskRow,
|
|
108
|
-
styles.maskFrame,
|
|
109
|
-
]}
|
|
105
|
+
style={[{ flex: maskRowHeight }, styles.maskRow, styles.maskFrame]}
|
|
110
106
|
/>
|
|
111
107
|
<View style={styles.maskCenter}>
|
|
112
108
|
<View style={[{ width: maskColWidth }, styles.maskFrame]} />
|
|
@@ -119,11 +115,7 @@ const QRScan = ({ isScanReady = true, onScan }) => {
|
|
|
119
115
|
</Text>
|
|
120
116
|
</View>
|
|
121
117
|
<View
|
|
122
|
-
style={[
|
|
123
|
-
{ flex: maskRowHeight },
|
|
124
|
-
styles.maskRow,
|
|
125
|
-
styles.maskFrame,
|
|
126
|
-
]}
|
|
118
|
+
style={[{ flex: maskRowHeight }, styles.maskRow, styles.maskFrame]}
|
|
127
119
|
/>
|
|
128
120
|
<CircleButton
|
|
129
121
|
onPress={onPressClose}
|
|
@@ -147,11 +139,6 @@ const styles = StyleSheet.create({
|
|
|
147
139
|
container: {
|
|
148
140
|
flex: 1,
|
|
149
141
|
},
|
|
150
|
-
preview: {
|
|
151
|
-
flex: 1,
|
|
152
|
-
justifyContent: 'flex-end',
|
|
153
|
-
alignItems: 'center',
|
|
154
|
-
},
|
|
155
142
|
maskOuter: {
|
|
156
143
|
position: 'absolute',
|
|
157
144
|
top: 0,
|
|
@@ -23,7 +23,6 @@ import PreventAccess from '../../../commons/PreventAccess';
|
|
|
23
23
|
import Routes from '../../../utils/Route';
|
|
24
24
|
import { storeData } from '../../../utils/Storage';
|
|
25
25
|
|
|
26
|
-
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
|
|
27
26
|
const wrapComponent = (route, account) => (
|
|
28
27
|
<SCProvider initState={mockSCStore({})}>
|
|
29
28
|
<UnitDetail route={route} account={account} />
|
package/src/utils/Route/index.js
CHANGED
|
@@ -153,10 +153,12 @@ const Routes = {
|
|
|
153
153
|
SelectUnit: 'SelectUnit',
|
|
154
154
|
AddNewScriptAction: 'AddNewScriptAction',
|
|
155
155
|
Automate: 'Automate',
|
|
156
|
+
AutomateStack: 'AutomateStack',
|
|
156
157
|
MultiUnits: 'MultiUnits',
|
|
157
158
|
EditDevice: 'EditDevice',
|
|
158
159
|
SetSchedule: 'SetSchedule',
|
|
159
160
|
Notification: 'Notification',
|
|
161
|
+
NotificationStack: 'NotificationStack',
|
|
160
162
|
AddEditConditionSchedule: 'AddEditConditionSchedule',
|
|
161
163
|
PersonalHealthStack: 'PersonalHealthStack',
|
|
162
164
|
ListSmartAccount: 'ListSmartAccount',
|