@eohjsc/react-native-smart-city 0.2.98 → 0.3.1
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 +36 -15
- package/package.json +5 -3
- package/src/commons/Action/ItemQuickAction.js +11 -2
- package/src/commons/Action/__test__/ItemQuickAction.test.js +11 -6
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +32 -21
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +24 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +14 -0
- package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +1 -3
- package/src/commons/ActionGroup/OnOffTemplate/index.js +15 -45
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +1 -1
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +3 -2
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +8 -4
- package/src/commons/ActionGroup/TimerActionTemplate.js +2 -2
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +6 -7
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +45 -48
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +77 -0
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +58 -6
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +49 -1
- package/src/commons/ActionGroup/__test__/index.test.js +137 -2
- package/src/commons/Automate/ItemAutomate.js +1 -3
- package/src/commons/Calendar/__test__/Calendar.test.js +33 -0
- package/src/commons/Connecting/__test__/Connecting.test.js +19 -2
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
- package/src/commons/ConnectingProcess/index.js +12 -8
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +16 -13
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +0 -5
- package/src/commons/Device/ConnectedViewHeader.js +1 -1
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
- package/src/commons/Device/HistoryChart.js +3 -3
- package/src/commons/Device/ItemDevice.js +15 -11
- package/src/commons/Device/LinearChart.js +15 -0
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- package/src/commons/Explore/__test__/CityItem.test.js +33 -54
- 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 +118 -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 +90 -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 +179 -0
- package/src/commons/FieldTemplate/ScheduleField/index.js +176 -0
- package/src/commons/Header/HeaderCustom.js +2 -1
- package/src/commons/HorizontalPicker/index.js +2 -2
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +0 -6
- package/src/commons/MediaPlayerDetail/index.js +19 -50
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
- package/src/commons/SubUnit/Favorites/index.js +2 -3
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
- package/src/commons/SubUnit/OneTap/index.js +1 -2
- package/src/commons/SubUnit/ShortDetail.js +1 -2
- package/src/commons/SubUnit/__test__/Item.test.js +0 -1
- package/src/commons/Unit/SharedUnit.js +1 -0
- package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +2 -13
- package/src/commons/UnitSummary/ConfigHistoryChart.js +22 -13
- package/src/commons/WheelDateTimePicker/index.js +4 -3
- package/src/configs/API.js +85 -145
- package/src/configs/Constants.js +36 -1
- package/src/configs/SCConfig.js +2 -0
- package/src/context/actionType.ts +8 -1
- package/src/context/mockStore.ts +10 -0
- package/src/context/reducer.ts +38 -5
- package/src/hooks/Common/index.js +2 -0
- package/src/hooks/Common/useGGHomeDeviceConnected.js +16 -0
- package/src/hooks/Common/useGetIdUser.js +1 -5
- package/src/hooks/Common/useSensorsStatus.js +5 -8
- package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +198 -0
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +198 -0
- package/src/hooks/IoT/index.js +4 -0
- package/src/hooks/IoT/useGGHomeConnection.js +91 -0
- package/src/hooks/IoT/useRemoteControl.js +79 -0
- package/src/hooks/index.js +4 -0
- package/src/hooks/useReceiveNotifications.js +8 -4
- package/src/iot/Monitor.js +3 -2
- package/src/iot/RemoteControl/Bluetooth.js +1 -1
- package/src/iot/RemoteControl/GoogleHome.js +75 -49
- package/src/iot/RemoteControl/Internet.js +1 -1
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +95 -48
- package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
- package/src/iot/RemoteControl/index.js +52 -52
- package/src/navigations/UnitStack.js +8 -0
- package/src/screens/ActivityLog/__test__/index.test.js +38 -23
- package/src/screens/ActivityLog/hooks/__test__/index.test.js +51 -90
- package/src/screens/ActivityLog/hooks/index.js +1 -1
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +13 -24
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
- package/src/screens/AddLocationMaps/index.js +5 -4
- package/src/screens/AddNewAction/SelectAction.js +8 -8
- package/src/screens/AddNewAction/SelectSensorDevices.js +2 -1
- package/src/screens/AddNewAction/SetupSensor.js +7 -7
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
- package/src/screens/AddNewAutoSmart/index.js +5 -2
- package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +34 -33
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -4
- package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +21 -21
- package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +3 -3
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +1 -0
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +4 -6
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +5 -29
- package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -4
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +10 -24
- package/src/screens/AddNewOneTap/index.js +2 -1
- package/src/screens/AllCamera/index.js +4 -4
- package/src/screens/Automate/MultiUnits.js +8 -8
- package/src/screens/Automate/__test__/MultiUnits.test.js +6 -9
- package/src/screens/Automate/__test__/index.test.js +7 -12
- package/src/screens/Automate/index.js +3 -3
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +36 -8
- package/src/screens/ConfirmUnitDeletion/index.js +7 -1
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +71 -22
- package/src/screens/Device/EditDevice/index.js +2 -2
- package/src/screens/Device/__test__/detail.test.js +33 -86
- package/src/screens/Device/components/DetailHistoryChart.js +1 -1
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +1 -0
- package/src/screens/Device/components/SensorDisplayItem.js +5 -2
- package/src/screens/Device/detail.js +81 -33
- package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
- package/src/screens/Device/hooks/useFavoriteDevice.js +5 -9
- package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
- package/src/screens/EditActionsList/index.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +6 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +18 -14
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +30 -31
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
- package/src/screens/GuestInfo/__test__/index.test.js +14 -41
- package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
- package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
- package/src/screens/HanetCamera/Detail.js +1 -1
- package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +8 -12
- package/src/screens/HanetCamera/__test__/Detail.test.js +27 -42
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +8 -5
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -32
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +3 -2
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +43 -35
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
- package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
- package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
- package/src/screens/ManageAccess/__test__/ManageAccess.test.js +33 -22
- package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +44 -45
- package/src/screens/ManageAccess/hooks/index.js +7 -4
- package/src/screens/ManageAccess/index.js +1 -1
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
- package/src/screens/MoveToAnotherSubUnit/index.js +5 -5
- package/src/screens/Notification/__test__/Notification.test.js +14 -25
- package/src/screens/Notification/__test__/NotificationItem.test.js +8 -7
- package/src/screens/Notification/components/NotificationItem.js +17 -20
- package/src/screens/Notification/index.js +9 -2
- package/src/screens/PlayBackCamera/Timer.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
- package/src/screens/PlayBackCamera/index.js +22 -6
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
- package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
- package/src/screens/ScanChipQR/hooks/index.js +15 -16
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
- package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
- package/src/screens/ScriptDetail/index.js +17 -12
- package/src/screens/SelectUnit/__test__/index.test.js +12 -55
- package/src/screens/SelectUnit/index.js +8 -4
- package/src/screens/SetSchedule/index.js +11 -10
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
- package/src/screens/Sharing/Components/SensorItem.js +10 -12
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/SelectPermission.js +121 -77
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +47 -29
- package/src/screens/Sharing/__test__/MemberList.test.js +13 -127
- package/src/screens/Sharing/__test__/MemberList2.test.js +80 -0
- package/src/screens/Sharing/__test__/SelectPermission.test.js +28 -38
- package/src/screens/Sharing/__test__/SelectUser.test.js +17 -38
- package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
- package/src/screens/SideMenuDetail/__test__/index.test.js +154 -0
- package/src/screens/SideMenuDetail/index.js +148 -0
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -2
- package/src/screens/SubUnit/Detail.js +1 -2
- package/src/screens/SubUnit/ManageSubUnit.js +12 -7
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +21 -67
- package/src/screens/SubUnit/__test__/Detail.test.js +31 -8
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +21 -89
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +27 -1
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +48 -45
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +14 -90
- package/src/screens/Unit/ChooseLocation.js +7 -14
- package/src/screens/Unit/Detail.js +30 -75
- package/src/screens/Unit/ManageUnit.js +1 -0
- package/src/screens/Unit/SelectAddress.js +34 -21
- package/src/screens/Unit/SmartAccount.js +4 -4
- package/src/screens/Unit/Summaries.js +17 -1
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +24 -29
- package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
- package/src/screens/Unit/__test__/Detail.test.js +99 -200
- package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
- package/src/screens/Unit/__test__/SelectAddress.test.js +84 -51
- package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
- package/src/screens/Unit/__test__/Summaries.test.js +100 -0
- package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +36 -0
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +54 -0
- package/src/screens/Unit/components/SharedUnit/index.js +1 -0
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +31 -34
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +50 -0
- package/src/screens/Unit/styles.js +4 -0
- package/src/screens/UnitSummary/__test__/index.test.js +70 -41
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +31 -2
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +2 -13
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -1
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +11 -2
- package/src/screens/UnitSummary/components/RunningDevices/index.js +7 -10
- package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
- package/src/screens/UnitSummary/index.js +15 -1
- package/src/utils/Apis/axios.js +46 -31
- package/src/utils/Converter/time.js +0 -18
- package/src/utils/I18n/translations/en.json +3 -1
- package/src/utils/I18n/translations/vi.json +4 -1
- package/src/utils/Permission/common.js +39 -0
- package/src/utils/Route/index.js +1 -0
- package/src/utils/Utils.js +11 -7
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { create, act } from 'react-test-renderer';
|
|
3
|
+
|
|
4
|
+
import MemberList from '../MemberList';
|
|
5
|
+
import { AlertAction } from '../../../commons';
|
|
6
|
+
import { SCProvider } from '../../../context';
|
|
7
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
8
|
+
import { TouchableOpacity } from 'react-native';
|
|
9
|
+
import Routes from '../../../utils/Route';
|
|
10
|
+
|
|
11
|
+
jest.mock('../../../hooks/Common', () => {
|
|
12
|
+
return {
|
|
13
|
+
useIsOwnerOfUnit: () => ({ isOwner: false }),
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const mockedNavigate = jest.fn();
|
|
18
|
+
const mockUseIsFocused = jest.fn();
|
|
19
|
+
|
|
20
|
+
jest.mock('@react-navigation/native', () => {
|
|
21
|
+
return {
|
|
22
|
+
...jest.requireActual('@react-navigation/native'),
|
|
23
|
+
useNavigation: () => ({
|
|
24
|
+
navigate: mockedNavigate,
|
|
25
|
+
}),
|
|
26
|
+
useIsFocused: () => ({
|
|
27
|
+
isFocused: mockUseIsFocused,
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const wrapComponent = (route, state) => (
|
|
33
|
+
<SCProvider initState={mockSCStore({})}>
|
|
34
|
+
<MemberList route={route} />
|
|
35
|
+
</SCProvider>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
describe('test MemberList', () => {
|
|
39
|
+
let route;
|
|
40
|
+
let localState = {
|
|
41
|
+
auth: {
|
|
42
|
+
account: {
|
|
43
|
+
user: {
|
|
44
|
+
id: 2,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
beforeEach(() => {
|
|
51
|
+
route = {
|
|
52
|
+
params: {
|
|
53
|
+
unitId: 1,
|
|
54
|
+
unit: {
|
|
55
|
+
id: 1,
|
|
56
|
+
user_id: 2,
|
|
57
|
+
name: '',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('AlertAction rightButtonClick', async () => {
|
|
64
|
+
let tree;
|
|
65
|
+
await act(async () => {
|
|
66
|
+
tree = await create(wrapComponent(route, localState));
|
|
67
|
+
});
|
|
68
|
+
const instance = tree.root;
|
|
69
|
+
const alertAction = instance.findByType(AlertAction);
|
|
70
|
+
await act(async () => {
|
|
71
|
+
alertAction.props.rightButtonClick();
|
|
72
|
+
});
|
|
73
|
+
const MemberListButtons = instance.findAllByType(TouchableOpacity);
|
|
74
|
+
await MemberListButtons[1].props.onPress();
|
|
75
|
+
expect(mockedNavigate).not.toBeCalledWith(Routes.AddMemberStack, {
|
|
76
|
+
screen: Routes.SharingSelectPermission,
|
|
77
|
+
params: { unit: { id: 1 } },
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -2,16 +2,17 @@ import { act } from '@testing-library/react-hooks';
|
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
3
|
import { FlatList, Text, Platform } from 'react-native';
|
|
4
4
|
import { create } from 'react-test-renderer';
|
|
5
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
6
|
+
|
|
5
7
|
import SelectPermission from '../SelectPermission';
|
|
6
|
-
import axios from 'axios';
|
|
7
8
|
import { SensorItem, TitleCheckBox } from '../Components';
|
|
8
9
|
import { ViewButtonBottom } from '../../../commons';
|
|
9
|
-
import Routes from '../../../utils/Route';
|
|
10
10
|
import { SCProvider } from '../../../context';
|
|
11
11
|
import { mockSCStore } from '../../../context/mockStore';
|
|
12
12
|
import API from '../../../configs/API';
|
|
13
|
+
import api from '../../../utils/Apis/axios';
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
15
16
|
|
|
16
17
|
const mockSetState = jest.fn();
|
|
17
18
|
jest.mock('react', () => {
|
|
@@ -63,7 +64,6 @@ describe('Test SelectPermission', () => {
|
|
|
63
64
|
const mockSetDataStations = jest.fn();
|
|
64
65
|
|
|
65
66
|
afterEach(() => {
|
|
66
|
-
axios.mockClear();
|
|
67
67
|
mockSetState.mockClear();
|
|
68
68
|
mockSetTickAllDevice.mockClear();
|
|
69
69
|
mockSetActiveItemId.mockClear();
|
|
@@ -92,15 +92,16 @@ describe('Test SelectPermission', () => {
|
|
|
92
92
|
act(() => {
|
|
93
93
|
tree = create(wrapComponent(route));
|
|
94
94
|
});
|
|
95
|
-
|
|
95
|
+
const instance = tree.root;
|
|
96
|
+
const ViewButtonBottoms = instance.findAllByType(ViewButtonBottom);
|
|
97
|
+
expect(ViewButtonBottoms).toHaveLength(1);
|
|
96
98
|
});
|
|
97
99
|
|
|
98
100
|
it('render empty list', () => {
|
|
99
101
|
mockLoading();
|
|
100
102
|
Platform.OS = 'ios';
|
|
101
|
-
|
|
102
103
|
route.params.unit = 1;
|
|
103
|
-
|
|
104
|
+
mock.onGet(API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1)).reply(200);
|
|
104
105
|
act(() => {
|
|
105
106
|
tree = create(wrapComponent(route));
|
|
106
107
|
});
|
|
@@ -111,9 +112,8 @@ describe('Test SelectPermission', () => {
|
|
|
111
112
|
|
|
112
113
|
it('test get unit fail', () => {
|
|
113
114
|
mockLoading();
|
|
114
|
-
|
|
115
115
|
route.params.unit = 1;
|
|
116
|
-
|
|
116
|
+
mock.onGet(API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1)).reply(400);
|
|
117
117
|
act(() => {
|
|
118
118
|
tree = create(wrapComponent(route));
|
|
119
119
|
});
|
|
@@ -183,27 +183,15 @@ describe('Test SelectPermission', () => {
|
|
|
183
183
|
act(() => {
|
|
184
184
|
ViewButtonBottomElement[0].props.onRightClick();
|
|
185
185
|
});
|
|
186
|
-
expect(mockNavigate).toBeCalledWith(Routes.SharingInviteMembers, {
|
|
187
|
-
permissions: {
|
|
188
|
-
control_permissions: [{ id: 123, values: [136] }],
|
|
189
|
-
read_permissions: [{ id: 123, values: [137] }],
|
|
190
|
-
},
|
|
191
|
-
unit: 1,
|
|
192
|
-
});
|
|
193
186
|
act(() => {
|
|
194
187
|
ViewButtonBottomElement[0].props.onLeftClick();
|
|
195
188
|
});
|
|
196
189
|
expect(mockGoBack).toBeCalled();
|
|
197
190
|
});
|
|
191
|
+
|
|
198
192
|
it('test selectPermission type share_device', () => {
|
|
199
193
|
mocSetdata();
|
|
200
|
-
|
|
201
|
-
params: {
|
|
202
|
-
unit: { id: 1 },
|
|
203
|
-
type: 'share_device',
|
|
204
|
-
member: { id: 1, name: 'a', phone_number: '89898888' },
|
|
205
|
-
},
|
|
206
|
-
};
|
|
194
|
+
useState.mockImplementationOnce((init) => [true, mockSetState]);
|
|
207
195
|
const response = {
|
|
208
196
|
status: 200,
|
|
209
197
|
data: [
|
|
@@ -223,28 +211,30 @@ describe('Test SelectPermission', () => {
|
|
|
223
211
|
},
|
|
224
212
|
],
|
|
225
213
|
};
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
214
|
+
mock
|
|
215
|
+
.onGet(API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1))
|
|
216
|
+
.reply(200, response.data);
|
|
217
|
+
const routes = {
|
|
218
|
+
params: {
|
|
219
|
+
unit: { id: 1 },
|
|
220
|
+
type: 'update_shared',
|
|
221
|
+
member: {
|
|
222
|
+
id: 1,
|
|
223
|
+
name: 'a',
|
|
224
|
+
phone_number: '89898888',
|
|
225
|
+
email: 'abcderfg@gmail.com',
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
229
|
act(() => {
|
|
230
230
|
tree = create(wrapComponent(routes));
|
|
231
231
|
});
|
|
232
232
|
const instance = tree.root;
|
|
233
233
|
const ViewButtonBottomElement = instance.findAllByType(ViewButtonBottom);
|
|
234
|
-
expect(ViewButtonBottomElement).toHaveLength(1);
|
|
235
|
-
expect(axios.get).toHaveBeenCalledWith(
|
|
236
|
-
API.SHARE.UNIT_MEMBER_SHARE_DEVICE(1, 1),
|
|
237
|
-
{}
|
|
238
|
-
);
|
|
239
234
|
act(() => {
|
|
240
235
|
ViewButtonBottomElement[0].props.onRightClick();
|
|
241
236
|
});
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
control_permissions: [{ id: 123, values: [136] }],
|
|
245
|
-
read_permissions: [{ id: 123, values: [137] }],
|
|
246
|
-
},
|
|
247
|
-
unit: 1,
|
|
248
|
-
});
|
|
237
|
+
mock.onPost(API.SHARE.SHARE()).reply(200);
|
|
238
|
+
expect(mockGoBack).toBeCalled();
|
|
249
239
|
});
|
|
250
240
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { create, act } from 'react-test-renderer';
|
|
3
|
-
import
|
|
3
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
4
4
|
|
|
5
5
|
import SelectUser from '../SelectUser';
|
|
6
6
|
import { TESTID } from '../../../configs/Constants';
|
|
@@ -11,6 +11,7 @@ import { API } from '../../../configs';
|
|
|
11
11
|
import { getTranslate } from '../../../utils/I18n';
|
|
12
12
|
import { SCProvider } from '../../../context';
|
|
13
13
|
import { mockSCStore } from '../../../context/mockStore';
|
|
14
|
+
import api from '../../../utils/Apis/axios';
|
|
14
15
|
|
|
15
16
|
const wrapComponent = (route) => (
|
|
16
17
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -18,13 +19,13 @@ const wrapComponent = (route) => (
|
|
|
18
19
|
</SCProvider>
|
|
19
20
|
);
|
|
20
21
|
|
|
22
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
23
|
+
|
|
21
24
|
const mockedNavigate = jest.fn();
|
|
22
25
|
const mockedGoBack = jest.fn();
|
|
23
26
|
const mockedDangerouslyGetState = jest.fn();
|
|
24
27
|
const mockedDangerouslyGetParentGoBack = jest.fn();
|
|
25
28
|
|
|
26
|
-
jest.mock('axios');
|
|
27
|
-
|
|
28
29
|
jest.mock('react-redux', () => {
|
|
29
30
|
return {
|
|
30
31
|
...jest.requireActual('react-redux'),
|
|
@@ -52,7 +53,6 @@ describe('test SelectUser container', () => {
|
|
|
52
53
|
let route;
|
|
53
54
|
|
|
54
55
|
beforeEach(() => {
|
|
55
|
-
axios.post.mockClear();
|
|
56
56
|
route = {
|
|
57
57
|
params: {
|
|
58
58
|
unit: {
|
|
@@ -70,12 +70,6 @@ describe('test SelectUser container', () => {
|
|
|
70
70
|
return instance.find((el) => el.props.testID === id);
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
-
const mockAxiosPost = (response) => {
|
|
74
|
-
axios.post.mockImplementation(async () => {
|
|
75
|
-
return await response;
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
73
|
test('create', async () => {
|
|
80
74
|
await act(async () => {
|
|
81
75
|
tree = create(wrapComponent(route));
|
|
@@ -125,11 +119,7 @@ describe('test SelectUser container', () => {
|
|
|
125
119
|
});
|
|
126
120
|
|
|
127
121
|
test('_TextInput onChange phone, invalidate and not call api sharedPermission', async () => {
|
|
128
|
-
|
|
129
|
-
status: 200,
|
|
130
|
-
};
|
|
131
|
-
mockAxiosPost(response);
|
|
132
|
-
|
|
122
|
+
mock.onPost(API.SHARE.SHARE()).reply(200);
|
|
133
123
|
await act(async () => {
|
|
134
124
|
tree = create(wrapComponent(route));
|
|
135
125
|
});
|
|
@@ -151,48 +141,37 @@ describe('test SelectUser container', () => {
|
|
|
151
141
|
expect(textInput.props.errorText).toEqual(
|
|
152
142
|
getTranslate('en', 'invalid_phone_number_or_email')
|
|
153
143
|
);
|
|
154
|
-
expect(axios.post).not.toHaveBeenCalled();
|
|
155
144
|
});
|
|
156
145
|
|
|
157
146
|
test('_TextInput onChange phone, validated and call api sharedPermission', async () => {
|
|
158
|
-
const response = {
|
|
159
|
-
status: 200,
|
|
160
|
-
data: {
|
|
161
|
-
user: {
|
|
162
|
-
id: 2,
|
|
163
|
-
name: 'user add',
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
mockAxiosPost(response);
|
|
168
|
-
|
|
169
147
|
await act(async () => {
|
|
170
148
|
tree = create(wrapComponent(route));
|
|
171
149
|
});
|
|
172
150
|
const instance = tree.root;
|
|
173
|
-
|
|
174
151
|
const textInput = instance.findByType(_TextInput);
|
|
175
152
|
const button = instance.findByType(Button);
|
|
176
|
-
|
|
177
153
|
let accountList = instance.findAllByType(AccountList);
|
|
178
154
|
expect(accountList).toHaveLength(0);
|
|
179
|
-
|
|
180
155
|
await act(async () => {
|
|
181
156
|
await textInput.props.onChange('0909123456');
|
|
182
157
|
});
|
|
183
|
-
|
|
158
|
+
mock.onPost(API.SHARE.SHARE()).reply(200, {
|
|
159
|
+
user: {
|
|
160
|
+
id: 2,
|
|
161
|
+
name: 'user add',
|
|
162
|
+
phone_number: '0909123456',
|
|
163
|
+
},
|
|
164
|
+
});
|
|
184
165
|
await act(async () => {
|
|
185
166
|
await button.props.onPress();
|
|
186
167
|
});
|
|
187
|
-
|
|
168
|
+
await act(async () => {
|
|
169
|
+
await textInput.props.onChange('test123@gmail.com');
|
|
170
|
+
});
|
|
188
171
|
expect(textInput.props.errorText).toEqual('');
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
email: '',
|
|
192
|
-
unit: 1,
|
|
193
|
-
permissions: { controlPermissions: {}, readPermissions: {} },
|
|
172
|
+
await act(async () => {
|
|
173
|
+
await button.props.onPress();
|
|
194
174
|
});
|
|
195
|
-
|
|
196
175
|
accountList = instance.findAllByType(AccountList);
|
|
197
176
|
expect(accountList).toHaveLength(1);
|
|
198
177
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Colors } from '../../configs';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
import { getBottomSpace } from 'react-native-iphone-x-helper';
|
|
4
|
+
|
|
5
|
+
export default StyleSheet.create({
|
|
6
|
+
container: {
|
|
7
|
+
flex: 1,
|
|
8
|
+
backgroundColor: Colors.White,
|
|
9
|
+
},
|
|
10
|
+
scrollview: {
|
|
11
|
+
flex: 1,
|
|
12
|
+
marginHorizontal: 16,
|
|
13
|
+
},
|
|
14
|
+
wrap: {
|
|
15
|
+
paddingBottom: 100,
|
|
16
|
+
},
|
|
17
|
+
viewBottomFixed: {
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
bottom: 0,
|
|
20
|
+
left: 0,
|
|
21
|
+
right: 0,
|
|
22
|
+
paddingBottom: getBottomSpace() > 0 ? getBottomSpace() : 32,
|
|
23
|
+
paddingTop: 24,
|
|
24
|
+
backgroundColor: Colors.White,
|
|
25
|
+
borderColor: Colors.ShadownTransparent,
|
|
26
|
+
borderTopWidth: 1,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
3
|
+
import { act, create } from 'react-test-renderer';
|
|
4
|
+
|
|
5
|
+
import { TESTID } from '../../../configs/Constants';
|
|
6
|
+
|
|
7
|
+
import { SCProvider } from '../../../context';
|
|
8
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
9
|
+
import SideMenuDetail from '../index';
|
|
10
|
+
import { API } from '../../../configs';
|
|
11
|
+
import { TouchableOpacity } from 'react-native';
|
|
12
|
+
import { ModalCustom } from '../../../commons/Modal';
|
|
13
|
+
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
14
|
+
import api from '../../../utils/Apis/axios';
|
|
15
|
+
|
|
16
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
17
|
+
|
|
18
|
+
const wrapComponent = (route) => (
|
|
19
|
+
<SCProvider initState={mockSCStore({})}>
|
|
20
|
+
<SideMenuDetail route={route} />
|
|
21
|
+
</SCProvider>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
describe('Test SideMenuDetail', () => {
|
|
25
|
+
let tree;
|
|
26
|
+
const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
|
|
27
|
+
const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
|
|
28
|
+
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
spyToastSuccess.mockReset();
|
|
31
|
+
spyToastSuccess.mockRestore();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const chooseUser = async (instance) => {
|
|
35
|
+
const ChooseField = instance.find(
|
|
36
|
+
(item) =>
|
|
37
|
+
item.props.testID === TESTID.CHOOSE_FIELD &&
|
|
38
|
+
item.type === TouchableOpacity
|
|
39
|
+
);
|
|
40
|
+
await act(async () => {
|
|
41
|
+
await ChooseField.props.onPress();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const popup = instance.find(
|
|
45
|
+
(item) =>
|
|
46
|
+
item.props.testID === TESTID.CHOOSE_POPUP && item.type === ModalCustom
|
|
47
|
+
);
|
|
48
|
+
expect(popup.props.isVisible).toBeTruthy();
|
|
49
|
+
|
|
50
|
+
const button_choose_done = instance.find(
|
|
51
|
+
(el) =>
|
|
52
|
+
el.props.testID === TESTID.CHOOSE_POPUP + TESTID.BOTTOM_VIEW_MAIN &&
|
|
53
|
+
el.type === TouchableOpacity
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
await act(async () => {
|
|
57
|
+
await button_choose_done.props.onPress();
|
|
58
|
+
});
|
|
59
|
+
expect(popup.props.isVisible).toBeFalsy();
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const enterPasscode = async (instance) => {
|
|
63
|
+
const inputPasscode = instance.find(
|
|
64
|
+
(item) => item.props.testID === TESTID.PASSCODE_FIELD
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
await act(async () => {
|
|
68
|
+
await inputPasscode.props.onChangeText('123456');
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const onPressSubmitData = async (instance) => {
|
|
73
|
+
const buttonSubmit = instance.find(
|
|
74
|
+
(el) =>
|
|
75
|
+
el.props.testID === TESTID.SUBMIT + TESTID.BOTTOM_VIEW_MAIN &&
|
|
76
|
+
el.type === TouchableOpacity
|
|
77
|
+
);
|
|
78
|
+
await act(async () => {
|
|
79
|
+
await buttonSubmit.props.onPress();
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
test('render SideMenuDetail template choose field', async () => {
|
|
84
|
+
const response_side_menu = {
|
|
85
|
+
status: 200,
|
|
86
|
+
data: {
|
|
87
|
+
id: 1,
|
|
88
|
+
action: '3df74a11-1a95-4a65-8e08-936b88c8b5ca',
|
|
89
|
+
fields: [
|
|
90
|
+
{
|
|
91
|
+
type: 'choose_user',
|
|
92
|
+
key: 'user_id',
|
|
93
|
+
action: {
|
|
94
|
+
type: 'action_zigbee',
|
|
95
|
+
id: 1,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
type: 'passcode',
|
|
100
|
+
key: 'passcode',
|
|
101
|
+
action: {
|
|
102
|
+
type: 'action_zigbee',
|
|
103
|
+
id: 1,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: 'schedule',
|
|
108
|
+
key: 'schedule',
|
|
109
|
+
action: {
|
|
110
|
+
type: 'action_zigbee',
|
|
111
|
+
id: {
|
|
112
|
+
always: 2,
|
|
113
|
+
recurring: 4,
|
|
114
|
+
temporary: 5,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
const response_unit_members = {
|
|
122
|
+
status: 200,
|
|
123
|
+
data: [{ id: 1, name: 'Ken' }],
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
mock
|
|
127
|
+
.onGet(API.DEVICE.SIDE_MENU_DETAIL(1, 1))
|
|
128
|
+
.reply(200, response_side_menu.data);
|
|
129
|
+
mock
|
|
130
|
+
.onGet(API.SHARE.UNITS_MEMBERS(1))
|
|
131
|
+
.reply(200, response_unit_members.data);
|
|
132
|
+
mock.onPost(API.DEVICE.TRIGGER_ACTION(1)).reply(200, []);
|
|
133
|
+
|
|
134
|
+
const route = {
|
|
135
|
+
params: {
|
|
136
|
+
unit: { id: 1 },
|
|
137
|
+
sensor: { id: 1 },
|
|
138
|
+
side_menu: { id: 1, name: 'Setup generate pass code' },
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
await act(async () => {
|
|
142
|
+
tree = await create(wrapComponent(route));
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const instance = tree.root;
|
|
146
|
+
await chooseUser(instance);
|
|
147
|
+
await onPressSubmitData(instance);
|
|
148
|
+
expect(spyToastError).toBeCalled();
|
|
149
|
+
|
|
150
|
+
await enterPasscode(instance);
|
|
151
|
+
await onPressSubmitData(instance);
|
|
152
|
+
expect(spyToastSuccess).toBeCalled();
|
|
153
|
+
});
|
|
154
|
+
});
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import React, { memo, useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { View, ScrollView } from 'react-native';
|
|
3
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
4
|
+
|
|
5
|
+
import styles from './SideMenuDetailStyles';
|
|
6
|
+
import { HeaderCustom } from '../../commons/Header';
|
|
7
|
+
import BottomButtonView from '../../commons/BottomButtonView';
|
|
8
|
+
import { axiosGet, axiosPost } from '../../utils/Apis/axios';
|
|
9
|
+
import { API } from '../../configs';
|
|
10
|
+
import PasscodeField from '../../commons/FieldTemplate/PasscodeField';
|
|
11
|
+
import ChooseUserField from '../../commons/FieldTemplate/ChooseUserField';
|
|
12
|
+
import ScheduleField from '../../commons/FieldTemplate/ScheduleField';
|
|
13
|
+
import { TESTID } from '../../configs/Constants';
|
|
14
|
+
import { ToastBottomHelper } from '../../utils/Utils';
|
|
15
|
+
import { useNavigation } from '@react-navigation/native';
|
|
16
|
+
|
|
17
|
+
const SideMenuDetail = memo(({ route }) => {
|
|
18
|
+
const t = useTranslations();
|
|
19
|
+
const { goBack } = useNavigation();
|
|
20
|
+
const { unit, sensor, side_menu } = route?.params || {};
|
|
21
|
+
const [sideMenu, setSideMenu] = useState({});
|
|
22
|
+
const [dataForm, setDataForm] = useState([]);
|
|
23
|
+
|
|
24
|
+
const renderTemplateField = useCallback(
|
|
25
|
+
(item, index) => {
|
|
26
|
+
const keyItem = item.key;
|
|
27
|
+
const dataItem = item;
|
|
28
|
+
switch (item.type) {
|
|
29
|
+
case 'choose_user':
|
|
30
|
+
return (
|
|
31
|
+
<ChooseUserField
|
|
32
|
+
key={index} // Todo avoid waring unique "key" prop
|
|
33
|
+
unit={unit}
|
|
34
|
+
dataItem={dataItem}
|
|
35
|
+
index={index}
|
|
36
|
+
setDataForm={setDataForm}
|
|
37
|
+
dataForm={dataForm}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
case 'passcode':
|
|
41
|
+
return (
|
|
42
|
+
<PasscodeField
|
|
43
|
+
key={index}
|
|
44
|
+
dataItem={dataItem}
|
|
45
|
+
index={index}
|
|
46
|
+
setDataForm={setDataForm}
|
|
47
|
+
dataForm={dataForm}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
case 'schedule':
|
|
51
|
+
return (
|
|
52
|
+
<ScheduleField
|
|
53
|
+
key={index}
|
|
54
|
+
dataItem={dataItem}
|
|
55
|
+
keyItem={keyItem}
|
|
56
|
+
setDataForm={setDataForm}
|
|
57
|
+
dataForm={dataForm}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
default:
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
[unit, dataForm]
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const onPressSubmit = useCallback(async () => {
|
|
68
|
+
const data = {};
|
|
69
|
+
const actionZigbee = [];
|
|
70
|
+
for (let i = 0; i < dataForm.length; i++) {
|
|
71
|
+
if (!dataForm[i].valid) {
|
|
72
|
+
ToastBottomHelper.error(t('invaild_data'));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (dataForm[i].data) {
|
|
76
|
+
data[dataForm[i].key] = dataForm[i].data;
|
|
77
|
+
if (
|
|
78
|
+
dataForm[i].action_zigbee &&
|
|
79
|
+
!actionZigbee.includes(dataForm[i].action_zigbee)
|
|
80
|
+
) {
|
|
81
|
+
actionZigbee.push(dataForm[i].action_zigbee);
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
data[dataForm[i].key] = null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
data.action_zigbee = actionZigbee;
|
|
89
|
+
|
|
90
|
+
const { success } = await axiosPost(API.DEVICE.TRIGGER_ACTION(sensor.id), {
|
|
91
|
+
key: sideMenu.action,
|
|
92
|
+
data,
|
|
93
|
+
source: 'smart_lock',
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
if (success) {
|
|
97
|
+
ToastBottomHelper.success(t('activated_successfully'));
|
|
98
|
+
goBack();
|
|
99
|
+
} else {
|
|
100
|
+
ToastBottomHelper.error(t('activation_failed'));
|
|
101
|
+
}
|
|
102
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
103
|
+
}, [dataForm]);
|
|
104
|
+
|
|
105
|
+
const fetchSideMenuDetail = useCallback(async () => {
|
|
106
|
+
const { success, data } = await axiosGet(
|
|
107
|
+
API.DEVICE.SIDE_MENU_DETAIL(sensor.id, side_menu.id)
|
|
108
|
+
);
|
|
109
|
+
if (success) {
|
|
110
|
+
setSideMenu(data);
|
|
111
|
+
setDataForm(data.fields);
|
|
112
|
+
}
|
|
113
|
+
}, [sensor.id, side_menu.id]);
|
|
114
|
+
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
fetchSideMenuDetail();
|
|
117
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
118
|
+
}, []);
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<View style={styles.container}>
|
|
122
|
+
<HeaderCustom
|
|
123
|
+
title={side_menu.name}
|
|
124
|
+
titleStyle={styles.title}
|
|
125
|
+
isShowSeparator
|
|
126
|
+
/>
|
|
127
|
+
<ScrollView
|
|
128
|
+
showsVerticalScrollIndicator={false}
|
|
129
|
+
showsHorizontalScrollIndicator={false}
|
|
130
|
+
style={styles.scrollview}
|
|
131
|
+
>
|
|
132
|
+
<View style={styles.wrap}>
|
|
133
|
+
{dataForm.map((item, index) => {
|
|
134
|
+
return renderTemplateField(item, index);
|
|
135
|
+
})}
|
|
136
|
+
</View>
|
|
137
|
+
</ScrollView>
|
|
138
|
+
<BottomButtonView
|
|
139
|
+
style={styles.viewBottomFixed}
|
|
140
|
+
testIDPrefix={TESTID.SUBMIT}
|
|
141
|
+
mainTitle={t('done')}
|
|
142
|
+
onPressMain={onPressSubmit}
|
|
143
|
+
/>
|
|
144
|
+
</View>
|
|
145
|
+
);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
export default SideMenuDetail;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { memo, useCallback, useState, useMemo } from 'react';
|
|
2
|
-
import { View, TouchableOpacity
|
|
2
|
+
import { View, TouchableOpacity } from 'react-native';
|
|
3
3
|
import WrapHeaderScrollable from '../../../../commons/Sharing/WrapHeaderScrollable';
|
|
4
4
|
import { useTranslations } from '../../../../hooks/Common/useTranslations';
|
|
5
5
|
import SmartTiviActionTemplate from '../../../../commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate';
|
|
@@ -14,6 +14,7 @@ import { Remote, SmartIr, Union } from '../../../../Images/SmartIr';
|
|
|
14
14
|
|
|
15
15
|
import styles from './GroupButtonByTypeStyles';
|
|
16
16
|
import { TESTID } from '../../../../configs/Constants';
|
|
17
|
+
import { notImplemented } from '../../../../utils/Utils';
|
|
17
18
|
|
|
18
19
|
const GroupButtonByType = memo(({ route }) => {
|
|
19
20
|
const t = useTranslations();
|
|
@@ -38,7 +39,7 @@ const GroupButtonByType = memo(({ route }) => {
|
|
|
38
39
|
case 'reload':
|
|
39
40
|
case 'more':
|
|
40
41
|
case 'done':
|
|
41
|
-
return
|
|
42
|
+
return notImplemented(t);
|
|
42
43
|
default:
|
|
43
44
|
return <></>;
|
|
44
45
|
}
|