@eohjsc/react-native-smart-city 0.2.96 → 0.2.99
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/README.md +35 -14
- package/package.json +16 -4
- package/src/commons/Action/ItemQuickAction.js +5 -2
- package/src/commons/ActionGroup/ColorPickerTemplate.js +1 -1
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +12 -4
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +7 -4
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +1 -0
- package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
- package/src/commons/ActionGroup/OnOffTemplate/index.js +18 -15
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +8 -2
- package/src/commons/ActionGroup/SliderRangeTemplate.js +1 -1
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +4 -1
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +14 -4
- package/src/commons/ActionGroup/TimerActionTemplate.js +9 -1
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +13 -9
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +53 -78
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +36 -20
- package/src/commons/Auth/AccountList.js +1 -1
- package/src/commons/{Connecting → Connecting}/__test__/Connecting.test.js +0 -0
- package/src/commons/{Connecting → Connecting}/index.js +0 -0
- package/src/commons/{Connecting → Connecting}/styles.js +0 -0
- package/src/commons/ConnectingProcess/index.js +1 -1
- package/src/commons/Device/HistoryChart.js +6 -2
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
- package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
- package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +25 -0
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +96 -0
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +39 -0
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +113 -0
- package/src/commons/FieldTemplate/ChooseUserField/index.js +62 -0
- package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +30 -0
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +93 -0
- package/src/commons/FieldTemplate/PasscodeField/index.js +43 -0
- package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +13 -0
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +182 -0
- package/src/commons/FieldTemplate/ScheduleField/index.js +176 -0
- package/src/commons/FullLoading/index.js +2 -1
- package/src/commons/MenuActionAddnew/index.js +1 -0
- package/src/commons/MenuActionList/index.js +1 -0
- package/src/commons/MenuActionMore/index.js +1 -1
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +62 -0
- package/src/commons/PreventAccess/index.js +67 -0
- package/src/commons/PreventAccess/styles.js +33 -0
- package/src/commons/WheelDateTimePicker/index.js +2 -1
- package/src/configs/API.js +3 -0
- package/src/configs/Constants.js +16 -1
- package/src/iot/RemoteControl/GoogleHome.js +24 -11
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +32 -0
- package/src/navigations/UnitStack.js +8 -0
- package/src/screens/AQIGuide/index.js +1 -1
- package/src/screens/ActivityLog/FilterPopup.js +2 -0
- package/src/screens/AddCommon/SelectSubUnit.js +1 -0
- package/src/screens/AddCommon/SelectUnit.js +1 -0
- package/src/screens/AddLocationMaps/index.js +4 -1
- package/src/screens/AddNewAction/SelectSensorDevices.js +14 -3
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +34 -92
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
- package/src/screens/AddNewAutoSmart/index.js +5 -2
- package/src/screens/AddNewDevice/index.js +1 -0
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +4 -1
- package/src/screens/AddNewGateway/SelectGateway.js +1 -0
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +1 -0
- package/src/screens/AddNewGateway/index.js +1 -0
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +1 -1
- package/src/screens/AddNewOneTap/index.js +3 -2
- package/src/screens/Automate/index.js +2 -0
- package/src/screens/Device/__test__/detail.test.js +4 -4
- package/src/screens/Device/detail.js +44 -6
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +5 -2
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +14 -0
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +19 -1
- package/src/screens/EmergencySetting/index.js +4 -1
- package/src/screens/Explore/index.js +2 -0
- package/src/screens/GuestInfo/__test__/index.test.js +1 -1
- package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
- package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
- package/src/screens/ManageAccess/index.js +1 -0
- package/src/screens/MoveToAnotherSubUnit/index.js +1 -1
- package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
- package/src/screens/ScriptDetail/index.js +3 -3
- package/src/screens/SelectUnit/__test__/index.test.js +1 -1
- package/src/screens/SelectUnit/index.js +5 -2
- package/src/screens/SetSchedule/index.js +6 -2
- package/src/screens/SharedUnit/index.js +2 -0
- package/src/screens/Sharing/MemberList.js +12 -11
- package/src/screens/Sharing/SelectPermission.js +1 -1
- package/src/screens/Sharing/hooks/index.js +3 -0
- package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
- package/src/screens/SideMenuDetail/__test__/index.test.js +165 -0
- package/src/screens/SideMenuDetail/index.js +149 -0
- package/src/screens/SmartIr/components/SelectBrand.js +1 -1
- package/src/screens/SubUnit/ManageSubUnit.js +1 -0
- package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
- package/src/screens/TDSGuide/index.js +4 -1
- package/src/screens/UVIndexGuide/index.js +1 -1
- package/src/screens/Unit/Detail.js +18 -5
- package/src/screens/Unit/SelectAddress.js +4 -1
- package/src/screens/Unit/Station/index.js +1 -0
- package/src/screens/Unit/Summaries.js +1 -1
- package/src/screens/Unit/__test__/Detail.test.js +25 -5
- package/src/screens/UnitSummary/__test__/index.test.js +32 -0
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +1 -1
- package/src/screens/WaterQualityGuide/index.js +1 -1
- package/src/utils/I18n/translations/en.json +5 -1
- package/src/utils/I18n/translations/vi.json +5 -1
- package/src/utils/Route/index.js +1 -0
|
@@ -1,11 +1,25 @@
|
|
|
1
|
+
/* eslint-disable promise/prefer-await-to-callbacks */
|
|
1
2
|
import { TESTID } from '../../../configs/Constants';
|
|
2
3
|
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
3
4
|
import React from 'react';
|
|
4
5
|
import { View } from 'react-native';
|
|
6
|
+
import { useSelector } from 'react-redux';
|
|
5
7
|
import { act, create } from 'react-test-renderer';
|
|
6
8
|
import OnOffTemplate from '../OnOffTemplate';
|
|
7
9
|
import OnOffButtonTemplate from '../OnOffTemplate/OnOffButtonTemplate';
|
|
8
10
|
import OnOffSimpleTemplate from '../OnOffTemplate/OnOffSimpleTemplate';
|
|
11
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
12
|
+
import { SCProvider } from '../../../context';
|
|
13
|
+
|
|
14
|
+
const wrapComponent = (actionGroup, mockDoAction, sensor) => (
|
|
15
|
+
<SCProvider initState={mockSCStore({})}>
|
|
16
|
+
<OnOffTemplate
|
|
17
|
+
actionGroup={actionGroup}
|
|
18
|
+
doAction={mockDoAction}
|
|
19
|
+
sensor={sensor}
|
|
20
|
+
/>
|
|
21
|
+
</SCProvider>
|
|
22
|
+
);
|
|
9
23
|
|
|
10
24
|
jest.mock('../../../iot/Monitor');
|
|
11
25
|
|
|
@@ -13,9 +27,15 @@ jest.mock('../../../iot/states', () => ({
|
|
|
13
27
|
useConfigGlobalState: () => [{ 5: 2 }, null],
|
|
14
28
|
}));
|
|
15
29
|
|
|
30
|
+
jest.mock('react-redux', () => ({
|
|
31
|
+
...jest.requireActual('react-redux'),
|
|
32
|
+
useSelector: jest.fn(),
|
|
33
|
+
}));
|
|
34
|
+
|
|
16
35
|
describe('Test OnOffTemplate', () => {
|
|
17
|
-
let wrapper;
|
|
18
36
|
let actionGroup;
|
|
37
|
+
let tree;
|
|
38
|
+
let sensor;
|
|
19
39
|
|
|
20
40
|
const action_data = {
|
|
21
41
|
color: '#00979D',
|
|
@@ -62,20 +82,23 @@ describe('Test OnOffTemplate', () => {
|
|
|
62
82
|
},
|
|
63
83
|
title: 'Turn on / off',
|
|
64
84
|
};
|
|
85
|
+
|
|
86
|
+
sensor = { name: 'Sensor' };
|
|
87
|
+
|
|
88
|
+
const localState = {
|
|
89
|
+
isOnSwich: false,
|
|
90
|
+
};
|
|
91
|
+
useSelector.mockImplementation((cb) => {
|
|
92
|
+
return cb(localState);
|
|
93
|
+
});
|
|
65
94
|
});
|
|
66
95
|
|
|
67
96
|
test('render with template OnOffSimpleActionTemplate', async () => {
|
|
68
97
|
const mockDoAction = jest.fn();
|
|
69
98
|
await act(async () => {
|
|
70
|
-
|
|
71
|
-
<OnOffTemplate
|
|
72
|
-
actionGroup={actionGroup}
|
|
73
|
-
doAction={mockDoAction}
|
|
74
|
-
sensor={{}}
|
|
75
|
-
/>
|
|
76
|
-
);
|
|
99
|
+
tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
|
|
77
100
|
});
|
|
78
|
-
const instance =
|
|
101
|
+
const instance = tree.root;
|
|
79
102
|
const template = instance.findAllByType(OnOffSimpleTemplate);
|
|
80
103
|
expect(template).toHaveLength(1);
|
|
81
104
|
});
|
|
@@ -84,15 +107,9 @@ describe('Test OnOffTemplate', () => {
|
|
|
84
107
|
actionGroup.template = 'on_off_button_action_template';
|
|
85
108
|
const mockDoAction = jest.fn();
|
|
86
109
|
await act(async () => {
|
|
87
|
-
|
|
88
|
-
<OnOffTemplate
|
|
89
|
-
actionGroup={actionGroup}
|
|
90
|
-
doAction={mockDoAction}
|
|
91
|
-
sensor={{}}
|
|
92
|
-
/>
|
|
93
|
-
);
|
|
110
|
+
tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
|
|
94
111
|
});
|
|
95
|
-
const instance =
|
|
112
|
+
const instance = tree.root;
|
|
96
113
|
const template = instance.findAllByType(OnOffButtonTemplate);
|
|
97
114
|
expect(template).toHaveLength(0);
|
|
98
115
|
});
|
|
@@ -101,15 +118,9 @@ describe('Test OnOffTemplate', () => {
|
|
|
101
118
|
actionGroup.template = 'wrong_template';
|
|
102
119
|
const mockDoAction = jest.fn();
|
|
103
120
|
await act(async () => {
|
|
104
|
-
|
|
105
|
-
<OnOffTemplate
|
|
106
|
-
actionGroup={actionGroup}
|
|
107
|
-
doAction={mockDoAction}
|
|
108
|
-
sensor={{}}
|
|
109
|
-
/>
|
|
110
|
-
);
|
|
121
|
+
tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
|
|
111
122
|
});
|
|
112
|
-
const instance =
|
|
123
|
+
const instance = tree.root;
|
|
113
124
|
|
|
114
125
|
const templateOnOffButton = instance.findAll(
|
|
115
126
|
(el) =>
|
|
@@ -125,32 +136,20 @@ describe('Test OnOffTemplate', () => {
|
|
|
125
136
|
test('render with template OnOffSimpleActionTemplate with is_managed_by_backend', async () => {
|
|
126
137
|
const mockDoAction = jest.fn();
|
|
127
138
|
await act(async () => {
|
|
128
|
-
|
|
129
|
-
<OnOffTemplate
|
|
130
|
-
actionGroup={actionGroup}
|
|
131
|
-
doAction={mockDoAction}
|
|
132
|
-
sensor={{ is_managed_by_backend: true }}
|
|
133
|
-
/>
|
|
134
|
-
);
|
|
139
|
+
tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
|
|
135
140
|
});
|
|
136
|
-
const instance =
|
|
141
|
+
const instance = tree.root;
|
|
137
142
|
const template = instance.findAllByType(OnOffSimpleTemplate);
|
|
138
143
|
expect(template).toHaveLength(1);
|
|
139
|
-
expect(watchMultiConfigs).toBeCalledTimes(
|
|
144
|
+
expect(watchMultiConfigs).toBeCalledTimes(0);
|
|
140
145
|
});
|
|
141
146
|
|
|
142
147
|
test('template OnOffSimpleActionTemplate doAction with is_on_value, match configValue', async () => {
|
|
143
148
|
const mockDoAction = jest.fn();
|
|
144
149
|
await act(async () => {
|
|
145
|
-
|
|
146
|
-
<OnOffTemplate
|
|
147
|
-
actionGroup={actionGroup}
|
|
148
|
-
doAction={mockDoAction}
|
|
149
|
-
sensor={{ name: 'Sensor name' }}
|
|
150
|
-
/>
|
|
151
|
-
);
|
|
150
|
+
tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
152
151
|
});
|
|
153
|
-
const instance =
|
|
152
|
+
const instance = tree.root;
|
|
154
153
|
const template = instance.findByType(OnOffSimpleTemplate);
|
|
155
154
|
expect(template.props.isOn).toEqual(true);
|
|
156
155
|
|
|
@@ -160,7 +159,7 @@ describe('Test OnOffTemplate', () => {
|
|
|
160
159
|
expect(mockDoAction).toHaveBeenCalledWith(
|
|
161
160
|
action_off_data,
|
|
162
161
|
null,
|
|
163
|
-
'Sensor
|
|
162
|
+
'Sensor turn on / off off'
|
|
164
163
|
);
|
|
165
164
|
expect(watchMultiConfigs).toBeCalledTimes(0);
|
|
166
165
|
});
|
|
@@ -169,15 +168,9 @@ describe('Test OnOffTemplate', () => {
|
|
|
169
168
|
actionGroup.configuration.is_on_value = [1];
|
|
170
169
|
const mockDoAction = jest.fn();
|
|
171
170
|
await act(async () => {
|
|
172
|
-
|
|
173
|
-
<OnOffTemplate
|
|
174
|
-
actionGroup={actionGroup}
|
|
175
|
-
doAction={mockDoAction}
|
|
176
|
-
sensor={{ name: 'Sensor name' }}
|
|
177
|
-
/>
|
|
178
|
-
);
|
|
171
|
+
tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
179
172
|
});
|
|
180
|
-
const instance =
|
|
173
|
+
const instance = tree.root;
|
|
181
174
|
const template = instance.findByType(OnOffSimpleTemplate);
|
|
182
175
|
expect(template.props.isOn).toEqual(false);
|
|
183
176
|
|
|
@@ -187,22 +180,16 @@ describe('Test OnOffTemplate', () => {
|
|
|
187
180
|
expect(mockDoAction).toHaveBeenCalledWith(
|
|
188
181
|
action_on_data,
|
|
189
182
|
null,
|
|
190
|
-
'Sensor
|
|
183
|
+
'Sensor turn on / off on'
|
|
191
184
|
);
|
|
192
185
|
});
|
|
193
186
|
|
|
194
187
|
test('template OnOffSimpleActionTemplate doAction with is_on_value and is_managed_by_backend', async () => {
|
|
195
188
|
const mockDoAction = jest.fn();
|
|
196
189
|
await act(async () => {
|
|
197
|
-
|
|
198
|
-
<OnOffTemplate
|
|
199
|
-
actionGroup={actionGroup}
|
|
200
|
-
doAction={mockDoAction}
|
|
201
|
-
sensor={{ name: 'Sensor name', is_managed_by_backend: true }}
|
|
202
|
-
/>
|
|
203
|
-
);
|
|
190
|
+
tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
204
191
|
});
|
|
205
|
-
const instance =
|
|
192
|
+
const instance = tree.root;
|
|
206
193
|
const template = instance.findByType(OnOffSimpleTemplate);
|
|
207
194
|
expect(template.props.isOn).toEqual(true);
|
|
208
195
|
|
|
@@ -212,9 +199,9 @@ describe('Test OnOffTemplate', () => {
|
|
|
212
199
|
expect(mockDoAction).toHaveBeenCalledWith(
|
|
213
200
|
action_off_data,
|
|
214
201
|
null,
|
|
215
|
-
'Sensor
|
|
202
|
+
'Sensor turn on / off off'
|
|
216
203
|
);
|
|
217
|
-
expect(watchMultiConfigs).toBeCalledTimes(
|
|
204
|
+
expect(watchMultiConfigs).toBeCalledTimes(0);
|
|
218
205
|
});
|
|
219
206
|
|
|
220
207
|
test('render with template OnOffSimpleActionTemplate with just action_data', async () => {
|
|
@@ -230,15 +217,9 @@ describe('Test OnOffTemplate', () => {
|
|
|
230
217
|
};
|
|
231
218
|
const mockDoAction = jest.fn();
|
|
232
219
|
await act(async () => {
|
|
233
|
-
|
|
234
|
-
<OnOffTemplate
|
|
235
|
-
actionGroup={actionGroup}
|
|
236
|
-
doAction={mockDoAction}
|
|
237
|
-
sensor={{ is_managed_by_backend: true }}
|
|
238
|
-
/>
|
|
239
|
-
);
|
|
220
|
+
tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
|
|
240
221
|
});
|
|
241
|
-
const instance =
|
|
222
|
+
const instance = tree.root;
|
|
242
223
|
const template = instance.findAllByType(OnOffSimpleTemplate);
|
|
243
224
|
expect(template).toHaveLength(1);
|
|
244
225
|
expect(template[0].props.disabled).toBeFalsy();
|
|
@@ -261,15 +242,9 @@ describe('Test OnOffTemplate', () => {
|
|
|
261
242
|
};
|
|
262
243
|
const mockDoAction = jest.fn();
|
|
263
244
|
await act(async () => {
|
|
264
|
-
|
|
265
|
-
<OnOffTemplate
|
|
266
|
-
actionGroup={actionGroup}
|
|
267
|
-
doAction={mockDoAction}
|
|
268
|
-
sensor={{ is_managed_by_backend: true }}
|
|
269
|
-
/>
|
|
270
|
-
);
|
|
245
|
+
tree = await create(wrapComponent(actionGroup, mockDoAction, {}));
|
|
271
246
|
});
|
|
272
|
-
const instance =
|
|
247
|
+
const instance = tree.root;
|
|
273
248
|
const template = instance.findAllByType(OnOffSimpleTemplate);
|
|
274
249
|
expect(template).toHaveLength(1);
|
|
275
250
|
expect(template[0].props.disabled).toBeTruthy();
|
|
@@ -1,8 +1,27 @@
|
|
|
1
|
+
/* eslint-disable promise/prefer-await-to-callbacks */
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { create, act } from 'react-test-renderer';
|
|
3
4
|
import { TouchableOpacity } from 'react-native';
|
|
5
|
+
import { useSelector } from 'react-redux';
|
|
4
6
|
|
|
5
7
|
import OneBigButtonTemplate from '../OneBigButtonTemplate';
|
|
8
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
9
|
+
import { SCProvider } from '../../../context';
|
|
10
|
+
|
|
11
|
+
const wrapComponent = (actionGroup, mockDoAction, sensor) => (
|
|
12
|
+
<SCProvider initState={mockSCStore({})}>
|
|
13
|
+
<OneBigButtonTemplate
|
|
14
|
+
actionGroup={actionGroup}
|
|
15
|
+
doAction={mockDoAction}
|
|
16
|
+
sensor={sensor}
|
|
17
|
+
/>
|
|
18
|
+
</SCProvider>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
jest.mock('react-redux', () => ({
|
|
22
|
+
...jest.requireActual('react-redux'),
|
|
23
|
+
useSelector: jest.fn(),
|
|
24
|
+
}));
|
|
6
25
|
|
|
7
26
|
describe('Test OneBigButtonTemplate', () => {
|
|
8
27
|
const action_data = {
|
|
@@ -23,24 +42,25 @@ describe('Test OneBigButtonTemplate', () => {
|
|
|
23
42
|
text: 'UP',
|
|
24
43
|
},
|
|
25
44
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
let wrapper;
|
|
45
|
+
let tree;
|
|
46
|
+
let sensor;
|
|
30
47
|
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
doAction={mockDoAction}
|
|
38
|
-
sensor={sensor}
|
|
39
|
-
/>
|
|
40
|
-
);
|
|
48
|
+
beforeEach(() => {
|
|
49
|
+
const localState = {
|
|
50
|
+
isOnSwich: false,
|
|
51
|
+
};
|
|
52
|
+
useSelector.mockImplementation((cb) => {
|
|
53
|
+
return cb(localState);
|
|
41
54
|
});
|
|
55
|
+
sensor = { name: 'Sensor' };
|
|
56
|
+
});
|
|
42
57
|
|
|
43
|
-
|
|
58
|
+
test('render OneBigButtonTemplate', async () => {
|
|
59
|
+
const mockDoAction = jest.fn();
|
|
60
|
+
await act(async () => {
|
|
61
|
+
tree = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
62
|
+
});
|
|
63
|
+
const instance = tree.root;
|
|
44
64
|
const buttons = instance.findAllByType(TouchableOpacity);
|
|
45
65
|
expect(buttons.length).toEqual(1);
|
|
46
66
|
|
|
@@ -49,10 +69,6 @@ describe('Test OneBigButtonTemplate', () => {
|
|
|
49
69
|
});
|
|
50
70
|
|
|
51
71
|
expect(mockDoAction).toHaveBeenCalledTimes(1);
|
|
52
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
53
|
-
action_data,
|
|
54
|
-
null,
|
|
55
|
-
'Sensor name up'
|
|
56
|
-
);
|
|
72
|
+
expect(mockDoAction).toHaveBeenCalledWith(action_data, null, 'Sensor up');
|
|
57
73
|
});
|
|
58
74
|
});
|
|
@@ -5,7 +5,7 @@ import AccountItem from './AccountItem';
|
|
|
5
5
|
|
|
6
6
|
const AccountList = ({ accounts }) => {
|
|
7
7
|
return (
|
|
8
|
-
<ScrollView>
|
|
8
|
+
<ScrollView scrollIndicatorInsets={{ right: 1 }}>
|
|
9
9
|
{accounts.map((account) => (
|
|
10
10
|
<AccountItem key={account.id || account.name} account={account} />
|
|
11
11
|
))}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -10,7 +10,7 @@ import { axiosPost } from '../../utils/Apis/axios';
|
|
|
10
10
|
import { API, Colors } from '../../configs';
|
|
11
11
|
import styles from './styles';
|
|
12
12
|
import DeviceItem from './DeviceItem/DeviceItem';
|
|
13
|
-
import Connecting from '../Connecting
|
|
13
|
+
import Connecting from '../Connecting';
|
|
14
14
|
import { useSCContextSelector } from '../../context';
|
|
15
15
|
|
|
16
16
|
const ConnectingProcess = ({ route }) => {
|
|
@@ -234,19 +234,23 @@ const HistoryChart = memo(
|
|
|
234
234
|
)}
|
|
235
235
|
<DateTimePickerModal
|
|
236
236
|
isVisible={eventPicker.showModalStart}
|
|
237
|
-
date={eventPicker.startTime.
|
|
237
|
+
date={eventPicker.startTime.valueOf()}
|
|
238
238
|
mode={formatType || 'datetime'}
|
|
239
239
|
onConfirm={onConfirmStart}
|
|
240
240
|
onCancel={onCancel}
|
|
241
241
|
display="spinner"
|
|
242
|
+
cancelTextIOS={t('cancel')}
|
|
243
|
+
confirmTextIOS={t('confirm')}
|
|
242
244
|
/>
|
|
243
245
|
<DateTimePickerModal
|
|
244
246
|
isVisible={eventPicker.showModalEnd}
|
|
245
|
-
date={eventPicker.endTime.
|
|
247
|
+
date={eventPicker.endTime.valueOf()}
|
|
246
248
|
mode={formatType || 'datetime'}
|
|
247
249
|
onConfirm={onConfirmEnd}
|
|
248
250
|
onCancel={onCancel}
|
|
249
251
|
display="spinner"
|
|
252
|
+
cancelTextIOS={t('cancel')}
|
|
253
|
+
confirmTextIOS={t('confirm')}
|
|
250
254
|
/>
|
|
251
255
|
</View>
|
|
252
256
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { memo, useCallback } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
2
3
|
import { FlatList } from 'react-native';
|
|
3
4
|
import QualityIndicatorItem from '../WaterQualitySensor/QualityIndicatorsItem';
|
|
4
5
|
import styles from './PMSensorIndicatorStyles';
|
|
@@ -26,18 +27,21 @@ const PMSensorIndicatior = memo(({ data, style }) => {
|
|
|
26
27
|
const isScrollMode = data.length > 3;
|
|
27
28
|
|
|
28
29
|
return (
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
<View style={styles.wrap}>
|
|
31
|
+
<FlatList
|
|
32
|
+
bounces={false}
|
|
33
|
+
numColumns={1}
|
|
34
|
+
horizontal={true}
|
|
35
|
+
contentContainerStyle={[
|
|
36
|
+
styles.standard,
|
|
37
|
+
!isScrollMode && styles.centerItem,
|
|
38
|
+
]}
|
|
39
|
+
data={data}
|
|
40
|
+
keyExtractor={keyExtractor}
|
|
41
|
+
renderItem={renderItem}
|
|
42
|
+
scrollIndicatorInsets={{ right: 1 }}
|
|
43
|
+
/>
|
|
44
|
+
</View>
|
|
41
45
|
);
|
|
42
46
|
});
|
|
43
47
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors } from '../../../configs';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
wrapper: {
|
|
6
|
+
flexDirection: 'row',
|
|
7
|
+
paddingTop: 30,
|
|
8
|
+
},
|
|
9
|
+
textHeadLine: {
|
|
10
|
+
fontSize: 16,
|
|
11
|
+
color: Colors.Gray9,
|
|
12
|
+
fontWeight: 'bold',
|
|
13
|
+
},
|
|
14
|
+
buttonValue: {
|
|
15
|
+
flex: 1,
|
|
16
|
+
flexDirection: 'row',
|
|
17
|
+
justifyContent: 'flex-end',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
},
|
|
20
|
+
value: {
|
|
21
|
+
marginRight: 20,
|
|
22
|
+
fontSize: 14,
|
|
23
|
+
color: Colors.Gray8,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React, { useState, useCallback } from 'react';
|
|
2
|
+
import { View, ScrollView, TouchableOpacity } from 'react-native';
|
|
3
|
+
import { Colors } from '../../../configs';
|
|
4
|
+
import { TESTID } from '../../../configs/Constants';
|
|
5
|
+
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
6
|
+
import BottomButtonView from '../../BottomButtonView';
|
|
7
|
+
import { ModalCustom } from '../../Modal';
|
|
8
|
+
import RadioCircle from '../../RadioCircle';
|
|
9
|
+
import Text from '../../Text';
|
|
10
|
+
|
|
11
|
+
import styles from './ChoosePopupStyles';
|
|
12
|
+
|
|
13
|
+
const RowMember = ({ member, isSelected, onSelect }) => {
|
|
14
|
+
const handleOnPress = useCallback(() => {
|
|
15
|
+
onSelect(member);
|
|
16
|
+
}, [onSelect, member]);
|
|
17
|
+
return (
|
|
18
|
+
<TouchableOpacity
|
|
19
|
+
style={styles.row}
|
|
20
|
+
onPress={handleOnPress}
|
|
21
|
+
testID={TESTID.CHOOSE_ITEM}
|
|
22
|
+
>
|
|
23
|
+
<RadioCircle active={isSelected} />
|
|
24
|
+
<View style={styles.wrapText}>
|
|
25
|
+
<Text type="H4" color={Colors.Gray9}>
|
|
26
|
+
{member.name
|
|
27
|
+
? member.name
|
|
28
|
+
: member.phone_number
|
|
29
|
+
? member.phone_number
|
|
30
|
+
: member.email}
|
|
31
|
+
</Text>
|
|
32
|
+
</View>
|
|
33
|
+
</TouchableOpacity>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const ChoosePopup = ({ isVisible, title, onHide, members, onApply }) => {
|
|
38
|
+
const t = useTranslations();
|
|
39
|
+
const [selectedUsers, setSelectedUsers] = useState({});
|
|
40
|
+
|
|
41
|
+
const handleOnSelectUser = useCallback((user) => {
|
|
42
|
+
setSelectedUsers(user);
|
|
43
|
+
}, []);
|
|
44
|
+
|
|
45
|
+
const handleOnApply = useCallback(() => {
|
|
46
|
+
onApply(selectedUsers);
|
|
47
|
+
onHide();
|
|
48
|
+
}, [selectedUsers, onApply, onHide]);
|
|
49
|
+
|
|
50
|
+
const handleOnCancel = useCallback(() => {
|
|
51
|
+
onHide();
|
|
52
|
+
}, [onHide]);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<ModalCustom
|
|
56
|
+
testID={TESTID.CHOOSE_POPUP}
|
|
57
|
+
isVisible={isVisible}
|
|
58
|
+
onBackButtonPress={handleOnCancel}
|
|
59
|
+
onBackdropPress={handleOnCancel}
|
|
60
|
+
useNativeDriver={true}
|
|
61
|
+
useNativeDriverForBackdrop={true}
|
|
62
|
+
animationIn={'zoomIn'}
|
|
63
|
+
animationOut={'zoomOut'}
|
|
64
|
+
style={styles.wrapPopup}
|
|
65
|
+
>
|
|
66
|
+
<View style={[styles.popup, styles.heigh50percent]}>
|
|
67
|
+
<Text type="H4" style={styles.title} bold>
|
|
68
|
+
{title}
|
|
69
|
+
</Text>
|
|
70
|
+
<View style={styles.separator} />
|
|
71
|
+
<ScrollView>
|
|
72
|
+
{members.map((member, index) => (
|
|
73
|
+
<RowMember
|
|
74
|
+
key={index}
|
|
75
|
+
member={member}
|
|
76
|
+
isSelected={selectedUsers.id === member.id}
|
|
77
|
+
onSelect={handleOnSelectUser}
|
|
78
|
+
/>
|
|
79
|
+
))}
|
|
80
|
+
</ScrollView>
|
|
81
|
+
<View style={styles.separator} />
|
|
82
|
+
<BottomButtonView
|
|
83
|
+
rowButton={true}
|
|
84
|
+
testIDPrefix={TESTID.CHOOSE_POPUP}
|
|
85
|
+
style={styles.bottomButtonView}
|
|
86
|
+
secondaryTitle={t('cancel')}
|
|
87
|
+
mainTitle={t('apply')}
|
|
88
|
+
onPressSecondary={handleOnCancel}
|
|
89
|
+
onPressMain={handleOnApply}
|
|
90
|
+
/>
|
|
91
|
+
</View>
|
|
92
|
+
</ModalCustom>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export default ChoosePopup;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors, Constants } from '../../../configs';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
wrapPopup: {
|
|
6
|
+
marginHorizontal: 16,
|
|
7
|
+
},
|
|
8
|
+
popup: {
|
|
9
|
+
backgroundColor: Colors.White,
|
|
10
|
+
width: '100%',
|
|
11
|
+
height: (Constants.height * 80) / 100,
|
|
12
|
+
padding: 24,
|
|
13
|
+
paddingBottom: 100,
|
|
14
|
+
borderRadius: 10,
|
|
15
|
+
},
|
|
16
|
+
heigh50percent: {
|
|
17
|
+
height: (Constants.height * 50) / 100,
|
|
18
|
+
},
|
|
19
|
+
title: {
|
|
20
|
+
marginBottom: 16,
|
|
21
|
+
},
|
|
22
|
+
bottomButtonView: {
|
|
23
|
+
marginBottom: 24,
|
|
24
|
+
},
|
|
25
|
+
separator: {
|
|
26
|
+
height: 0.5,
|
|
27
|
+
backgroundColor: Colors.Gray4,
|
|
28
|
+
},
|
|
29
|
+
row: {
|
|
30
|
+
flexDirection: 'row',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
},
|
|
33
|
+
wrapText: {
|
|
34
|
+
flex: 1,
|
|
35
|
+
paddingVertical: 8,
|
|
36
|
+
marginRight: 24,
|
|
37
|
+
marginLeft: 16,
|
|
38
|
+
},
|
|
39
|
+
});
|