@eohjsc/react-native-smart-city 0.2.26 → 0.2.27
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/assets/images/Illustrations.svg +83 -0
- package/assets/images/{WeatherChange.svg → ValueChange.svg} +0 -0
- package/index.js +2 -0
- package/package.json +3 -1
- package/src/Images/Common/file.png +0 -0
- package/src/Images/Common/fullscreen.png +0 -0
- package/src/commons/ActionGroup/OnOffTemplate/index.js +5 -0
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +294 -0
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplateWithNullConfigValue.test.js +60 -0
- package/src/commons/AlertAction/__test__/AlertAction.test.js +6 -6
- package/src/commons/AlertAction/index.js +2 -0
- package/src/commons/Automate/ItemAutomate.js +7 -1
- package/src/commons/Automate/__test__/ItemAutomate.test.js +16 -0
- package/src/commons/Automate/__test__/ItemScriptAction.test.js +16 -0
- package/src/commons/BackDefault/__test__/BackDefault.test.js +21 -0
- package/src/commons/BottomScrollPicker/index.js +5 -1
- package/src/commons/BottomSheet/index.js +10 -5
- package/src/commons/ButtonPopup/__test__/__snapshots__/ButtonPopup.test.js.snap +2 -0
- package/src/commons/ButtonPopup/index.js +2 -0
- package/src/commons/Calendar/index.js +72 -0
- package/src/commons/Calendar/styles.js +11 -0
- package/src/commons/Device/ItemAddNew/index.js +2 -2
- package/src/commons/Explore/__test__/HeaderExplore.test.js +25 -0
- package/src/commons/Explore/__test__/LocationItem.test.js +31 -0
- package/src/commons/Header/HeaderCustom.js +7 -3
- package/src/commons/HeaderAni/index.js +31 -3
- package/src/commons/HorizontalPicker/index.js +134 -0
- package/src/commons/HorizontalPicker/styles.js +56 -0
- package/src/commons/Modal/__test__/ModalBottom.test.js +39 -0
- package/src/commons/RowItem/__test__/RowItem.test.js +16 -0
- package/src/commons/RowItem/index.js +61 -0
- package/src/commons/RowItem/styles.js +53 -0
- package/src/commons/Sharing/WrapHeaderScrollable.js +78 -74
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +73 -69
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +47 -1
- package/src/commons/SubUnit/OneTap/index.js +2 -2
- package/src/commons/Unit/__test__/SharedUnit.test.js +330 -0
- package/src/commons/WheelDateTimePicker/index.js +16 -8
- package/src/commons/index.js +2 -0
- package/src/configs/API.js +5 -1
- package/src/configs/Constants.js +18 -3
- package/src/configs/Theme.js +20 -0
- package/src/context/SCContext.tsx +2 -2
- package/src/context/mockStore.ts +3 -1
- package/src/hooks/Common/__test__/useStatusbar.test.js +28 -0
- package/src/navigations/AutomateStack.js +45 -0
- package/src/navigations/UnitStack.js +33 -14
- package/src/navigations/utils.js +8 -0
- package/src/screens/AddNewAction/Components/LoadingSelectAction.js +40 -0
- package/src/screens/AddNewAction/Components/index.js +3 -0
- package/src/screens/AddNewAction/SelectAction.js +147 -62
- package/src/screens/AddNewAction/{SelectDevice.js → SelectSensorDevices.js} +42 -12
- package/src/screens/AddNewAction/SetupSensor.js +221 -0
- package/src/screens/AddNewAction/Styles/SelectActionStyles.js +43 -5
- package/src/screens/AddNewAction/Styles/{SelectDeviceStyles.js → SelectSensorDevicesStyles.js} +0 -0
- package/src/screens/AddNewAction/Styles/SetupSensorStyles.js +76 -0
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +0 -19
- package/src/screens/AddNewAction/__test__/{SelectDevice.test.js → SelectSensorDevices.test.js} +3 -3
- package/src/screens/AddNewAction/__test__/SetupSensor.test.js +125 -0
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +69 -12
- package/src/screens/AddNewAutoSmart/index.js +42 -14
- package/src/screens/AddNewOneTap/AddNewOneTapStyles.js +4 -3
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +1 -0
- package/src/screens/AddNewOneTap/index.js +7 -4
- package/src/screens/AllCamera/__test__/index.test.js +103 -0
- package/src/screens/Automate/Components/Loading.js +64 -0
- package/src/screens/Automate/Styles/indexStyles.js +64 -0
- package/src/screens/Automate/__test__/Loading.test.js +16 -0
- package/src/screens/Automate/__test__/index.test.js +93 -0
- package/src/screens/Automate/index.js +148 -0
- package/src/screens/Device/__test__/detail.test.js +64 -0
- package/src/screens/Device/detail.js +17 -7
- package/src/screens/EditActionsList/index.js +2 -2
- package/src/screens/GuestInfo/__test__/index.test.js +176 -0
- package/src/screens/GuestInfo/components/AccessScheduleItem.js +6 -1
- package/src/screens/GuestInfo/components/AccessScheduleSheet.js +26 -15
- package/src/screens/GuestInfo/components/HeaderGuestInfo.js +6 -1
- package/src/screens/GuestInfo/components/RecurringDetail.js +9 -2
- package/src/screens/GuestInfo/components/TemporaryDetail.js +9 -2
- package/src/screens/GuestInfo/constant.js +2 -2
- package/src/screens/GuestInfo/index.js +4 -5
- package/src/screens/PlayBackCamera/Timer.js +1 -1
- package/src/screens/ScriptDetail/Styles/indexStyles.js +14 -0
- package/src/screens/ScriptDetail/__test__/index.test.js +119 -0
- package/src/screens/ScriptDetail/hooks/index.js +55 -0
- package/src/screens/ScriptDetail/index.js +124 -23
- package/src/screens/SelectUnit/Styles/indexStyles.js +55 -0
- package/src/screens/SelectUnit/__test__/index.test.js +85 -0
- package/src/screens/SelectUnit/index.js +100 -0
- package/src/screens/SetSchedule/__test__/index.test.js +97 -0
- package/src/screens/SetSchedule/components/RepeatOptionsPopup.js +56 -0
- package/src/screens/SetSchedule/components/RowItem.js +27 -0
- package/src/screens/SetSchedule/components/SelectWeekday.js +65 -0
- package/src/screens/SetSchedule/index.js +139 -0
- package/src/screens/SetSchedule/styles/RepeatOptionsPopupStyles.js +22 -0
- package/src/screens/SetSchedule/styles/RowItemStyles.js +29 -0
- package/src/screens/SetSchedule/styles/SelectWeekdayStyles.js +26 -0
- package/src/screens/{AddNewScriptAction/AddNewScriptActionStyles.js → SetSchedule/styles/indexStyles.js} +6 -12
- package/src/screens/Sharing/__test__/MemberList.test.js +21 -28
- package/src/screens/SubUnit/EditSubUnit.js +274 -0
- package/src/screens/SubUnit/EditSubUnitStyles.js +119 -0
- package/src/screens/SubUnit/ManageSubUnit.js +112 -370
- package/src/screens/SubUnit/ManageSubUnitStyles.js +40 -0
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +427 -0
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +42 -386
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +85 -0
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +35 -0
- package/src/screens/Unit/Detail.js +3 -2
- package/src/screens/Unit/ManageUnit.js +10 -0
- package/src/screens/Unit/components/SearchLocation/__test__/RowLocation.test.js +36 -0
- package/src/screens/Unit/components/__test__/MyUnit.test.js +35 -0
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +32 -0
- package/src/screens/UnitSummary/components/__test__/UnitSummary.test.js +67 -0
- package/src/screens/UnitSummary/components/__test__/index.test.js +48 -0
- package/src/screens/UnitSummary/components/index.js +1 -37
- package/src/screens/UnitSummary/components/indexstyles.js +39 -0
- package/src/utils/Apis/axios.js +0 -4
- package/src/utils/I18n/translations/en.json +30 -4
- package/src/utils/I18n/translations/vi.json +29 -3
- package/src/utils/Route/index.js +6 -1
- package/src/utils/__test__/InitData.test.js +20 -0
- package/src/commons/Automate/ItemAddNewScriptAction.js +0 -30
- package/src/screens/AddNewScriptAction/index.js +0 -100
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Colors } from '../../configs';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
wrap: {
|
|
6
|
+
flex: 1,
|
|
7
|
+
backgroundColor: Colors.White,
|
|
8
|
+
},
|
|
9
|
+
columeFlex: {
|
|
10
|
+
paddingLeft: 16,
|
|
11
|
+
flexDirection: 'column',
|
|
12
|
+
},
|
|
13
|
+
rowFlex: {
|
|
14
|
+
flexDirection: 'row',
|
|
15
|
+
},
|
|
16
|
+
endFlex: {
|
|
17
|
+
flex: 1,
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
alignItems: 'flex-end',
|
|
20
|
+
paddingRight: 16,
|
|
21
|
+
},
|
|
22
|
+
Border: {
|
|
23
|
+
display: 'flex',
|
|
24
|
+
width: '100%',
|
|
25
|
+
borderWidth: 0,
|
|
26
|
+
borderColor: Colors.Gray4,
|
|
27
|
+
borderBottomWidth: 1,
|
|
28
|
+
borderStyle: 'solid',
|
|
29
|
+
flexDirection: 'row',
|
|
30
|
+
paddingTop: 16,
|
|
31
|
+
paddingBottom: 16,
|
|
32
|
+
},
|
|
33
|
+
titleName: {
|
|
34
|
+
fontSize: 16,
|
|
35
|
+
lineHeight: 24,
|
|
36
|
+
fontStyle: 'normal',
|
|
37
|
+
fontWeight: '400',
|
|
38
|
+
color: Colors.Gray9,
|
|
39
|
+
},
|
|
40
|
+
status: {
|
|
41
|
+
fontSize: 12,
|
|
42
|
+
lineHeight: 20,
|
|
43
|
+
fontStyle: 'normal',
|
|
44
|
+
fontWeight: '400',
|
|
45
|
+
color: Colors.Gray7,
|
|
46
|
+
},
|
|
47
|
+
container: {
|
|
48
|
+
paddingTop: 0,
|
|
49
|
+
},
|
|
50
|
+
paddingLeft16: {
|
|
51
|
+
paddingLeft: 16,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
@@ -14,82 +14,86 @@ import { Colors, Theme } from '../../configs';
|
|
|
14
14
|
import HeaderAni, { heightHeader } from '../../commons/HeaderAni';
|
|
15
15
|
import Text from '../../commons/Text';
|
|
16
16
|
|
|
17
|
-
const WrapHeaderScrollable =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
17
|
+
const WrapHeaderScrollable = ({
|
|
18
|
+
children,
|
|
19
|
+
title,
|
|
20
|
+
subTitle,
|
|
21
|
+
rightComponent,
|
|
22
|
+
loading = false,
|
|
23
|
+
onRefresh,
|
|
24
|
+
styleScrollView,
|
|
25
|
+
contentContainerStyle,
|
|
26
|
+
onLoadMore,
|
|
27
|
+
headerAniStyle,
|
|
28
|
+
headerAniCenterStyle,
|
|
29
|
+
onGoBack,
|
|
30
|
+
}) => {
|
|
31
|
+
const animatedScrollYValue = useRef(new Animated.Value(0)).current;
|
|
32
|
+
const [loadingMore, setLoadingMore] = useState(false);
|
|
33
|
+
const loadMore = useCallback(() => {
|
|
34
|
+
if (onLoadMore) {
|
|
35
|
+
setLoadingMore(true);
|
|
36
|
+
onLoadMore(() => setLoadingMore(false));
|
|
37
|
+
}
|
|
38
|
+
}, [onLoadMore]);
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
style={[styles.scrollView, styleScrollView]}
|
|
56
|
-
contentContainerStyle={[
|
|
57
|
-
styles.contentContainerStyle,
|
|
58
|
-
contentContainerStyle && contentContainerStyle,
|
|
59
|
-
]}
|
|
60
|
-
refreshControl={
|
|
61
|
-
<RefreshControl
|
|
62
|
-
refreshing={loading}
|
|
63
|
-
onRefresh={onRefresh}
|
|
64
|
-
progressViewOffset={heightHeader}
|
|
65
|
-
/>
|
|
40
|
+
return (
|
|
41
|
+
<SafeAreaView style={[styles.container, headerAniStyle]}>
|
|
42
|
+
<HeaderAni
|
|
43
|
+
scrollY={animatedScrollYValue}
|
|
44
|
+
title={title}
|
|
45
|
+
rightComponent={rightComponent}
|
|
46
|
+
headerAniCenterStyle={headerAniCenterStyle}
|
|
47
|
+
headerStyle={headerAniStyle}
|
|
48
|
+
onLeft={onGoBack}
|
|
49
|
+
/>
|
|
50
|
+
<Animated.ScrollView
|
|
51
|
+
scrollEventThrottle={16}
|
|
52
|
+
onScroll={Animated.event(
|
|
53
|
+
[{ nativeEvent: { contentOffset: { y: animatedScrollYValue } } }],
|
|
54
|
+
{
|
|
55
|
+
useNativeDriver: false,
|
|
66
56
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
57
|
+
)}
|
|
58
|
+
style={[styles.scrollView, styleScrollView]}
|
|
59
|
+
contentContainerStyle={[
|
|
60
|
+
styles.contentContainerStyle,
|
|
61
|
+
contentContainerStyle && contentContainerStyle,
|
|
62
|
+
]}
|
|
63
|
+
refreshControl={
|
|
64
|
+
<RefreshControl
|
|
65
|
+
refreshing={loading}
|
|
66
|
+
onRefresh={onRefresh}
|
|
67
|
+
progressViewOffset={heightHeader}
|
|
68
|
+
/>
|
|
69
|
+
}
|
|
70
|
+
contentInset={{
|
|
71
|
+
top: heightHeader - (isIphoneX() ? 32 : 0),
|
|
72
|
+
}}
|
|
73
|
+
contentOffset={{
|
|
74
|
+
y: -heightHeader,
|
|
75
|
+
}}
|
|
76
|
+
showsVerticalScrollIndicator={false}
|
|
77
|
+
onMomentumScrollEnd={loadMore}
|
|
78
|
+
>
|
|
79
|
+
{!!subTitle && (
|
|
80
|
+
<Text type={'Body'} color={Colors.Gray8} style={styles.subTitle}>
|
|
81
|
+
{subTitle}
|
|
82
|
+
</Text>
|
|
83
|
+
)}
|
|
84
|
+
{children}
|
|
85
|
+
{loadingMore && (
|
|
86
|
+
<View style={styles.bottomLoading}>
|
|
87
|
+
<ActivityIndicator size="small" color={Colors.Black} />
|
|
88
|
+
</View>
|
|
89
|
+
)}
|
|
90
|
+
</Animated.ScrollView>
|
|
91
|
+
</SafeAreaView>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default memo(WrapHeaderScrollable);
|
|
96
|
+
|
|
93
97
|
const styles = StyleSheet.create({
|
|
94
98
|
container: {
|
|
95
99
|
flex: 1,
|
|
@@ -15,83 +15,87 @@ import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
|
15
15
|
import { useNavigation } from '@react-navigation/native';
|
|
16
16
|
import Routes from '../../../utils/Route';
|
|
17
17
|
import { useGetIdUser } from '../../../hooks/Common';
|
|
18
|
-
import { TESTID } from '../../../configs/Constants';
|
|
18
|
+
import { AUTOMATE_TYPE, TESTID } from '../../../configs/Constants';
|
|
19
19
|
|
|
20
|
-
const ItemOneTap = memo(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const ItemOneTap = memo(
|
|
21
|
+
({ isOwner, automate, unit, wrapSyles, onPressItem }) => {
|
|
22
|
+
const { navigate } = useNavigation();
|
|
23
|
+
const { id, type, user, script, activate_at } = automate;
|
|
24
|
+
const t = useTranslations();
|
|
25
|
+
const idUser = useGetIdUser();
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
const goToDetail = useCallback(() => {
|
|
28
|
+
navigate(Routes.ScriptDetail, {
|
|
29
|
+
id,
|
|
30
|
+
name: script?.name,
|
|
31
|
+
type: type,
|
|
32
|
+
havePermission: isOwner || user === idUser,
|
|
33
|
+
unit,
|
|
34
|
+
});
|
|
35
|
+
}, [isOwner, user, idUser, navigate, id, script, type, unit]);
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
const handleScriptAction = useCallback(async () => {
|
|
38
|
+
const { success } = await axiosPost(API.AUTOMATE.ACTION_ONE_TAP(id));
|
|
39
|
+
if (success) {
|
|
40
|
+
ToastBottomHelper.success(t('Activated successfully.'));
|
|
41
|
+
} else {
|
|
42
|
+
ToastBottomHelper.error(t('Activation failed.'));
|
|
43
|
+
}
|
|
44
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
+
}, [id]);
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
semibold
|
|
73
|
-
size={14}
|
|
74
|
-
color={Colors.Gray9}
|
|
75
|
-
type="Body"
|
|
76
|
-
>
|
|
77
|
-
{script?.name}
|
|
78
|
-
</Text>
|
|
79
|
-
<View style={styles.descriptionContainer}>
|
|
47
|
+
const displayIcon = () => {
|
|
48
|
+
const iconKit = script?.icon_kit;
|
|
49
|
+
return iconKit ? (
|
|
50
|
+
<FImage source={{ uri: iconKit }} style={styles.iconSensor} />
|
|
51
|
+
) : (
|
|
52
|
+
<OneTap />
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
const activateAt = activate_at
|
|
56
|
+
? timeDifference(new Date(), moment(activate_at), true)
|
|
57
|
+
: null;
|
|
58
|
+
return (
|
|
59
|
+
<TouchableWithoutFeedback onPress={onPressItem || goToDetail}>
|
|
60
|
+
<View style={[styles.container, wrapSyles]}>
|
|
61
|
+
<View style={styles.boxIcon}>
|
|
62
|
+
{displayIcon()}
|
|
63
|
+
{type === AUTOMATE_TYPE.ONE_TAP && (
|
|
64
|
+
<TouchableOpacity
|
|
65
|
+
testID={TESTID.AUTOMATE_SCRIPT_ACTION}
|
|
66
|
+
onPress={handleScriptAction}
|
|
67
|
+
>
|
|
68
|
+
<CheckCircle />
|
|
69
|
+
</TouchableOpacity>
|
|
70
|
+
)}
|
|
71
|
+
</View>
|
|
72
|
+
<TouchableOpacity testID={TESTID.GO_DETAIL} onPress={goToDetail}>
|
|
80
73
|
<Text
|
|
81
74
|
numberOfLines={1}
|
|
82
75
|
semibold
|
|
83
|
-
size={
|
|
84
|
-
color={Colors.
|
|
85
|
-
type="
|
|
76
|
+
size={14}
|
|
77
|
+
color={Colors.Gray9}
|
|
78
|
+
type="Body"
|
|
86
79
|
>
|
|
87
|
-
{
|
|
80
|
+
{script?.name}
|
|
88
81
|
</Text>
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
<View style={styles.descriptionContainer}>
|
|
83
|
+
<Text
|
|
84
|
+
numberOfLines={1}
|
|
85
|
+
semibold
|
|
86
|
+
size={12}
|
|
87
|
+
color={Colors.Gray8}
|
|
88
|
+
type="Label"
|
|
89
|
+
>
|
|
90
|
+
{activateAt && t('activated_time', { time: activateAt })}
|
|
91
|
+
</Text>
|
|
92
|
+
<IconOutline name="right" size={12} />
|
|
93
|
+
</View>
|
|
94
|
+
</TouchableOpacity>
|
|
95
|
+
</View>
|
|
96
|
+
</TouchableWithoutFeedback>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
);
|
|
96
100
|
|
|
97
101
|
export default ItemOneTap;
|
|
@@ -117,7 +117,8 @@ describe('test Item', () => {
|
|
|
117
117
|
});
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
test('render SubUnitAutomate handleScriptAction fail', async () => {
|
|
120
|
+
test('render SubUnitAutomate not is owner handleScriptAction fail', async () => {
|
|
121
|
+
data.isOwner = false;
|
|
121
122
|
const response = {
|
|
122
123
|
status: 400,
|
|
123
124
|
};
|
|
@@ -146,4 +147,49 @@ describe('test Item', () => {
|
|
|
146
147
|
visibilityTime: 1000,
|
|
147
148
|
});
|
|
148
149
|
});
|
|
150
|
+
|
|
151
|
+
test('render SubUnitAutomate script value_change', async () => {
|
|
152
|
+
data.isOwner = false;
|
|
153
|
+
data.type = 'value_change';
|
|
154
|
+
data.automates = [
|
|
155
|
+
{
|
|
156
|
+
id: 1,
|
|
157
|
+
user: 6,
|
|
158
|
+
type: 'value_change',
|
|
159
|
+
activate_at: null,
|
|
160
|
+
script: {
|
|
161
|
+
name: 'Rain',
|
|
162
|
+
icon: '',
|
|
163
|
+
icon_kit: 'https://www.figma.com/',
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
const response = {
|
|
168
|
+
status: 200,
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
axios.post.mockImplementation(async () => {
|
|
172
|
+
return response;
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
await act(async () => {
|
|
176
|
+
tree = await create(wrapComponent(data));
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
const goDetail = tree.root.findAll(
|
|
180
|
+
(el) =>
|
|
181
|
+
el.props.testID === TESTID.GO_DETAIL && el.type === TouchableOpacity
|
|
182
|
+
);
|
|
183
|
+
expect(goDetail).toHaveLength(1);
|
|
184
|
+
await act(async () => {
|
|
185
|
+
await goDetail[0].props.onPress();
|
|
186
|
+
});
|
|
187
|
+
expect(mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail, {
|
|
188
|
+
havePermission: false,
|
|
189
|
+
id: 1,
|
|
190
|
+
name: 'Rain',
|
|
191
|
+
type: 'value_change',
|
|
192
|
+
unit: undefined,
|
|
193
|
+
});
|
|
194
|
+
});
|
|
149
195
|
});
|
|
@@ -10,7 +10,7 @@ import { useNavigation } from '@react-navigation/native';
|
|
|
10
10
|
import Routes from '../../../utils/Route/index.js';
|
|
11
11
|
import { AUTOMATE_TYPE } from '../../../configs/Constants';
|
|
12
12
|
|
|
13
|
-
const SubUnitAutomate = ({ isOwner, type, automates, unit }) => {
|
|
13
|
+
const SubUnitAutomate = ({ isOwner, type, automates, unit, isScript }) => {
|
|
14
14
|
const t = useTranslations();
|
|
15
15
|
const { navigate } = useNavigation();
|
|
16
16
|
const handleOnAddNew = () => {
|
|
@@ -19,7 +19,7 @@ const SubUnitAutomate = ({ isOwner, type, automates, unit }) => {
|
|
|
19
19
|
navigate(Routes.AddNewOneTap, { type: type, unit });
|
|
20
20
|
break;
|
|
21
21
|
case AUTOMATE_TYPE.VALUE_CHANGE:
|
|
22
|
-
navigate(Routes.AddNewAutoSmart, { type
|
|
22
|
+
navigate(Routes.AddNewAutoSmart, { type, unit, isScript });
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
25
|
};
|