@eohjsc/react-native-smart-city 0.3.90 → 0.3.91
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/__test__/NumberUpDownTemplate.test.js +1 -1
- package/src/commons/ActionTemplate/CurtainAction.js +2 -2
- package/src/commons/ActionTemplate/OnOffButtonAction.js +2 -2
- package/src/commons/ActionTemplate/OnOffSimpleAction.js +2 -2
- package/src/commons/ActionTemplate/OnOffSmartLockAction.js +2 -2
- package/src/commons/ActionTemplate/OneButtonAction.js +2 -2
- package/src/commons/ActionTemplate/ThreeButtonAction.js +2 -2
- package/src/commons/ActionTemplate/__test__/CurtainAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/OnOffSimpleAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/OnOffSmartLockAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/OneButtonAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/ThreeButtonAction.test.js +1 -1
- package/src/commons/ActionTemplate/__test__/index.test.js +21 -70
- package/src/commons/ActionTemplate/index.js +19 -55
- package/src/commons/Alert/__test__/Alert.test.js +1 -1
- package/src/commons/Auth/__test__/OtpInputList.test.js +4 -2
- package/src/commons/Auth/__test__/SocialButton.test.js +4 -2
- package/src/commons/BackDefault/__test__/BackDefault.test.js +1 -1
- package/src/commons/Button/__test__/Button.test.js +1 -1
- package/src/commons/ButtonPopup/__test__/ButtonPopup.test.js +1 -1
- package/src/commons/Calendar/__test__/Calendar.test.js +1 -1
- package/src/commons/ChartLoading/__test__/ChartLoading.test.js +1 -1
- package/src/commons/CircleButton/__test__/CircleButton.test.js +1 -1
- package/src/commons/CircleView/__test__/CircleView.test.js +1 -1
- package/src/commons/DateTimeRangeChange/__test__/DateTimeButton.test.js +4 -2
- package/src/commons/DateTimeRangeChange/index.js +31 -48
- package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +2 -2
- package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +1 -1
- package/src/commons/Device/FlatListItems.js +1 -1
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +2 -2
- package/src/commons/Device/HistoryChart.js +6 -49
- package/src/commons/Device/LinearChart/LinearChart.test.js +1 -1
- package/src/commons/Device/ProgressBar/__test__/ProgressBar.test.js +1 -1
- package/src/commons/Device/RainningSensor/__test__/CurrentRainSensor.test.js +5 -5
- package/src/commons/Device/SonosSpeaker/__test__/SonosSpeaker.test.js +3 -3
- package/src/commons/Device/WindDirection/Compass/Compass.test.js +2 -2
- package/src/commons/Device/WindSpeed/LinearChart/index.js +1 -1
- package/src/commons/Device/__test__/DeviceAlertStatus.test.js +3 -3
- package/src/commons/Device/__test__/DisconnectedView.test.js +2 -2
- package/src/commons/Device/__test__/FlatListItems.test.js +1 -1
- package/src/commons/Device/__test__/SensorConnectedStatus.test.js +1 -1
- package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +1 -1
- package/src/commons/Form/__test__/CurrencyInput.test.js +2 -2
- package/src/commons/Form/__test__/TextInput.test.js +2 -2
- package/src/commons/Form/__test__/TextInputPassword.test.js +2 -2
- package/src/commons/FullLoading/__test__/index.test.js +2 -2
- package/src/commons/ImageButton/__test__/ImageButton.test.js +1 -1
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +2 -2
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +4 -4
- package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +4 -4
- package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +2 -2
- package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +1 -1
- package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +2 -2
- package/src/commons/RowItem/__test__/RowItem.test.js +1 -1
- package/src/commons/RowUser/__test__/RowUser.test.js +1 -1
- package/src/commons/Section/Section.test.js +2 -2
- package/src/commons/SelectSubUnit/__test__/SelectSubUnit.test.js +1 -1
- package/src/commons/SelectUnit/__test__/SelectUnit.test.js +3 -3
- package/src/commons/Sharing/__test__/ButtonRemoveMember.test.js +1 -1
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +1 -1
- package/src/commons/Sharing/__test__/MemberList.test.js +6 -4
- package/src/commons/Sharing/__test__/RowMember.test.js +2 -2
- package/src/commons/Sharing/__test__/StationDevicePermission.test.js +3 -3
- package/src/commons/Sharing/__test__/WrapHeaderScrollable.test.js +4 -2
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +2 -10
- package/src/commons/SubUnit/OneTap/index.js +3 -1
- package/src/commons/TextButton/__test__/TextButton.test.js +2 -2
- package/src/commons/Today/__test__/Today.test.js +1 -1
- package/src/commons/TouchableScale/__test__/TouchableScale.test.js +1 -1
- package/src/commons/UnitSummary/AirQuality/index.js +2 -2
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +0 -6
- package/src/commons/UnitSummary/__test__/TotalPowerBox.test.js +1 -1
- package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +1 -1
- package/src/commons/ViewButtonBottom/__test__/ViewButtonBottom.test.js +1 -1
- package/src/configs/API.js +9 -32
- package/src/configs/Constants.js +2 -30
- package/src/context/reducer.ts +3 -1
- package/src/hoc/__test__/withRemoteControl.test.js +1 -1
- package/src/navigations/UnitStack.js +23 -13
- package/src/screens/ActivityLog/FilterPopup.js +4 -4
- package/src/screens/ActivityLog/__test__/FilterPopup.test.js +2 -2
- package/src/screens/ActivityLog/__test__/index.test.js +2 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +3 -3
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +5 -5
- package/src/screens/AddNewAction/ChooseAction.js +180 -0
- package/src/screens/AddNewAction/ChooseConfig.js +207 -0
- package/src/screens/AddNewAction/Components/SelectDevices.js +75 -0
- package/src/screens/AddNewAction/Device/__test__/index.test.js +1 -1
- package/src/screens/AddNewAction/NewActionWrapper.js +55 -0
- package/src/screens/AddNewAction/SelectControlDevices.js +107 -0
- package/src/screens/AddNewAction/SelectMonitorDevices.js +142 -0
- package/src/screens/AddNewAction/SetupConfigCondition.js +245 -0
- package/src/screens/AddNewAction/Styles/SetupSensorStyles.js +1 -1
- package/src/screens/AddNewAction/__test__/{SelectAction.test.js → ChooseAction.test.js} +94 -114
- package/src/screens/AddNewAction/__test__/ChooseConfig.test.js +211 -0
- package/src/screens/AddNewAction/__test__/{SelectSensorDevices.test.js → SelectControlDevices.test.js} +32 -83
- package/src/screens/AddNewAction/__test__/SelectMonitorDevices.test.js +92 -0
- package/src/screens/AddNewAction/__test__/SetupSensor.test.js +9 -22
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +2 -3
- package/src/screens/AddNewAutoSmart/index.js +13 -33
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectRouterGuide.test.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +1 -1
- package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +1 -1
- package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +2 -2
- package/src/screens/AddNewGateway/__test__/ScanModbusQR.test.js +3 -3
- package/src/screens/AddNewGateway/__test__/ScanWifiDeviceQR.test.js +2 -2
- package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +3 -3
- package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +1 -1
- package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +1 -1
- package/src/screens/AddNewOneTap/index.js +16 -7
- package/src/screens/AllCamera/__test__/index.test.js +18 -57
- package/src/screens/AllCamera/index.js +98 -30
- package/src/screens/Automate/MultiUnits.js +2 -2
- package/src/screens/Automate/__test__/MultiUnits.test.js +2 -2
- package/src/screens/Automate/__test__/index.test.js +19 -38
- package/src/screens/Automate/index.js +8 -3
- package/src/screens/Device/__test__/DetailHistoryChart.test.js +2 -2
- package/src/screens/Device/__test__/EmergencyCountdown.test.js +4 -2
- package/src/screens/Device/__test__/sensorDisplayItem.test.js +10 -10
- package/src/screens/Device/components/ChartWrapper.js +3 -3
- package/src/screens/Device/components/VisualChart.js +1 -1
- package/src/screens/Device/components/__test__/VisualChart.test.js +1 -1
- package/src/screens/Device/hooks/useEvaluateValue.js +8 -0
- package/src/screens/DeviceInfo/__test__/index.test.js +16 -18
- package/src/screens/DeviceInfo/index.js +6 -5
- package/src/screens/EditActionsList/__tests__/index.test.js +14 -6
- package/src/screens/Notification/__test__/Notification.test.js +65 -74
- package/src/screens/Notification/index.js +14 -14
- package/src/screens/ScriptDetail/__test__/index.test.js +2 -8
- package/src/screens/ScriptDetail/index.js +9 -88
- package/src/screens/ScriptDetail/utils.js +112 -0
- package/src/screens/SelectUnit/__test__/index.test.js +0 -5
- package/src/screens/SelectUnit/index.js +1 -2
- package/src/screens/Sharing/Components/TitleCheckBox.js +2 -2
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +3 -3
- package/src/screens/SmartAccount/__test__/Connecting.test.js +1 -1
- package/src/screens/SmartAccount/__test__/SmartAccount.test.js +3 -3
- package/src/screens/SmartIr/__test__/ButtonsBottom.test.js +1 -1
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +5 -5
- package/src/screens/SmartIr/__test__/SelectBrand.test.js +2 -2
- package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +2 -2
- package/src/screens/SmartIr/__test__/SmartIr.test.js +2 -2
- package/src/screens/Template/__test__/detail.test.js +10 -2
- package/src/screens/Unit/__test__/Detail.test.js +7 -13
- package/src/screens/Unit/components/__test__/Header.test.js +4 -4
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +1 -1
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +14 -6
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +1 -1
- package/src/screens/UnitSummary/components/Temperature/index.js +2 -2
- package/src/screens/UnitSummary/components/UvIndex/index.js +2 -2
- package/src/screens/UnitSummary/components/WaterQuality/index.js +2 -2
- package/src/screens/UnitSummary/components/__test__/TotalPowerBox.test.js +1 -1
- package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +1 -1
- package/src/screens/UnitSummary/components/__test__/index.test.js +2 -2
- package/src/utils/Apis/axios.js +3 -0
- package/src/utils/I18n/translations/en.json +1 -0
- package/src/utils/I18n/translations/vi.json +1 -0
- package/src/utils/Route/index.js +6 -3
- package/src/screens/AddNewAction/SelectAction.js +0 -570
- package/src/screens/AddNewAction/SelectSensorDevices.js +0 -236
- package/src/screens/AddNewAction/SetupSensor.js +0 -263
|
@@ -72,7 +72,9 @@ describe('EditActionsList', () => {
|
|
|
72
72
|
el.type === TouchableOpacity
|
|
73
73
|
);
|
|
74
74
|
expect(buttonCancel).toBeDefined();
|
|
75
|
-
|
|
75
|
+
await act(async () => {
|
|
76
|
+
buttonCancel.props.onPress();
|
|
77
|
+
});
|
|
76
78
|
expect(mockGoBack).toHaveBeenCalled();
|
|
77
79
|
});
|
|
78
80
|
it('EditActionsList onPress save', async () => {
|
|
@@ -88,10 +90,15 @@ describe('EditActionsList', () => {
|
|
|
88
90
|
el.type === TouchableOpacity
|
|
89
91
|
);
|
|
90
92
|
expect(buttonSave).toBeDefined();
|
|
91
|
-
|
|
93
|
+
|
|
94
|
+
await act(async () => {
|
|
95
|
+
buttonSave.props.onPress();
|
|
96
|
+
});
|
|
97
|
+
|
|
92
98
|
expect(mock.history.put).toHaveLength(1);
|
|
93
99
|
});
|
|
94
|
-
|
|
100
|
+
|
|
101
|
+
it('EditActionsList has remove button', async () => {
|
|
95
102
|
await act(async () => {
|
|
96
103
|
tree = await create(wrapComponent());
|
|
97
104
|
});
|
|
@@ -103,18 +110,19 @@ describe('EditActionsList', () => {
|
|
|
103
110
|
el.type === TouchableOpacity
|
|
104
111
|
);
|
|
105
112
|
expect(buttonRemove).toBeDefined();
|
|
106
|
-
buttonRemove.props.onPress();
|
|
107
113
|
});
|
|
114
|
+
|
|
108
115
|
it('EditActionsList modal onPress remove', async () => {
|
|
109
116
|
await act(async () => {
|
|
110
117
|
tree = await create(wrapComponent());
|
|
111
118
|
});
|
|
112
119
|
const instance = tree.root;
|
|
113
120
|
const modalBottom = instance.findAllByType(ModalBottom);
|
|
114
|
-
|
|
121
|
+
await act(async () => {
|
|
122
|
+
modalBottom[0].props.onRemove();
|
|
123
|
+
});
|
|
115
124
|
|
|
116
125
|
mock.onDelete(API.AUTOMATE.DELETE_SCRIPT_ACTION(1, 1)).reply(200);
|
|
117
126
|
expect(mock.history.delete).toHaveLength(1);
|
|
118
|
-
modalBottom[0].props.onClose();
|
|
119
127
|
});
|
|
120
128
|
});
|
|
@@ -10,6 +10,7 @@ import Notification from '../index';
|
|
|
10
10
|
import NotificationItem from '../components/NotificationItem';
|
|
11
11
|
import { API } from '../../../configs';
|
|
12
12
|
import api from '../../../utils/Apis/axios';
|
|
13
|
+
import { WrapHeaderScrollable } from '../../../commons';
|
|
13
14
|
|
|
14
15
|
const wrapComponent = () => (
|
|
15
16
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -48,33 +49,30 @@ describe('test Notification', () => {
|
|
|
48
49
|
|
|
49
50
|
it('test render', async () => {
|
|
50
51
|
const response = {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
},
|
|
52
|
+
results: [
|
|
53
|
+
{
|
|
54
|
+
content_code: 'NOTIFY_INVITE_MEMBER',
|
|
55
|
+
created_at: '2021-10-07T08:57:09.370286Z',
|
|
56
|
+
icon: 'https://eoh-gateway-backend.eoh.io/Rectangle_65.png',
|
|
57
|
+
id: 12905,
|
|
58
|
+
is_read: true,
|
|
59
|
+
params: "{'unit_owner_name': 'Canh', 'unit_name': 'EoH Office'}",
|
|
60
|
+
type: 'NEWS',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
content_code: 'PARKING_COMPLETED',
|
|
64
|
+
created_at: '2021-07-26T07:30:00.558123Z',
|
|
65
|
+
icon: 'https://eoh-gateway-backend.eoh.io/2021-07-01_00-21_1.png',
|
|
66
|
+
id: 11621,
|
|
67
|
+
is_read: true,
|
|
68
|
+
params: "{'booking_id': 4736}",
|
|
69
|
+
type: 'NEWS',
|
|
70
|
+
},
|
|
71
|
+
],
|
|
74
72
|
};
|
|
75
73
|
mock
|
|
76
74
|
.onGet(API.NOTIFICATION.LIST_EOH_NOTIFICATIONS(1, ''))
|
|
77
|
-
.reply(200, response
|
|
75
|
+
.reply(200, response);
|
|
78
76
|
await act(async () => {
|
|
79
77
|
tree = await create(wrapComponent());
|
|
80
78
|
});
|
|
@@ -84,75 +82,68 @@ describe('test Notification', () => {
|
|
|
84
82
|
expect(notificationItem).toHaveLength(2);
|
|
85
83
|
});
|
|
86
84
|
|
|
87
|
-
it('test handleOnLoadMore', async () => {
|
|
85
|
+
it.only('test handleOnLoadMore', async () => {
|
|
88
86
|
const response = {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
results: [
|
|
92
|
-
{
|
|
93
|
-
content_code: 'NOTIFY_INVITE_MEMBER',
|
|
94
|
-
created_at: '2021-10-07T08:57:09.370286Z',
|
|
95
|
-
icon: 'https://eoh-gateway-backend.eoh.io/Rectangle_65.png',
|
|
96
|
-
id: 12905,
|
|
97
|
-
is_read: true,
|
|
98
|
-
params: "{'unit_owner_name': 'Canh', 'unit_name': 'EoH Office'}",
|
|
99
|
-
type: 'NEWS',
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
content_code: 'PARKING_COMPLETED',
|
|
103
|
-
created_at: '2021-07-26T07:30:00.558123Z',
|
|
104
|
-
icon: 'https://eoh-gateway-backend.eoh.io/2021-07-01_00-21_1.png',
|
|
105
|
-
id: 11621,
|
|
106
|
-
is_read: true,
|
|
107
|
-
params: "{'booking_id': 4736}",
|
|
108
|
-
type: 'NEWS',
|
|
109
|
-
},
|
|
110
|
-
],
|
|
111
|
-
},
|
|
87
|
+
count: 13,
|
|
88
|
+
results: [],
|
|
112
89
|
};
|
|
90
|
+
for (let index = 0; index < 10; index++) {
|
|
91
|
+
response.results.push({
|
|
92
|
+
content_code: 'NOTIFY_INVITE_MEMBER',
|
|
93
|
+
created_at: '2021-10-07T08:57:09.370286Z',
|
|
94
|
+
icon: 'https://eoh-gateway-backend.eoh.io/Rectangle_65.png',
|
|
95
|
+
id: 12905,
|
|
96
|
+
is_read: true,
|
|
97
|
+
params: "{'unit_owner_name': 'Canh', 'unit_name': 'EoH Office'}",
|
|
98
|
+
type: 'NEWS',
|
|
99
|
+
});
|
|
100
|
+
}
|
|
113
101
|
mock
|
|
114
102
|
.onGet(API.NOTIFICATION.LIST_EOH_NOTIFICATIONS(1, ''))
|
|
115
|
-
.reply(200, response
|
|
103
|
+
.reply(200, response);
|
|
116
104
|
await act(async () => {
|
|
117
105
|
tree = await create(wrapComponent());
|
|
118
106
|
});
|
|
119
107
|
const instance = tree.root;
|
|
108
|
+
const wrapHeaderScrollable = instance.findByType(WrapHeaderScrollable);
|
|
109
|
+
expect(wrapHeaderScrollable.props.disableLoadMore).toEqual(false);
|
|
110
|
+
|
|
120
111
|
const scrollView = instance.findByType(Animated.ScrollView);
|
|
112
|
+
mock
|
|
113
|
+
.onGet(API.NOTIFICATION.LIST_EOH_NOTIFICATIONS(2, ''))
|
|
114
|
+
.reply(200, response);
|
|
121
115
|
await act(async () => {
|
|
122
116
|
scrollView.props.onMomentumScrollEnd();
|
|
123
117
|
});
|
|
124
|
-
expect(
|
|
118
|
+
expect(wrapHeaderScrollable.props.disableLoadMore).toEqual(true);
|
|
125
119
|
});
|
|
126
120
|
|
|
127
121
|
it('test onRefresh', async () => {
|
|
128
122
|
const response = {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
},
|
|
150
|
-
],
|
|
151
|
-
},
|
|
123
|
+
results: [
|
|
124
|
+
{
|
|
125
|
+
content_code: 'NOTIFY_INVITE_MEMBER',
|
|
126
|
+
created_at: '2021-10-07T08:57:09.370286Z',
|
|
127
|
+
icon: 'https://eoh-gateway-backend.eoh.io/Rectangle_65.png',
|
|
128
|
+
id: 12905,
|
|
129
|
+
is_read: true,
|
|
130
|
+
params: "{'unit_owner_name': 'Canh', 'unit_name': 'EoH Office'}",
|
|
131
|
+
type: 'NEWS',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
content_code: 'PARKING_COMPLETED',
|
|
135
|
+
created_at: '2021-07-26T07:30:00.558123Z',
|
|
136
|
+
icon: 'https://eoh-gateway-backend.eoh.io/2021-07-01_00-21_1.png',
|
|
137
|
+
id: 11621,
|
|
138
|
+
is_read: true,
|
|
139
|
+
params: "{'booking_id': 4736}",
|
|
140
|
+
type: 'NEWS',
|
|
141
|
+
},
|
|
142
|
+
],
|
|
152
143
|
};
|
|
153
144
|
mock
|
|
154
145
|
.onGet(API.NOTIFICATION.LIST_EOH_NOTIFICATIONS(1, ''))
|
|
155
|
-
.reply(200, response
|
|
146
|
+
.reply(200, response);
|
|
156
147
|
await act(async () => {
|
|
157
148
|
tree = await create(wrapComponent());
|
|
158
149
|
});
|
|
@@ -17,10 +17,9 @@ import { useSCContextSelector } from '../../context';
|
|
|
17
17
|
import { notImplemented } from '../../utils/Utils';
|
|
18
18
|
import { useReceiveNotifications } from '../../hooks';
|
|
19
19
|
|
|
20
|
-
let page = 1;
|
|
21
|
-
|
|
22
20
|
const Notification = memo(() => {
|
|
23
21
|
const t = useTranslations();
|
|
22
|
+
const [page, setPage] = useState(1);
|
|
24
23
|
const user = useSCContextSelector((state) => state?.auth?.account?.user);
|
|
25
24
|
const [notifications, setNotifications] = useState([]);
|
|
26
25
|
const [maxPageNotification, setMaxPageNotification] = useState(1);
|
|
@@ -60,27 +59,21 @@ const Notification = memo(() => {
|
|
|
60
59
|
}
|
|
61
60
|
}, []);
|
|
62
61
|
|
|
63
|
-
useFocusEffect(
|
|
64
|
-
useCallback(() => {
|
|
65
|
-
fetchNotifications(1);
|
|
66
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
67
|
-
}, [])
|
|
68
|
-
);
|
|
69
|
-
|
|
70
62
|
const handleOnLoadMore = useCallback(() => {
|
|
71
|
-
|
|
72
|
-
if (page
|
|
73
|
-
fetchNotifications(page);
|
|
63
|
+
setPage((preState) => preState + 1);
|
|
64
|
+
if (page < maxPageNotification) {
|
|
65
|
+
fetchNotifications(page + 1);
|
|
74
66
|
}
|
|
75
|
-
}, [maxPageNotification, fetchNotifications]);
|
|
67
|
+
}, [page, maxPageNotification, fetchNotifications]);
|
|
76
68
|
|
|
77
69
|
const onRefresh = useCallback(async () => {
|
|
78
|
-
|
|
70
|
+
setPage(1);
|
|
79
71
|
const { success, data } = await axiosGet(
|
|
80
72
|
API.NOTIFICATION.LIST_EOH_NOTIFICATIONS(1, '')
|
|
81
73
|
);
|
|
82
74
|
if (success) {
|
|
83
75
|
setNotifications(data.results);
|
|
76
|
+
setMaxPageNotification(Math.ceil(data.count / 10));
|
|
84
77
|
}
|
|
85
78
|
}, []);
|
|
86
79
|
|
|
@@ -91,6 +84,13 @@ const Notification = memo(() => {
|
|
|
91
84
|
return () => unwatchNotificationData(user);
|
|
92
85
|
}, [user, onRefresh]);
|
|
93
86
|
|
|
87
|
+
useFocusEffect(
|
|
88
|
+
useCallback(() => {
|
|
89
|
+
onRefresh();
|
|
90
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
+
}, [])
|
|
92
|
+
);
|
|
93
|
+
|
|
94
94
|
return (
|
|
95
95
|
<View style={styles.wrap}>
|
|
96
96
|
<WrapHeaderScrollable
|
|
@@ -9,11 +9,7 @@ import ScriptDetail from '..';
|
|
|
9
9
|
import MenuActionMore from '../../../commons/MenuActionMore';
|
|
10
10
|
import AlertAction from '../../../commons/AlertAction';
|
|
11
11
|
import _TextInput from '../../../commons/Form/TextInput';
|
|
12
|
-
import {
|
|
13
|
-
AUTOMATE_SELECT,
|
|
14
|
-
AUTOMATE_TYPE,
|
|
15
|
-
AccessibilityLabel,
|
|
16
|
-
} from '../../../configs/Constants';
|
|
12
|
+
import { AUTOMATE_TYPE, AccessibilityLabel } from '../../../configs/Constants';
|
|
17
13
|
import { API } from '../../../configs';
|
|
18
14
|
import { TouchableOpacity } from 'react-native';
|
|
19
15
|
import Routes from '../../../utils/Route';
|
|
@@ -223,12 +219,10 @@ describe('Test ScriptDetail', () => {
|
|
|
223
219
|
await act(async () => {
|
|
224
220
|
await button.props.onPress();
|
|
225
221
|
});
|
|
226
|
-
expect(mockNavigate).toHaveBeenCalledWith(Routes.
|
|
222
|
+
expect(mockNavigate).toHaveBeenCalledWith(Routes.SelectControlDevices, {
|
|
227
223
|
unit: route.params.unit,
|
|
228
224
|
automateId: route.params.id,
|
|
229
|
-
isCreateNewAction: true,
|
|
230
225
|
scriptName: route.params.name,
|
|
231
|
-
title: AUTOMATE_SELECT.SELECT_DEVICE,
|
|
232
226
|
type: AUTOMATE_TYPE.ONE_TAP,
|
|
233
227
|
oldType: AUTOMATE_TYPE.ONE_TAP,
|
|
234
228
|
automate: route.params.automate,
|
|
@@ -34,16 +34,13 @@ import Routes from '../../utils/Route';
|
|
|
34
34
|
import { ToastBottomHelper } from '../../utils/Utils';
|
|
35
35
|
import ItemAutomate from '../../commons/Automate/ItemAutomate';
|
|
36
36
|
import withPreventDoubleClick from '../../commons/WithPreventDoubleClick';
|
|
37
|
-
import {
|
|
38
|
-
AUTOMATE_SELECT,
|
|
39
|
-
AUTOMATE_TYPE,
|
|
40
|
-
STATE_VALUE_SENSOR_TYPES,
|
|
41
|
-
} from '../../configs/Constants';
|
|
37
|
+
import { AUTOMATE_TYPE } from '../../configs/Constants';
|
|
42
38
|
import { popAction } from '../../navigations/utils';
|
|
43
39
|
import { AccessibilityLabel } from '../../configs/Constants';
|
|
44
40
|
import useKeyboardAnimated from '../../hooks/Explore/useKeyboardAnimated';
|
|
45
|
-
import { REPEAT_OPTIONS } from '../SetSchedule/components/RepeatOptionsPopup';
|
|
46
41
|
import { useSCContextSelector } from '../../context';
|
|
42
|
+
import { useGetEvaluateValue } from '../Device/hooks/useEvaluateValue';
|
|
43
|
+
import { generateAutomationConditionText } from './utils';
|
|
47
44
|
|
|
48
45
|
const PreventDoubleTouch = withPreventDoubleClick(TouchableOpacity);
|
|
49
46
|
|
|
@@ -67,6 +64,7 @@ const ScriptDetail = ({ route }) => {
|
|
|
67
64
|
isCreateNewAction,
|
|
68
65
|
isMultiUnits,
|
|
69
66
|
} = params;
|
|
67
|
+
const valueEvaluation = useGetEvaluateValue(automate?.config_id);
|
|
70
68
|
const [scriptName, setScriptName] = useState(name);
|
|
71
69
|
const [inputName, setInputName] = useState(name);
|
|
72
70
|
const [
|
|
@@ -203,12 +201,10 @@ const ScriptDetail = ({ route }) => {
|
|
|
203
201
|
automateId: id,
|
|
204
202
|
type,
|
|
205
203
|
oldType: type,
|
|
206
|
-
isCreateNewAction: true,
|
|
207
|
-
title: AUTOMATE_SELECT.SELECT_DEVICE,
|
|
208
204
|
automate,
|
|
209
205
|
};
|
|
210
206
|
navigate(
|
|
211
|
-
isMultiUnits ? Routes.SelectUnit : Routes.
|
|
207
|
+
isMultiUnits ? Routes.SelectUnit : Routes.SelectControlDevices,
|
|
212
208
|
navParams
|
|
213
209
|
);
|
|
214
210
|
}, [unit, scriptName, id, type, navigate, isMultiUnits, automate]);
|
|
@@ -356,85 +352,10 @@ const ScriptDetail = ({ route }) => {
|
|
|
356
352
|
|
|
357
353
|
const isHaveScriptActions = data?.length > 0;
|
|
358
354
|
|
|
359
|
-
const textCondition = useMemo(
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
const { condition, config_name, value, sensor_type } =
|
|
364
|
-
automate?.value_change || automate?.event_sensor;
|
|
365
|
-
const stateConditionData = STATE_VALUE_SENSOR_TYPES.find(
|
|
366
|
-
(i) => i.type === sensor_type
|
|
367
|
-
);
|
|
368
|
-
const isNumberValue = !stateConditionData;
|
|
369
|
-
|
|
370
|
-
let text;
|
|
371
|
-
if (condition === '>') {
|
|
372
|
-
text = 'higher_than';
|
|
373
|
-
} else if (condition === '<') {
|
|
374
|
-
text = 'lower_than';
|
|
375
|
-
} else if (condition === '=') {
|
|
376
|
-
text = isNumberValue ? 'equal' : stateConditionData?.stateValue[value];
|
|
377
|
-
}
|
|
378
|
-
return `${config_name} ${t(text)} ${isNumberValue ? value : ''}`;
|
|
379
|
-
} else if (type === AUTOMATE_TYPE.SCHEDULE) {
|
|
380
|
-
const { repeat, time_repeat, date_repeat, weekday_repeat } =
|
|
381
|
-
automate?.schedule;
|
|
382
|
-
const time =
|
|
383
|
-
time_repeat?.length >= 8
|
|
384
|
-
? time_repeat.substring(0, time_repeat?.length - 3)
|
|
385
|
-
: time_repeat;
|
|
386
|
-
const date = date_repeat?.split('-').reverse().join('/');
|
|
387
|
-
const weekday = {
|
|
388
|
-
1: t('mon'),
|
|
389
|
-
2: t('tue'),
|
|
390
|
-
3: t('wed'),
|
|
391
|
-
4: t('thu'),
|
|
392
|
-
5: t('fri'),
|
|
393
|
-
6: t('sat'),
|
|
394
|
-
0: t('sun'),
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
if (repeat === REPEAT_OPTIONS.ONCE) {
|
|
398
|
-
return `${time} ${date}`;
|
|
399
|
-
} else if (repeat === REPEAT_OPTIONS.EVERYDAY) {
|
|
400
|
-
return `${t('every_day_at', { time })}`;
|
|
401
|
-
} else if (repeat === REPEAT_OPTIONS.EVERYWEEK) {
|
|
402
|
-
//sort 0 is last number, exp: [1,3,5,0]
|
|
403
|
-
const newWeekdayRepeat = weekday_repeat.map((item) =>
|
|
404
|
-
parseInt(item, 10)
|
|
405
|
-
);
|
|
406
|
-
const sortWeekday = newWeekdayRepeat.sort((a, b) => {
|
|
407
|
-
if (a !== 0 && b === 0) {
|
|
408
|
-
return -1;
|
|
409
|
-
}
|
|
410
|
-
if (a === 0 && b !== 0) {
|
|
411
|
-
return 1;
|
|
412
|
-
}
|
|
413
|
-
return a - b;
|
|
414
|
-
});
|
|
415
|
-
const textWeekday = sortWeekday.map((item) => weekday[item]).join(', ');
|
|
416
|
-
return `${textWeekday} ${t('at')} ${time}`;
|
|
417
|
-
}
|
|
418
|
-
} else if (
|
|
419
|
-
[AUTOMATE_TYPE.EVENT, AUTOMATE_TYPE.EVENT_ACTION].includes(type)
|
|
420
|
-
) {
|
|
421
|
-
const { action, end_device_name, config_name, sensor_type, value } =
|
|
422
|
-
automate?.event || automate?.event_action || automate?.event_sensor;
|
|
423
|
-
let textEvent = '';
|
|
424
|
-
if (config_name) {
|
|
425
|
-
const stateConditionData = STATE_VALUE_SENSOR_TYPES.find(
|
|
426
|
-
(i) => i.type === sensor_type
|
|
427
|
-
);
|
|
428
|
-
textEvent = `${config_name} - ${t(
|
|
429
|
-
stateConditionData.stateValue[value]
|
|
430
|
-
)}`;
|
|
431
|
-
} else {
|
|
432
|
-
textEvent = `${end_device_name} - ${action}`;
|
|
433
|
-
}
|
|
434
|
-
return textEvent;
|
|
435
|
-
}
|
|
436
|
-
return null;
|
|
437
|
-
}, [t, automate, type]);
|
|
355
|
+
const textCondition = useMemo(
|
|
356
|
+
() => generateAutomationConditionText(type, automate, valueEvaluation, t),
|
|
357
|
+
[type, automate, valueEvaluation, t]
|
|
358
|
+
);
|
|
438
359
|
|
|
439
360
|
return (
|
|
440
361
|
<View style={styles.wrap}>
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { AUTOMATE_TYPE } from '../../configs/Constants';
|
|
2
|
+
import { REPEAT_OPTIONS } from '../SetSchedule/components/RepeatOptionsPopup';
|
|
3
|
+
|
|
4
|
+
export const generateAutomationDataConditionText = (
|
|
5
|
+
type,
|
|
6
|
+
automateData,
|
|
7
|
+
valueEvaluation,
|
|
8
|
+
t
|
|
9
|
+
) => {
|
|
10
|
+
let automate = {
|
|
11
|
+
...automateData,
|
|
12
|
+
config_name: automateData.name,
|
|
13
|
+
};
|
|
14
|
+
if ([AUTOMATE_TYPE.VALUE_CHANGE, AUTOMATE_TYPE.EVENT_SENSOR].includes(type)) {
|
|
15
|
+
automate = { value_change: automate };
|
|
16
|
+
} else if (type === AUTOMATE_TYPE.SCHEDULE) {
|
|
17
|
+
automate = { schedule: automate };
|
|
18
|
+
} else if ([AUTOMATE_TYPE.EVENT, AUTOMATE_TYPE.EVENT_ACTION].includes(type)) {
|
|
19
|
+
automate = { event: automate };
|
|
20
|
+
}
|
|
21
|
+
return generateAutomationConditionText(type, automate, valueEvaluation, t);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const getAutomationData = (type, automate) => {
|
|
25
|
+
if ([AUTOMATE_TYPE.VALUE_CHANGE, AUTOMATE_TYPE.EVENT_SENSOR].includes(type)) {
|
|
26
|
+
return automate?.value_change || automate?.event_sensor;
|
|
27
|
+
} else if (type === AUTOMATE_TYPE.SCHEDULE) {
|
|
28
|
+
return automate?.schedule;
|
|
29
|
+
} else if ([AUTOMATE_TYPE.EVENT, AUTOMATE_TYPE.EVENT_ACTION].includes(type)) {
|
|
30
|
+
return automate?.event || automate?.event_action || automate?.event_sensor;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const generateAutomationConditionText = (
|
|
36
|
+
type,
|
|
37
|
+
automate,
|
|
38
|
+
valueEvaluation,
|
|
39
|
+
t
|
|
40
|
+
) => {
|
|
41
|
+
if ([AUTOMATE_TYPE.VALUE_CHANGE, AUTOMATE_TYPE.EVENT_SENSOR].includes(type)) {
|
|
42
|
+
const { condition, config_name, value } =
|
|
43
|
+
automate?.value_change || automate?.event_sensor;
|
|
44
|
+
|
|
45
|
+
if (condition === 'value_evaluation' && valueEvaluation) {
|
|
46
|
+
return `${config_name} ${t('is')} ${
|
|
47
|
+
valueEvaluation.configuration.ranges[value]?.evaluate.text
|
|
48
|
+
}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let text;
|
|
52
|
+
if (condition === '>') {
|
|
53
|
+
text = 'higher_than';
|
|
54
|
+
} else if (condition === '<') {
|
|
55
|
+
text = 'lower_than';
|
|
56
|
+
} else if (condition === '=') {
|
|
57
|
+
text = 'equal';
|
|
58
|
+
}
|
|
59
|
+
return `${config_name} ${t(text)} ${value}`;
|
|
60
|
+
} else if (type === AUTOMATE_TYPE.SCHEDULE) {
|
|
61
|
+
const { repeat, time_repeat, date_repeat, weekday_repeat } =
|
|
62
|
+
automate?.schedule;
|
|
63
|
+
const time =
|
|
64
|
+
time_repeat?.length >= 8
|
|
65
|
+
? time_repeat.substring(0, time_repeat?.length - 3)
|
|
66
|
+
: time_repeat;
|
|
67
|
+
const date = date_repeat?.split('-').reverse().join('/');
|
|
68
|
+
const weekday = {
|
|
69
|
+
1: t('mon'),
|
|
70
|
+
2: t('tue'),
|
|
71
|
+
3: t('wed'),
|
|
72
|
+
4: t('thu'),
|
|
73
|
+
5: t('fri'),
|
|
74
|
+
6: t('sat'),
|
|
75
|
+
0: t('sun'),
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
if (repeat === REPEAT_OPTIONS.ONCE) {
|
|
79
|
+
return `${time} ${date}`;
|
|
80
|
+
} else if (repeat === REPEAT_OPTIONS.EVERYDAY) {
|
|
81
|
+
return `${t('every_day_at', { time })}`;
|
|
82
|
+
} else if (repeat === REPEAT_OPTIONS.EVERYWEEK) {
|
|
83
|
+
//sort 0 is last number, exp: [1,3,5,0]
|
|
84
|
+
const newWeekdayRepeat = weekday_repeat.map((item) => parseInt(item, 10));
|
|
85
|
+
const sortWeekday = newWeekdayRepeat.sort((a, b) => {
|
|
86
|
+
if (a !== 0 && b === 0) {
|
|
87
|
+
return -1;
|
|
88
|
+
}
|
|
89
|
+
if (a === 0 && b !== 0) {
|
|
90
|
+
return 1;
|
|
91
|
+
}
|
|
92
|
+
return a - b;
|
|
93
|
+
});
|
|
94
|
+
const textWeekday = sortWeekday.map((item) => weekday[item]).join(', ');
|
|
95
|
+
return `${textWeekday} ${t('at')} ${time}`;
|
|
96
|
+
}
|
|
97
|
+
} else if ([AUTOMATE_TYPE.EVENT, AUTOMATE_TYPE.EVENT_ACTION].includes(type)) {
|
|
98
|
+
const { action, end_device_name, config_name, value } =
|
|
99
|
+
automate?.event || automate?.event_action || automate?.event_sensor;
|
|
100
|
+
let textEvent = '';
|
|
101
|
+
if (config_name) {
|
|
102
|
+
const stateConditionData = null;
|
|
103
|
+
textEvent = `${config_name} - ${t(
|
|
104
|
+
stateConditionData?.stateValue[value]
|
|
105
|
+
)}`;
|
|
106
|
+
} else {
|
|
107
|
+
textEvent = `${end_device_name} - ${action}`;
|
|
108
|
+
}
|
|
109
|
+
return textEvent;
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
};
|
|
@@ -59,7 +59,6 @@ describe('Test Select unit screen', () => {
|
|
|
59
59
|
isAutomateTab: true,
|
|
60
60
|
isMultiUnits: true,
|
|
61
61
|
routeName: 'test',
|
|
62
|
-
isCreateNewAction: false,
|
|
63
62
|
},
|
|
64
63
|
});
|
|
65
64
|
const response = {
|
|
@@ -96,7 +95,6 @@ describe('Test Select unit screen', () => {
|
|
|
96
95
|
isAutomateTab: true,
|
|
97
96
|
isMultiUnits: true,
|
|
98
97
|
routeName: 'test',
|
|
99
|
-
isCreateNewAction: false,
|
|
100
98
|
},
|
|
101
99
|
});
|
|
102
100
|
|
|
@@ -119,7 +117,6 @@ describe('Test Select unit screen', () => {
|
|
|
119
117
|
useRoute.mockReturnValue({
|
|
120
118
|
params: {
|
|
121
119
|
automateId: 1,
|
|
122
|
-
isCreateNewAction: true,
|
|
123
120
|
scriptName: '1',
|
|
124
121
|
title: 'select_device',
|
|
125
122
|
type: 'value_change',
|
|
@@ -162,7 +159,6 @@ describe('Test Select unit screen', () => {
|
|
|
162
159
|
useRoute.mockReturnValue({
|
|
163
160
|
params: {
|
|
164
161
|
automateId: 1,
|
|
165
|
-
isCreateNewAction: true,
|
|
166
162
|
scriptName: '1',
|
|
167
163
|
title: 'select_device',
|
|
168
164
|
type: 'value_change',
|
|
@@ -189,7 +185,6 @@ describe('Test Select unit screen', () => {
|
|
|
189
185
|
expect(mockNavigate).toBeCalledWith(Routes.ScriptDetail, {
|
|
190
186
|
id: 1,
|
|
191
187
|
havePermission: true,
|
|
192
|
-
isCreateNewAction: true,
|
|
193
188
|
isMultiUnits: undefined,
|
|
194
189
|
name: '1',
|
|
195
190
|
type: undefined,
|
|
@@ -67,11 +67,10 @@ const SelectUnit = () => {
|
|
|
67
67
|
|
|
68
68
|
const onContinue = useCallback(() => {
|
|
69
69
|
navigate(
|
|
70
|
-
isCreateNewAction || !routeName ? Routes.
|
|
70
|
+
isCreateNewAction || !routeName ? Routes.SelectMonitorDevices : routeName,
|
|
71
71
|
{
|
|
72
72
|
...params,
|
|
73
73
|
automate,
|
|
74
|
-
title,
|
|
75
74
|
selectedItem,
|
|
76
75
|
type,
|
|
77
76
|
isAutomateTab,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { View, Text } from 'react-native';
|
|
3
3
|
import { CheckBoxCustom } from '.';
|
|
4
4
|
import t from '../../../hooks/Common/useTranslations';
|
|
@@ -48,4 +48,4 @@ const TitleCheckBox = ({
|
|
|
48
48
|
);
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
export default
|
|
51
|
+
export default TitleCheckBox;
|
package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js
CHANGED
|
@@ -86,7 +86,7 @@ describe('Test SuccessfullyConnected', () => {
|
|
|
86
86
|
],
|
|
87
87
|
});
|
|
88
88
|
await act(async () => {
|
|
89
|
-
tree = renderer.create(wrapComponent(route));
|
|
89
|
+
tree = await renderer.create(wrapComponent(route));
|
|
90
90
|
});
|
|
91
91
|
await flushPromises();
|
|
92
92
|
const instance = tree.root;
|
|
@@ -101,7 +101,7 @@ describe('Test SuccessfullyConnected', () => {
|
|
|
101
101
|
|
|
102
102
|
it('render function handleContinue ', async () => {
|
|
103
103
|
await act(async () => {
|
|
104
|
-
tree = renderer.create(wrapComponent(route));
|
|
104
|
+
tree = await renderer.create(wrapComponent(route));
|
|
105
105
|
});
|
|
106
106
|
const instance = tree.root;
|
|
107
107
|
const handleContinue = instance.find(
|
|
@@ -123,7 +123,7 @@ describe('Test SuccessfullyConnected', () => {
|
|
|
123
123
|
});
|
|
124
124
|
it('render function handleFinish ', async () => {
|
|
125
125
|
await act(async () => {
|
|
126
|
-
tree = renderer.create(wrapComponent(route));
|
|
126
|
+
tree = await renderer.create(wrapComponent(route));
|
|
127
127
|
});
|
|
128
128
|
const instance = tree.root;
|
|
129
129
|
|
|
@@ -44,7 +44,7 @@ describe('Test Connecting', () => {
|
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
46
|
await act(async () => {
|
|
47
|
-
tree = renderer.create(wrapComponent(route));
|
|
47
|
+
tree = await renderer.create(wrapComponent(route));
|
|
48
48
|
});
|
|
49
49
|
const instance = tree.root;
|
|
50
50
|
const texts = instance.findAllByType(Text);
|