@eohjsc/react-native-smart-city 0.7.38 → 0.7.40
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/screens/Automate/AddNewAction/ChooseAction.js +7 -1
- package/src/screens/Automate/AddNewAction/NewActionWrapper.js +1 -0
- 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/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 +78 -24
- package/src/screens/Automate/SetSchedule/AddEditConditionSchedule.js +3 -3
- package/src/screens/Automate/SetSchedule/__test__/AddEditConditionSchedule.test.js +8 -5
- 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.40",
|
|
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
|
}
|
|
@@ -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,6 +22,7 @@ const NewActionWrapper = ({
|
|
|
22
22
|
canNext !== undefined || onNext !== undefined || nextTitle !== undefined;
|
|
23
23
|
const { navigate } = useNavigation();
|
|
24
24
|
const { params = {} } = useRoute();
|
|
25
|
+
|
|
25
26
|
const { closeScreen } = params;
|
|
26
27
|
|
|
27
28
|
const handleClose = useCallback(() => {
|
|
@@ -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(), automate },
|
|
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, automate]);
|
|
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(), automate },
|
|
30
|
+
params: { saveAt: moment().valueOf(), automate, closeScreen },
|
|
31
31
|
});
|
|
32
32
|
} else {
|
|
33
33
|
ToastBottomHelper.error(t('error_please_try_later'));
|
|
34
34
|
}
|
|
35
|
-
}, [automate, 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(), automate },
|
|
30
|
+
params: { saveAt: moment().valueOf(), automate, closeScreen },
|
|
31
31
|
});
|
|
32
32
|
} else {
|
|
33
33
|
ToastBottomHelper.error(t('error_please_try_later'));
|
|
34
34
|
}
|
|
35
|
-
}, [automate, 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(), automate },
|
|
30
|
+
params: { saveAt: moment().valueOf(), automate, closeScreen },
|
|
31
31
|
});
|
|
32
32
|
} else {
|
|
33
33
|
ToastBottomHelper.error(t('error_please_try_later'));
|
|
34
34
|
}
|
|
35
|
-
}, [automate, 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
|
);
|
|
@@ -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);
|
|
@@ -96,10 +97,11 @@ const ScriptDetail = ({ route }) => {
|
|
|
96
97
|
name,
|
|
97
98
|
unit,
|
|
98
99
|
can_edit,
|
|
99
|
-
id: automateId,
|
|
100
100
|
is_need_all_conditions,
|
|
101
101
|
conditions = [{}],
|
|
102
102
|
} = automate;
|
|
103
|
+
// Create const automateId Fix error navigation from handleClose NewActionWrapper to ScriptDetail
|
|
104
|
+
const automateId = automate.id || params.automateId;
|
|
103
105
|
const [needAllCondition, setNeedAllCondition] = useState(
|
|
104
106
|
is_need_all_conditions
|
|
105
107
|
);
|
|
@@ -147,16 +149,12 @@ const ScriptDetail = ({ route }) => {
|
|
|
147
149
|
} else if (index >= 0) {
|
|
148
150
|
routes = state.routes.slice(0, index + 1);
|
|
149
151
|
}
|
|
150
|
-
|
|
151
|
-
(r) => r.name === Routes.ScriptDetail
|
|
152
|
-
);
|
|
152
|
+
routes = routes.filter((r) => r.name !== Routes.ScriptDetail);
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
});
|
|
159
|
-
}
|
|
154
|
+
routes.push({
|
|
155
|
+
name: Routes.ScriptDetail,
|
|
156
|
+
params: route.params,
|
|
157
|
+
});
|
|
160
158
|
|
|
161
159
|
routes.push({
|
|
162
160
|
name: screen,
|
|
@@ -317,23 +315,77 @@ const ScriptDetail = ({ route }) => {
|
|
|
317
315
|
}
|
|
318
316
|
}, [automateId, t]);
|
|
319
317
|
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
318
|
+
const customNavigate = useCallback(
|
|
319
|
+
(screen, screenParams = {}) => {
|
|
320
|
+
const state = getState();
|
|
321
|
+
const index = state.routes.findIndex((r) => r.name === screen);
|
|
322
|
+
|
|
323
|
+
if (index > 0) {
|
|
324
|
+
const existingRoute = state.routes[index];
|
|
325
|
+
|
|
326
|
+
reset({
|
|
327
|
+
routes: [
|
|
328
|
+
...state.routes.slice(0, index),
|
|
329
|
+
{
|
|
330
|
+
name: screen,
|
|
331
|
+
params: {
|
|
332
|
+
...existingRoute.params,
|
|
333
|
+
...screenParams,
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
],
|
|
337
|
+
index,
|
|
338
|
+
});
|
|
339
|
+
} else if (index === 0) {
|
|
340
|
+
popToTop();
|
|
341
|
+
} else {
|
|
342
|
+
navigate(screen, screenParams);
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
[navigate, getState, popToTop, reset]
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
const customGoOtherStack = useCallback(
|
|
349
|
+
(stack, screen) => {
|
|
350
|
+
const state = getState();
|
|
351
|
+
if (state.routes.length > 1) {
|
|
352
|
+
navigate(Routes.Main, {
|
|
353
|
+
screen: Routes.DrawerMain,
|
|
354
|
+
params: { screen: stack, params: { screen: screen } },
|
|
355
|
+
});
|
|
356
|
+
} else {
|
|
357
|
+
goBack();
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
[navigate, getState, goBack]
|
|
361
|
+
);
|
|
362
|
+
|
|
363
|
+
const customGoBack = useCallback(() => {
|
|
364
|
+
const state = getState();
|
|
365
|
+
const index = state.routes.findIndex((r) => r.name === Routes.ScriptDetail);
|
|
366
|
+
if (index > 0) {
|
|
367
|
+
reset({
|
|
368
|
+
routes: state.routes.slice(0, index),
|
|
369
|
+
index: index - 1,
|
|
330
370
|
});
|
|
331
|
-
} else if (closeScreen === Routes.ScriptDetail) {
|
|
332
|
-
navigate(Routes.UnitDetail, { unitId: unit });
|
|
333
371
|
} else {
|
|
334
372
|
goBack();
|
|
335
373
|
}
|
|
336
|
-
}, [
|
|
374
|
+
}, [getState, goBack, reset]);
|
|
375
|
+
|
|
376
|
+
const handleGoBack = useCallback(async () => {
|
|
377
|
+
if (closeScreen === Routes.UnitDetail) {
|
|
378
|
+
customNavigate(Routes.UnitDetail, { unitId: unit });
|
|
379
|
+
} else if (closeScreen === Routes.MultiUnits) {
|
|
380
|
+
customNavigate(Routes.MultiUnits);
|
|
381
|
+
} else if (closeScreen === Routes.Automate) {
|
|
382
|
+
customGoOtherStack(Routes.AutomateStack, Routes.Automate);
|
|
383
|
+
} else if (closeScreen === Routes.Notification) {
|
|
384
|
+
customGoOtherStack(Routes.NotificationStack, Routes.Notification);
|
|
385
|
+
} else {
|
|
386
|
+
customGoBack();
|
|
387
|
+
}
|
|
388
|
+
}, [closeScreen, customNavigate, customGoOtherStack, customGoBack, unit]);
|
|
337
389
|
|
|
338
390
|
const onChangeSwitch = useCallback(
|
|
339
391
|
async (checked) => {
|
|
@@ -810,6 +862,7 @@ const ScriptDetail = ({ route }) => {
|
|
|
810
862
|
/>
|
|
811
863
|
<AddActionScript
|
|
812
864
|
automate={automate}
|
|
865
|
+
closeScreen={closeScreen}
|
|
813
866
|
scriptItems={data}
|
|
814
867
|
isVisible={isShowAddAction}
|
|
815
868
|
setIsVisible={setIsShowAddAction}
|
|
@@ -818,6 +871,7 @@ const ScriptDetail = ({ route }) => {
|
|
|
818
871
|
/>
|
|
819
872
|
<ModalAddCondition
|
|
820
873
|
automate={automate}
|
|
874
|
+
closeScreen={closeScreen}
|
|
821
875
|
numberActionAdded={data.length}
|
|
822
876
|
isVisible={isShowAddCondition}
|
|
823
877
|
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
|
});
|
|
@@ -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',
|