@eohjsc/react-native-smart-city 0.3.28 → 0.3.29
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/commons/ActionGroup/CurtainButtonTemplate.js +1 -2
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +2 -0
- package/src/commons/ActionTemplate/CurtainAction.js +60 -0
- package/src/commons/ActionTemplate/CurtainActionStyles.js +11 -0
- package/src/commons/ActionTemplate/OnOffSmartLockAction.js +44 -0
- package/src/commons/ActionTemplate/OnOffSmartLockActionStyles.js +11 -0
- package/src/commons/ActionTemplate/index.js +18 -0
- package/src/commons/Device/ItemDevice.js +1 -0
- package/src/commons/HeaderAni/index.js +1 -0
- package/src/commons/MenuActionMore/index.js +11 -1
- package/src/commons/NavBar/index.js +12 -1
- package/src/commons/SubUnit/ShortDetail.js +1 -0
- package/src/commons/SummaryItem/index.js +2 -1
- package/src/commons/Unit/HeaderUnit/index.js +2 -0
- package/src/commons/Unit/SharedUnit.js +1 -0
- package/src/commons/WrapParallaxScrollView/index.js +16 -2
- package/src/configs/Constants.js +5 -0
- package/src/screens/AddNewAction/SelectAction.js +6 -1
- package/src/screens/Notification/__test__/NotificationItem.test.js +79 -85
- package/src/screens/Notification/components/NotificationItem.js +37 -220
- package/src/screens/ScriptDetail/__test__/index.test.js +39 -0
- package/src/screens/Unit/Detail.js +5 -0
- package/src/screens/Unit/MoreMenu.js +16 -1
- package/src/screens/Unit/Station/index.js +0 -1
- package/src/screens/Unit/Summaries.js +6 -1
- package/src/utils/I18n/translations/en.json +21 -41
- package/src/utils/I18n/translations/vi.json +21 -43
package/package.json
CHANGED
|
@@ -16,7 +16,6 @@ const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
16
16
|
action_on_data,
|
|
17
17
|
is_display_lock,
|
|
18
18
|
text1,
|
|
19
|
-
text2,
|
|
20
19
|
text3,
|
|
21
20
|
text_door_lock,
|
|
22
21
|
} = configuration || {};
|
|
@@ -56,7 +55,7 @@ const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
56
55
|
{
|
|
57
56
|
style: styles.buttonActionCurtainCenter,
|
|
58
57
|
icon: Images.buttonPauseCurtain,
|
|
59
|
-
text:
|
|
58
|
+
text: '',
|
|
60
59
|
onPress: onButtonStopPress,
|
|
61
60
|
testID: TESTID.BUTTON_TEMPLATE_2,
|
|
62
61
|
},
|
|
@@ -18,6 +18,7 @@ const OnOffButtonTemplate = memo(
|
|
|
18
18
|
style={styles.bigCircle}
|
|
19
19
|
onPress={triggerAction}
|
|
20
20
|
testID={`${TESTID.ON_OFF_BUTTON}-${id}`}
|
|
21
|
+
accessibilityLabel={`${TESTID.ON_OFF_BUTTON}-${id}`}
|
|
21
22
|
>
|
|
22
23
|
<View style={styles.smallCircle}>
|
|
23
24
|
<Icon
|
|
@@ -31,6 +32,7 @@ const OnOffButtonTemplate = memo(
|
|
|
31
32
|
{ color: isOn ? Colors.Gray8 : Colors.Gray6 },
|
|
32
33
|
]}
|
|
33
34
|
testID={`${TESTID.SENSOR_STATUS}-${id}`}
|
|
35
|
+
accessibilityLabel={`${TESTID.SENSOR_STATUS}-${id}`}
|
|
34
36
|
>
|
|
35
37
|
{isOn ? configuration.text_on : configuration.text_off}
|
|
36
38
|
</Text>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { memo, useCallback } from 'react';
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import Text from '../Text';
|
|
4
|
+
import styles from './CurtainActionStyles';
|
|
5
|
+
|
|
6
|
+
const CurtainAction = ({ configuration, onPress, template }) => {
|
|
7
|
+
const { open_action, close_action, stop_action, text1, text2, text3 } =
|
|
8
|
+
configuration || {};
|
|
9
|
+
|
|
10
|
+
const onPressActionClose = useCallback(() => {
|
|
11
|
+
onPress &&
|
|
12
|
+
onPress({
|
|
13
|
+
name: text1,
|
|
14
|
+
action: close_action,
|
|
15
|
+
template,
|
|
16
|
+
});
|
|
17
|
+
}, [onPress, text1, close_action, template]);
|
|
18
|
+
|
|
19
|
+
const onPressActionStop = useCallback(() => {
|
|
20
|
+
onPress &&
|
|
21
|
+
onPress({
|
|
22
|
+
name: text2,
|
|
23
|
+
action: stop_action,
|
|
24
|
+
template,
|
|
25
|
+
});
|
|
26
|
+
}, [onPress, text2, stop_action, template]);
|
|
27
|
+
|
|
28
|
+
const onPressActionOpen = useCallback(() => {
|
|
29
|
+
onPress &&
|
|
30
|
+
onPress({
|
|
31
|
+
name: text3,
|
|
32
|
+
action: open_action,
|
|
33
|
+
template,
|
|
34
|
+
});
|
|
35
|
+
}, [onPress, text3, open_action, template]);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<TouchableOpacity onPress={onPressActionClose}>
|
|
40
|
+
<Text type="H4" style={styles.textwithline}>
|
|
41
|
+
{text1}
|
|
42
|
+
</Text>
|
|
43
|
+
</TouchableOpacity>
|
|
44
|
+
|
|
45
|
+
<TouchableOpacity onPress={onPressActionStop}>
|
|
46
|
+
<Text type="H4" style={styles.textwithline}>
|
|
47
|
+
{text2}
|
|
48
|
+
</Text>
|
|
49
|
+
</TouchableOpacity>
|
|
50
|
+
|
|
51
|
+
<TouchableOpacity onPress={onPressActionOpen}>
|
|
52
|
+
<Text type="H4" style={styles.textwithline}>
|
|
53
|
+
{text3}
|
|
54
|
+
</Text>
|
|
55
|
+
</TouchableOpacity>
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export default memo(CurtainAction);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { memo, useCallback } from 'react';
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import Text from '../Text';
|
|
4
|
+
import styles from './OnOffSmartLockActionStyles';
|
|
5
|
+
|
|
6
|
+
const OnOffSmartLockAction = ({ configuration, onPress, template }) => {
|
|
7
|
+
const { action_off, action_on, text_off, text_on } = configuration || {};
|
|
8
|
+
|
|
9
|
+
const onPressActionClose = useCallback(() => {
|
|
10
|
+
onPress &&
|
|
11
|
+
onPress({
|
|
12
|
+
name: text_off,
|
|
13
|
+
action: action_off,
|
|
14
|
+
template,
|
|
15
|
+
});
|
|
16
|
+
}, [onPress, text_off, action_off, template]);
|
|
17
|
+
|
|
18
|
+
const onPressActionOpen = useCallback(() => {
|
|
19
|
+
onPress &&
|
|
20
|
+
onPress({
|
|
21
|
+
name: text_on,
|
|
22
|
+
action: action_on,
|
|
23
|
+
template,
|
|
24
|
+
});
|
|
25
|
+
}, [onPress, text_on, action_on, template]);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<TouchableOpacity onPress={onPressActionClose}>
|
|
30
|
+
<Text type="H4" style={styles.textwithline}>
|
|
31
|
+
{text_off}
|
|
32
|
+
</Text>
|
|
33
|
+
</TouchableOpacity>
|
|
34
|
+
|
|
35
|
+
<TouchableOpacity onPress={onPressActionOpen}>
|
|
36
|
+
<Text type="H4" style={styles.textwithline}>
|
|
37
|
+
{text_on}
|
|
38
|
+
</Text>
|
|
39
|
+
</TouchableOpacity>
|
|
40
|
+
</>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default memo(OnOffSmartLockAction);
|
|
@@ -9,6 +9,8 @@ import ThreeButtonAction from './ThreeButtonAction';
|
|
|
9
9
|
import OnOffSimpleAction from './OnOffSimpleAction';
|
|
10
10
|
import SelectActionCard from '../SelectActionCard';
|
|
11
11
|
import { ModalCustom } from '../Modal';
|
|
12
|
+
import CurtainAction from './CurtainAction';
|
|
13
|
+
import OnOffSmartLockAction from './OnOffSmartLockAction';
|
|
12
14
|
|
|
13
15
|
const ActionTemplate = memo(({ data, onSelectAction }) => {
|
|
14
16
|
const t = useTranslations();
|
|
@@ -66,6 +68,22 @@ const ActionTemplate = memo(({ data, onSelectAction }) => {
|
|
|
66
68
|
key={index}
|
|
67
69
|
/>
|
|
68
70
|
);
|
|
71
|
+
case 'curtain_action_template':
|
|
72
|
+
return (
|
|
73
|
+
<CurtainAction
|
|
74
|
+
{...item}
|
|
75
|
+
onPress={onPressSelectAction}
|
|
76
|
+
key={index}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
case 'OnOffSmartLockActionTemplate':
|
|
80
|
+
return (
|
|
81
|
+
<OnOffSmartLockAction
|
|
82
|
+
{...item}
|
|
83
|
+
onPress={onPressSelectAction}
|
|
84
|
+
key={index}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
69
87
|
}
|
|
70
88
|
});
|
|
71
89
|
}, [data, onPressSelectAction]);
|
|
@@ -131,6 +131,7 @@ const ItemDevice = memo(
|
|
|
131
131
|
<TouchableWithoutFeedback
|
|
132
132
|
onPress={goToSensorDisplay}
|
|
133
133
|
testID={`${TESTID.SENSOR_NAME}-${sensor?.id}`}
|
|
134
|
+
accessibilityLabel={`${TESTID.SENSOR_NAME}-${sensor?.id}`}
|
|
134
135
|
>
|
|
135
136
|
<View
|
|
136
137
|
style={[styles.container, wrapStyle, { borderColor }]}
|
|
@@ -17,6 +17,9 @@ const MenuActionMore = memo(
|
|
|
17
17
|
onItemClick,
|
|
18
18
|
wrapStyle,
|
|
19
19
|
isTextCenter = true,
|
|
20
|
+
idLabelPopover,
|
|
21
|
+
idLabelScrollView,
|
|
22
|
+
idLabelItem = TESTID.SUB_UNIT_NAME,
|
|
20
23
|
}) => {
|
|
21
24
|
const [isDisable, setIsDisable] = useState(false);
|
|
22
25
|
const onPress = useCallback(
|
|
@@ -47,8 +50,12 @@ const MenuActionMore = memo(
|
|
|
47
50
|
onRequestClose={hideMore}
|
|
48
51
|
isVisible={isVisible}
|
|
49
52
|
arrowStyle={styles.wrap}
|
|
53
|
+
accessibilityLabel={idLabelPopover}
|
|
50
54
|
>
|
|
51
|
-
<ScrollView
|
|
55
|
+
<ScrollView
|
|
56
|
+
scrollIndicatorInsets={{ right: 1 }}
|
|
57
|
+
accessibilityLabel={idLabelScrollView}
|
|
58
|
+
>
|
|
52
59
|
{listMenuItem.map((item, index) => {
|
|
53
60
|
return (
|
|
54
61
|
<TouchableOpacity
|
|
@@ -59,6 +66,9 @@ const MenuActionMore = memo(
|
|
|
59
66
|
onPress={onPress(item, index)}
|
|
60
67
|
key={index}
|
|
61
68
|
testID={TESTID.TOUCHABLE_ACTION_ADD_MORE}
|
|
69
|
+
accessibilityLabel={`${idLabelItem}-${
|
|
70
|
+
item?.route ? item?.id : item?.station?.id
|
|
71
|
+
}`}
|
|
62
72
|
disabled={isDisable}
|
|
63
73
|
>
|
|
64
74
|
<Text style={styles.modalHeaderText}>{item.text}</Text>
|
|
@@ -10,7 +10,15 @@ import Station from '../../screens/Unit/Station';
|
|
|
10
10
|
import MenuActionMore from '../MenuActionMore';
|
|
11
11
|
|
|
12
12
|
const NavBar = memo(
|
|
13
|
-
({
|
|
13
|
+
({
|
|
14
|
+
listMenuItem,
|
|
15
|
+
listStation,
|
|
16
|
+
onSnapToItem,
|
|
17
|
+
indexStation,
|
|
18
|
+
style,
|
|
19
|
+
idLabelScrollView,
|
|
20
|
+
idLabelItem,
|
|
21
|
+
}) => {
|
|
14
22
|
const { childRef, showingPopover, showPopoverWithRef, hidePopover } =
|
|
15
23
|
usePopover();
|
|
16
24
|
const refMenuAction = useRef();
|
|
@@ -31,6 +39,7 @@ const NavBar = memo(
|
|
|
31
39
|
onPress={handleShowMenuAction}
|
|
32
40
|
ref={refMenuAction}
|
|
33
41
|
testID={TESTID.NAVBAR_ICON_BARS}
|
|
42
|
+
accessibilityLabel={TESTID.NAVBAR_ICON_BARS}
|
|
34
43
|
>
|
|
35
44
|
<Icon name={'bars'} size={19} color={Colors.Black} />
|
|
36
45
|
</TouchableOpacity>
|
|
@@ -44,6 +53,8 @@ const NavBar = memo(
|
|
|
44
53
|
isTextCenter={false}
|
|
45
54
|
testID={TESTID.NAVBAR_MENU_ACTION_MORE}
|
|
46
55
|
wrapStyle={styles.wrapStyle}
|
|
56
|
+
idLabelScrollView={idLabelScrollView}
|
|
57
|
+
idLabelItem={idLabelItem}
|
|
47
58
|
/>
|
|
48
59
|
</>
|
|
49
60
|
);
|
|
@@ -9,6 +9,7 @@ import Temperature from '../../../assets/images/Temperature.svg';
|
|
|
9
9
|
import UVIndex from '../../../assets/images/UVIndex.svg';
|
|
10
10
|
import WaterQuality from '../../../assets/images/WaterQuality.svg';
|
|
11
11
|
import Device from '../../../assets/images/Device.svg';
|
|
12
|
+
import { TESTID } from '../../configs/Constants';
|
|
12
13
|
|
|
13
14
|
const SummaryItem = memo(({ item, goToSummary }) => {
|
|
14
15
|
const Icon = (() => {
|
|
@@ -29,11 +30,11 @@ const SummaryItem = memo(({ item, goToSummary }) => {
|
|
|
29
30
|
return Device; /* istanbul ignore next */
|
|
30
31
|
}
|
|
31
32
|
})();
|
|
32
|
-
|
|
33
33
|
return (
|
|
34
34
|
<TouchableOpacity
|
|
35
35
|
onPress={() => goToSummary(item)}
|
|
36
36
|
style={styles.wrapSummaryItem}
|
|
37
|
+
accessibilityLabel={`${TESTID.UNIT_DETAIL_UNIT_SUMMARY_ITEM}-${item?.id}`}
|
|
37
38
|
>
|
|
38
39
|
<View style={styles.summaryItem}>
|
|
39
40
|
<Icon />
|
|
@@ -19,6 +19,7 @@ const HeaderUnit = memo(
|
|
|
19
19
|
hideRightPlus,
|
|
20
20
|
styleBoxTitle,
|
|
21
21
|
bottomBorder,
|
|
22
|
+
idButtonMore,
|
|
22
23
|
}) => {
|
|
23
24
|
const { goBack } = useNavigation();
|
|
24
25
|
const buttonMoreRef = useRef(null);
|
|
@@ -80,6 +81,7 @@ const HeaderUnit = memo(
|
|
|
80
81
|
style={styles.btnMore}
|
|
81
82
|
onPress={onPressMore}
|
|
82
83
|
ref={buttonMoreRef}
|
|
84
|
+
accessibilityLabel={idButtonMore}
|
|
83
85
|
>
|
|
84
86
|
<Icon
|
|
85
87
|
name={'more'}
|
|
@@ -21,6 +21,8 @@ const WrapParallaxScrollView = ({
|
|
|
21
21
|
hideRight,
|
|
22
22
|
hideRightPlus,
|
|
23
23
|
contentBackground,
|
|
24
|
+
accessibilityLabel,
|
|
25
|
+
idButtonMore,
|
|
24
26
|
}) => {
|
|
25
27
|
const renderForeground = useCallback(
|
|
26
28
|
() => (
|
|
@@ -32,6 +34,7 @@ const WrapParallaxScrollView = ({
|
|
|
32
34
|
onMore={onMore}
|
|
33
35
|
hideRight={hideRight}
|
|
34
36
|
hideRightPlus={hideRightPlus}
|
|
37
|
+
idButtonMore={idButtonMore}
|
|
35
38
|
/>
|
|
36
39
|
<Text semibold style={styles.nameUnit}>
|
|
37
40
|
{title}
|
|
@@ -39,7 +42,16 @@ const WrapParallaxScrollView = ({
|
|
|
39
42
|
{contentBackground}
|
|
40
43
|
</View>
|
|
41
44
|
),
|
|
42
|
-
[
|
|
45
|
+
[
|
|
46
|
+
onBack,
|
|
47
|
+
onAdd,
|
|
48
|
+
onMore,
|
|
49
|
+
hideRight,
|
|
50
|
+
hideRightPlus,
|
|
51
|
+
idButtonMore,
|
|
52
|
+
title,
|
|
53
|
+
contentBackground,
|
|
54
|
+
]
|
|
43
55
|
);
|
|
44
56
|
const renderBackground = useCallback(
|
|
45
57
|
() => (
|
|
@@ -68,10 +80,11 @@ const WrapParallaxScrollView = ({
|
|
|
68
80
|
onMore={onMore}
|
|
69
81
|
hideRight={hideRight}
|
|
70
82
|
hideRightPlus={hideRightPlus}
|
|
83
|
+
idButtonMore={idButtonMore}
|
|
71
84
|
/>
|
|
72
85
|
</View>
|
|
73
86
|
),
|
|
74
|
-
[title, onBack, onAdd, onMore, hideRight, hideRightPlus]
|
|
87
|
+
[title, onBack, onAdd, onMore, hideRight, hideRightPlus, idButtonMore]
|
|
75
88
|
);
|
|
76
89
|
return (
|
|
77
90
|
<ParallaxScrollView
|
|
@@ -83,6 +96,7 @@ const WrapParallaxScrollView = ({
|
|
|
83
96
|
backgroundColor={Colors.White}
|
|
84
97
|
refreshControl={refreshControl}
|
|
85
98
|
showsVerticalScrollIndicator={false}
|
|
99
|
+
accessibilityLabel={accessibilityLabel}
|
|
86
100
|
>
|
|
87
101
|
{children}
|
|
88
102
|
</ParallaxScrollView>
|
package/src/configs/Constants.js
CHANGED
|
@@ -400,6 +400,11 @@ export const TESTID = {
|
|
|
400
400
|
//Unit Detail
|
|
401
401
|
UNIT_DETAIL_STATION_LIST: 'UNIT_DETAIL_STATION_LIST',
|
|
402
402
|
UNIT_DETAIL_UNIT_SUMMARY_VIEW: 'UNIT_DETAIL_UNIT_SUMMARY_VIEW',
|
|
403
|
+
UNIT_DETAIL_UNIT_SUMMARY_ITEM: 'UNIT_DETAIL_UNIT_SUMMARY_ITEM',
|
|
404
|
+
UNIT_DETAIL_PARALLAX_SCROLLVIEW: 'UNIT_DETAIL_PARALLAX_SCROLLVIEW',
|
|
405
|
+
UNIT_DETAIL_PARALLAX_BUTTON_MORE: 'UNIT_DETAIL_PARALLAX_BUTTON_MORE',
|
|
406
|
+
UNIT_DETAIL_POPUP_MORE: 'UNIT_DETAIL_POPUP_MORE',
|
|
407
|
+
UNIT_DETAIL_POPUP_MORE_ITEM: 'UNIT_DETAIL_POPUP_MORE_ITEM',
|
|
403
408
|
|
|
404
409
|
ON_CHECK_SPOT_NUMBER: 'ON_CHECK_SPOT_NUMBER',
|
|
405
410
|
ON_BOOK_NOW: 'ON_BOOK_NOW',
|
|
@@ -226,12 +226,15 @@ const SelectAction = memo(({ route }) => {
|
|
|
226
226
|
case 'one_button_action_template':
|
|
227
227
|
case 'three_button_action_template':
|
|
228
228
|
case 'OnOffSimpleActionTemplate':
|
|
229
|
+
case 'curtain_action_template':
|
|
229
230
|
index = newActions.findIndex((item) => {
|
|
230
231
|
return (
|
|
231
232
|
item.template === 'on_off_button_action_template' ||
|
|
232
233
|
item.template === 'one_button_action_template' ||
|
|
233
234
|
item.template === 'three_button_action_template' ||
|
|
234
|
-
item.template === 'OnOffSimpleActionTemplate'
|
|
235
|
+
item.template === 'OnOffSimpleActionTemplate' ||
|
|
236
|
+
item.template === 'curtain_action_template' ||
|
|
237
|
+
item.template === 'OnOffSmartLockActionTemplate'
|
|
235
238
|
);
|
|
236
239
|
});
|
|
237
240
|
break;
|
|
@@ -423,6 +426,8 @@ const RenderActionItem = ({ data, onSelectAction }) => {
|
|
|
423
426
|
case 'one_button_action_template':
|
|
424
427
|
case 'three_button_action_template':
|
|
425
428
|
case 'OnOffSimpleActionTemplate':
|
|
429
|
+
case 'curtain_action_template':
|
|
430
|
+
case 'OnOffSmartLockActionTemplate':
|
|
426
431
|
actionTemplate.push(item);
|
|
427
432
|
break;
|
|
428
433
|
case 'OptionsDropdownActionTemplate':
|
|
@@ -50,57 +50,19 @@ describe('test NotificationItem', () => {
|
|
|
50
50
|
item = { ...item, is_read: false, content_code: '' };
|
|
51
51
|
});
|
|
52
52
|
let tree;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
screen: Routes.SmartParkingBookingDetails,
|
|
62
|
-
params: { id: 1 },
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
content_code: NOTIFICATION_TYPES.REMIND_TO_SCAN_QR_CODE,
|
|
66
|
-
screen: Routes.SmartParkingBookingDetails,
|
|
67
|
-
params: { id: 1 },
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
content_code: NOTIFICATION_TYPES.BOOKING_SUCCESSFULLY,
|
|
71
|
-
screen: Routes.SmartParkingBookingDetails,
|
|
72
|
-
params: { id: 1 },
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
content_code: NOTIFICATION_TYPES.BOOKING_EXPIRED_AND_VIOLATION_CREATED,
|
|
76
|
-
screen: Routes.SmartParkingBookingDetails,
|
|
77
|
-
params: { id: 1 },
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
content_code: NOTIFICATION_TYPES.MOVE_CAR_WITHOUT_PAY_VIOLATION,
|
|
81
|
-
screen: Routes.SmartParkingBookingDetails,
|
|
82
|
-
params: { id: 1 },
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
content_code: NOTIFICATION_TYPES.PAY_FINE_SUCCESSFULLY,
|
|
86
|
-
screen: Routes.SmartParkingBookingDetails,
|
|
87
|
-
params: { id: 1 },
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
content_code: NOTIFICATION_TYPES.STOP_VIOLATION_FREE_PARKING_ZONE,
|
|
91
|
-
screen: Routes.SmartParkingBookingDetails,
|
|
92
|
-
params: { id: 1 },
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
content_code: NOTIFICATION_TYPES.PAY_FINE_AND_EXTEND_SUCCESSFULLY,
|
|
96
|
-
screen: Routes.SmartParkingBookingDetails,
|
|
97
|
-
params: { id: 1 },
|
|
98
|
-
},
|
|
53
|
+
|
|
54
|
+
const listCase2 = [
|
|
55
|
+
NOTIFICATION_TYPES.NOTIFY_REMOVE_UNIT,
|
|
56
|
+
NOTIFICATION_TYPES.NOTIFY_REMOVE_MEMBER,
|
|
57
|
+
NOTIFICATION_TYPES.NOTIFY_MEMBER_LEAVE_UNIT,
|
|
58
|
+
NOTIFICATION_TYPES.NOTIFY_REMOVE_SUB_UNIT,
|
|
59
|
+
NOTIFICATION_TYPES.NOTIFY_REMOVE_DEVICE,
|
|
60
|
+
'default case',
|
|
99
61
|
];
|
|
100
62
|
|
|
101
|
-
for (const
|
|
102
|
-
test(`create ItemNotification ${
|
|
103
|
-
item.content_code =
|
|
63
|
+
for (const content_code of listCase2) {
|
|
64
|
+
test(`create ItemNotification ${content_code}`, () => {
|
|
65
|
+
item.content_code = content_code;
|
|
104
66
|
act(() => {
|
|
105
67
|
tree = create(wrapComponent(item));
|
|
106
68
|
});
|
|
@@ -109,33 +71,23 @@ describe('test NotificationItem', () => {
|
|
|
109
71
|
act(() => {
|
|
110
72
|
button.props.onPress();
|
|
111
73
|
});
|
|
112
|
-
expect(mockNavigate).
|
|
113
|
-
screen: notify.screen,
|
|
114
|
-
params: { id: 1 },
|
|
115
|
-
});
|
|
74
|
+
expect(mockNavigate).not.toHaveBeenCalled();
|
|
116
75
|
});
|
|
117
76
|
}
|
|
118
77
|
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
content_code: NOTIFICATION_TYPES.SYSTEM_CANCEL_NO_PAYMENT,
|
|
127
|
-
screen: Routes.MyBookingList,
|
|
128
|
-
params: { tab: 1 },
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
content_code: NOTIFICATION_TYPES.PARKING_COMPLETED,
|
|
132
|
-
screen: Routes.MyBookingList,
|
|
133
|
-
params: { tab: 1 },
|
|
134
|
-
},
|
|
78
|
+
const listCaseUnitDetail = [
|
|
79
|
+
NOTIFICATION_TYPES.NOTIFY_RENAME_UNIT,
|
|
80
|
+
NOTIFICATION_TYPES.NOTIFY_UPDATE_ADDRESS,
|
|
81
|
+
NOTIFICATION_TYPES.NOTIFY_RENAME_SUB_UNIT,
|
|
82
|
+
NOTIFICATION_TYPES.NOTIFY_INVITE_MEMBER,
|
|
135
83
|
];
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
84
|
+
|
|
85
|
+
for (const content_code of listCaseUnitDetail) {
|
|
86
|
+
test(`create ItemNotification ${content_code}`, () => {
|
|
87
|
+
item.content_code = content_code;
|
|
88
|
+
item.params = {
|
|
89
|
+
unit_id: 1,
|
|
90
|
+
};
|
|
139
91
|
act(() => {
|
|
140
92
|
tree = create(wrapComponent(item));
|
|
141
93
|
});
|
|
@@ -144,25 +96,24 @@ describe('test NotificationItem', () => {
|
|
|
144
96
|
act(() => {
|
|
145
97
|
button.props.onPress();
|
|
146
98
|
});
|
|
147
|
-
expect(mockNavigate).toHaveBeenCalledWith(Routes.
|
|
148
|
-
screen:
|
|
149
|
-
params: {
|
|
99
|
+
expect(mockNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
|
|
100
|
+
screen: Routes.UnitDetail,
|
|
101
|
+
params: {
|
|
102
|
+
unitId: 1,
|
|
103
|
+
},
|
|
150
104
|
});
|
|
151
105
|
});
|
|
152
106
|
}
|
|
153
107
|
|
|
154
|
-
const
|
|
155
|
-
NOTIFICATION_TYPES.NOTIFY_REMOVE_UNIT,
|
|
156
|
-
NOTIFICATION_TYPES.NOTIFY_REMOVE_MEMBER,
|
|
157
|
-
NOTIFICATION_TYPES.NOTIFY_MEMBER_LEAVE_UNIT,
|
|
158
|
-
NOTIFICATION_TYPES.NOTIFY_REMOVE_SUB_UNIT,
|
|
159
|
-
NOTIFICATION_TYPES.NOTIFY_REMOVE_DEVICE,
|
|
160
|
-
'default case',
|
|
161
|
-
];
|
|
108
|
+
const listCaseDeviceDetail = [NOTIFICATION_TYPES.NOTIFY_DEVICE_DISCONNECT];
|
|
162
109
|
|
|
163
|
-
for (const content_code of
|
|
110
|
+
for (const content_code of listCaseDeviceDetail) {
|
|
164
111
|
test(`create ItemNotification ${content_code}`, () => {
|
|
165
112
|
item.content_code = content_code;
|
|
113
|
+
item.params = {
|
|
114
|
+
unit_id: 1,
|
|
115
|
+
sensor_id: 1,
|
|
116
|
+
};
|
|
166
117
|
act(() => {
|
|
167
118
|
tree = create(wrapComponent(item));
|
|
168
119
|
});
|
|
@@ -171,7 +122,13 @@ describe('test NotificationItem', () => {
|
|
|
171
122
|
act(() => {
|
|
172
123
|
button.props.onPress();
|
|
173
124
|
});
|
|
174
|
-
expect(mockNavigate).
|
|
125
|
+
expect(mockNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
|
|
126
|
+
screen: Routes.DeviceDetail,
|
|
127
|
+
params: {
|
|
128
|
+
unitId: 1,
|
|
129
|
+
sensorId: 1,
|
|
130
|
+
},
|
|
131
|
+
});
|
|
175
132
|
});
|
|
176
133
|
}
|
|
177
134
|
|
|
@@ -208,6 +165,24 @@ describe('test NotificationItem', () => {
|
|
|
208
165
|
});
|
|
209
166
|
}
|
|
210
167
|
|
|
168
|
+
test('test case NOTIFY_INDICATOR no sensor_type', () => {
|
|
169
|
+
item.content_code = NOTIFICATION_TYPES.NOTIFY_INDICATOR;
|
|
170
|
+
item.params = {
|
|
171
|
+
sensor_type: null,
|
|
172
|
+
unit_id: 5,
|
|
173
|
+
summary_id: 11,
|
|
174
|
+
};
|
|
175
|
+
act(() => {
|
|
176
|
+
tree = create(wrapComponent(item));
|
|
177
|
+
});
|
|
178
|
+
const instance = tree.root;
|
|
179
|
+
const button = instance.findByType(TouchableOpacity);
|
|
180
|
+
act(() => {
|
|
181
|
+
button.props.onPress();
|
|
182
|
+
});
|
|
183
|
+
expect(mockNavigate).not.toHaveBeenCalled();
|
|
184
|
+
});
|
|
185
|
+
|
|
211
186
|
const listSensorType2 = [
|
|
212
187
|
SENSOR_TYPE.SMOKE,
|
|
213
188
|
SENSOR_TYPE.FIRE,
|
|
@@ -344,4 +319,23 @@ describe('test NotificationItem', () => {
|
|
|
344
319
|
},
|
|
345
320
|
});
|
|
346
321
|
});
|
|
322
|
+
|
|
323
|
+
test('test notify emergency not params type', () => {
|
|
324
|
+
item.content_code = NOTIFICATION_TYPES.NOTIFY_EMERGENCY;
|
|
325
|
+
item.params = {
|
|
326
|
+
unit_id: 1,
|
|
327
|
+
sensor_id: 1,
|
|
328
|
+
type: null,
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
act(() => {
|
|
332
|
+
tree = create(wrapComponent(item));
|
|
333
|
+
});
|
|
334
|
+
const instance = tree.root;
|
|
335
|
+
const button = instance.findByType(TouchableOpacity);
|
|
336
|
+
act(() => {
|
|
337
|
+
button.props.onPress();
|
|
338
|
+
});
|
|
339
|
+
expect(mockNavigate).not.toHaveBeenCalled();
|
|
340
|
+
});
|
|
347
341
|
});
|