@eohjsc/react-native-smart-city 0.3.8 → 0.3.9
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 +10 -6
- package/react-native-smart-city.podspec +1 -0
- package/src/commons/Action/ItemQuickAction.js +16 -4
- package/src/commons/Action/__test__/ItemQuickAction.test.js +11 -6
- package/src/commons/ActionGroup/ColorPickerTemplate.js +37 -24
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
- 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/OnOffSmartLock/SetupGeneratePasscode/index.js +1 -0
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +8 -2
- package/src/commons/ActionGroup/SliderRangeTemplate.js +6 -2
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -3
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +22 -8
- package/src/commons/ActionGroup/TimerActionTemplate.js +11 -3
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +1 -5
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
- 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/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 +135 -0
- package/src/commons/Auth/AccountList.js +1 -1
- 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/DeviceItem/DeviceItem.js +7 -3
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +8 -11
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +3 -2
- package/src/commons/ConnectingProcess/index.js +76 -26
- 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 +7 -3
- package/src/commons/Device/ItemDevice.js +34 -13
- package/src/commons/Device/LinearChart.js +15 -0
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
- package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +7 -2
- 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/Form/CurrencyInput.js +15 -1
- package/src/commons/Form/TextInputPassword.js +1 -1
- package/src/commons/FullLoading/index.js +2 -1
- package/src/commons/Header/HeaderCustom.js +2 -1
- package/src/commons/HeaderAni/index.js +6 -1
- package/src/commons/HorizontalPicker/index.js +2 -2
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +0 -6
- package/src/commons/MediaPlayerDetail/index.js +26 -47
- 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 +9 -1
- package/src/commons/Sharing/MemberList.js +10 -2
- package/src/commons/Sharing/WrapHeaderScrollable.js +2 -0
- 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 +25 -9
- package/src/commons/SubUnit/__test__/Item.test.js +0 -1
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +9 -2
- 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 +87 -143
- package/src/configs/Constants.js +61 -1
- package/src/configs/SCConfig.js +4 -0
- package/src/context/actionType.ts +10 -0
- package/src/context/mockStore.ts +11 -0
- package/src/context/reducer.ts +51 -2
- 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 +4 -4
- package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +199 -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 +93 -0
- package/src/hooks/IoT/useRemoteControl.js +79 -0
- package/src/hooks/index.js +4 -0
- package/src/hooks/useReceiveNotifications.js +9 -5
- 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 +11 -20
- package/src/navigations/UnitStackStyles.js +21 -0
- package/src/screens/AQIGuide/index.js +1 -1
- package/src/screens/ActivityLog/FilterPopup.js +2 -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/SelectSubUnit.js +1 -0
- package/src/screens/AddCommon/SelectUnit.js +1 -0
- 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 +9 -5
- package/src/screens/AddNewAction/SelectAction.js +8 -8
- package/src/screens/AddNewAction/SelectSensorDevices.js +8 -2
- 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 +42 -34
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -4
- package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +22 -22
- package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
- package/src/screens/AddNewDevice/index.js +1 -0
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +46 -40
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +64 -10
- package/src/screens/AddNewGateway/SelectGateway.js +1 -0
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +2 -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/AddNewGateway/index.js +1 -0
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +10 -24
- package/src/screens/AddNewOneTap/index.js +3 -2
- 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 +5 -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 +17 -15
- 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 +44 -24
- package/src/screens/Device/components/SensorDisplayItem.js +5 -2
- package/src/screens/Device/detail.js +85 -26
- 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 +20 -2
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +40 -23
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EmergencySetting/index.js +4 -1
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
- package/src/screens/Explore/index.js +2 -0
- 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 +2 -1
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
- package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
- 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 +54 -35
- 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 +19 -14
- package/src/screens/SelectUnit/__test__/index.test.js +12 -55
- package/src/screens/SelectUnit/index.js +9 -4
- package/src/screens/SetSchedule/index.js +15 -11
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
- package/src/screens/SharedUnit/index.js +2 -0
- package/src/screens/Sharing/Components/SensorItem.js +10 -12
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/MemberList.js +12 -11
- package/src/screens/Sharing/SelectPermission.js +121 -76
- 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/Sharing/hooks/index.js +3 -0
- 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/SmartIr/components/SelectBrand.js +1 -1
- package/src/screens/SubUnit/AddSubUnit.js +23 -17
- package/src/screens/SubUnit/Detail.js +1 -2
- package/src/screens/SubUnit/EditSubUnit.js +15 -13
- package/src/screens/SubUnit/ManageSubUnit.js +13 -7
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +29 -89
- 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/AddLGDevice.js +1 -0
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +22 -91
- package/src/screens/TDSGuide/index.js +4 -1
- package/src/screens/UVIndexGuide/index.js +1 -1
- package/src/screens/Unit/ChooseLocation.js +7 -14
- package/src/screens/Unit/Detail.js +31 -75
- package/src/screens/Unit/ManageUnit.js +1 -0
- package/src/screens/Unit/SelectAddress.js +45 -23
- package/src/screens/Unit/SmartAccount.js +4 -4
- package/src/screens/Unit/Station/index.js +4 -0
- package/src/screens/Unit/Summaries.js +18 -2
- 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 +98 -199
- package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
- package/src/screens/Unit/__test__/SelectAddress.test.js +159 -49
- 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/MyUnitDevice/index.js +4 -4
- package/src/screens/Unit/components/SharedUnit/index.js +1 -0
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
- 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 +91 -30
- 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/components/WaterQuality/Item/index.js +10 -2
- package/src/screens/UnitSummary/index.js +15 -1
- package/src/screens/WaterQualityGuide/index.js +1 -1
- package/src/utils/Apis/axios.js +54 -31
- package/src/utils/Converter/time.js +0 -18
- package/src/utils/I18n/translations/en.json +7 -1
- package/src/utils/I18n/translations/vi.json +8 -1
- package/src/utils/Permission/common.js +67 -0
- package/src/utils/Route/index.js +1 -0
- package/src/utils/Setting/Location.js +30 -0
- package/src/utils/Utils.js +11 -7
- package/src/utils/__test__/Utils.test.js +12 -0
|
@@ -2,14 +2,18 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import { TouchableOpacity } from 'react-native';
|
|
3
3
|
import { useRoute } from '@react-navigation/native';
|
|
4
4
|
import { act, create } from 'react-test-renderer';
|
|
5
|
-
import
|
|
5
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
6
|
+
|
|
6
7
|
import SelectUnit from '../';
|
|
7
8
|
import { SCProvider } from '../../../context';
|
|
8
9
|
import { mockSCStore } from '../../../context/mockStore';
|
|
9
10
|
import { TESTID } from '../../../configs/Constants';
|
|
10
11
|
import Routes from '../../../utils/Route';
|
|
12
|
+
import api from '../../../utils/Apis/axios';
|
|
13
|
+
import { API } from '../../../configs';
|
|
14
|
+
|
|
15
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
11
16
|
|
|
12
|
-
jest.mock('axios');
|
|
13
17
|
const mockSetState = jest.fn();
|
|
14
18
|
const mockDispatch = jest.fn();
|
|
15
19
|
const mockGoBack = jest.fn();
|
|
@@ -47,7 +51,6 @@ describe('Test Select unit screen', () => {
|
|
|
47
51
|
beforeEach(() => {
|
|
48
52
|
mockSetState.mockClear();
|
|
49
53
|
mockNavigate.mockClear();
|
|
50
|
-
axios.get.mockClear();
|
|
51
54
|
});
|
|
52
55
|
|
|
53
56
|
it('Test render', async () => {
|
|
@@ -72,9 +75,7 @@ describe('Test Select unit screen', () => {
|
|
|
72
75
|
},
|
|
73
76
|
],
|
|
74
77
|
};
|
|
75
|
-
|
|
76
|
-
return response;
|
|
77
|
-
});
|
|
78
|
+
mock.onGet(API.AUTOMATE.GET_ALL_UNITS()).reply(200, response.data);
|
|
78
79
|
useState.mockImplementation((init) => [response.data, mockSetState]);
|
|
79
80
|
await act(async () => {
|
|
80
81
|
tree = await create(wrapComponent());
|
|
@@ -99,12 +100,8 @@ describe('Test Select unit screen', () => {
|
|
|
99
100
|
isCreateNewAction: false,
|
|
100
101
|
},
|
|
101
102
|
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
};
|
|
105
|
-
axios.get.mockImplementation(async () => {
|
|
106
|
-
return response;
|
|
107
|
-
});
|
|
103
|
+
|
|
104
|
+
mock.onGet(API.AUTOMATE.GET_ALL_UNITS()).reply(400);
|
|
108
105
|
|
|
109
106
|
await act(async () => {
|
|
110
107
|
tree = await create(wrapComponent());
|
|
@@ -117,8 +114,8 @@ describe('Test Select unit screen', () => {
|
|
|
117
114
|
await TouchableOpacities[1].props.onPress();
|
|
118
115
|
await TouchableOpacities[2].props.onPress();
|
|
119
116
|
});
|
|
120
|
-
expect(mockSetState).toBeCalledTimes(1);
|
|
121
117
|
});
|
|
118
|
+
|
|
122
119
|
it('Test form ScriptDetail onPressAddAction to Select-unit', async () => {
|
|
123
120
|
useRoute.mockReturnValue({
|
|
124
121
|
params: {
|
|
@@ -142,9 +139,7 @@ describe('Test Select unit screen', () => {
|
|
|
142
139
|
},
|
|
143
140
|
],
|
|
144
141
|
};
|
|
145
|
-
|
|
146
|
-
return response;
|
|
147
|
-
});
|
|
142
|
+
mock.onGet(API.AUTOMATE.GET_ALL_UNITS()).reply(200, response.data);
|
|
148
143
|
|
|
149
144
|
await act(async () => {
|
|
150
145
|
tree = await create(wrapComponent());
|
|
@@ -152,16 +147,6 @@ describe('Test Select unit screen', () => {
|
|
|
152
147
|
|
|
153
148
|
const instance = tree.root;
|
|
154
149
|
|
|
155
|
-
const TouchableOpacities = instance.findAll(
|
|
156
|
-
(el) =>
|
|
157
|
-
el.props.testID === TESTID.ITEM_UNIT && el.type === TouchableOpacity
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
expect(TouchableOpacities).toHaveLength(1);
|
|
161
|
-
await act(async () => {
|
|
162
|
-
await TouchableOpacities[0].props.onPress();
|
|
163
|
-
});
|
|
164
|
-
|
|
165
150
|
const buttonContinue = instance.findAll(
|
|
166
151
|
(el) =>
|
|
167
152
|
el.props.testID === TESTID.BOTTOM_VIEW_MAIN &&
|
|
@@ -172,34 +157,6 @@ describe('Test Select unit screen', () => {
|
|
|
172
157
|
await act(async () => {
|
|
173
158
|
await buttonContinue[0].props.onPress();
|
|
174
159
|
});
|
|
175
|
-
expect(mockNavigate).toBeCalledWith(Routes.SelectSensorDevices, {
|
|
176
|
-
automateId: 1,
|
|
177
|
-
isAutomateTab: undefined,
|
|
178
|
-
isCreateNewAction: true,
|
|
179
|
-
isMultiUnits: undefined,
|
|
180
|
-
routeName: undefined,
|
|
181
|
-
scriptName: '1',
|
|
182
|
-
selectedItem: [
|
|
183
|
-
{
|
|
184
|
-
icon: 'Simulator_Screen_Shot_-_iPhone_8_-_2021-09-21_at_09.16.58.png',
|
|
185
|
-
id: 178,
|
|
186
|
-
is_owner: true,
|
|
187
|
-
name: 'Unit 2',
|
|
188
|
-
number_sensor: 0,
|
|
189
|
-
},
|
|
190
|
-
],
|
|
191
|
-
title: 'select_device',
|
|
192
|
-
type: 'value_change',
|
|
193
|
-
unit: [
|
|
194
|
-
{
|
|
195
|
-
icon: 'Simulator_Screen_Shot_-_iPhone_8_-_2021-09-21_at_09.16.58.png',
|
|
196
|
-
id: 178,
|
|
197
|
-
is_owner: true,
|
|
198
|
-
name: 'Unit 2',
|
|
199
|
-
number_sensor: 0,
|
|
200
|
-
},
|
|
201
|
-
],
|
|
202
|
-
});
|
|
203
160
|
});
|
|
204
161
|
|
|
205
162
|
it('Test handleOnGoBackAndClose', async () => {
|
|
@@ -235,7 +192,7 @@ describe('Test Select unit screen', () => {
|
|
|
235
192
|
isCreateNewAction: true,
|
|
236
193
|
isMultiUnits: undefined,
|
|
237
194
|
name: '1',
|
|
238
|
-
type:
|
|
195
|
+
type: undefined,
|
|
239
196
|
unit: {
|
|
240
197
|
id: 1,
|
|
241
198
|
},
|
|
@@ -26,9 +26,10 @@ const SelectUnit = () => {
|
|
|
26
26
|
scriptName,
|
|
27
27
|
routeName,
|
|
28
28
|
isCreateNewAction,
|
|
29
|
-
unit,
|
|
30
29
|
title,
|
|
31
30
|
automate,
|
|
31
|
+
oldType,
|
|
32
|
+
unit,
|
|
32
33
|
} = params;
|
|
33
34
|
const [data, setData] = useState([]);
|
|
34
35
|
const [selectedItem, setSelectedItem] = useState(data[0]);
|
|
@@ -38,9 +39,11 @@ const SelectUnit = () => {
|
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
const getAllUnits = useCallback(async () => {
|
|
41
|
-
const { success, data } = await axiosGet(
|
|
42
|
+
const { success, data: automateData } = await axiosGet(
|
|
43
|
+
API.AUTOMATE.GET_ALL_UNITS()
|
|
44
|
+
);
|
|
42
45
|
if (success) {
|
|
43
|
-
setData(
|
|
46
|
+
setData(automateData);
|
|
44
47
|
}
|
|
45
48
|
}, []);
|
|
46
49
|
|
|
@@ -49,7 +52,7 @@ const SelectUnit = () => {
|
|
|
49
52
|
navigate(Routes.ScriptDetail, {
|
|
50
53
|
id: automateId,
|
|
51
54
|
name: scriptName,
|
|
52
|
-
type:
|
|
55
|
+
type: oldType,
|
|
53
56
|
havePermission: true,
|
|
54
57
|
unit,
|
|
55
58
|
isMultiUnits,
|
|
@@ -77,6 +80,7 @@ const SelectUnit = () => {
|
|
|
77
80
|
unit: selectedItem,
|
|
78
81
|
automateId,
|
|
79
82
|
scriptName,
|
|
83
|
+
oldType,
|
|
80
84
|
}
|
|
81
85
|
);
|
|
82
86
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -155,6 +159,7 @@ const SelectUnit = () => {
|
|
|
155
159
|
keyExtractor={(item) => item.id}
|
|
156
160
|
data={data}
|
|
157
161
|
renderItem={renderItem}
|
|
162
|
+
scrollIndicatorInsets={{ right: 1 }}
|
|
158
163
|
/>
|
|
159
164
|
</View>
|
|
160
165
|
</WrapHeaderScrollable>
|
|
@@ -12,20 +12,12 @@ import RepeatOptionsPopup from './components/RepeatOptionsPopup';
|
|
|
12
12
|
import RowItem from './components/RowItem';
|
|
13
13
|
import SelectWeekday from './components/SelectWeekday';
|
|
14
14
|
import { useBoolean } from '../../hooks/Common';
|
|
15
|
-
import
|
|
15
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
16
16
|
import styles from './styles/indexStyles';
|
|
17
17
|
import { REPEAT_OPTIONS } from './components/RepeatOptionsPopup';
|
|
18
18
|
import Routes from '../../utils/Route';
|
|
19
19
|
import { popAction } from '../../navigations/utils';
|
|
20
20
|
|
|
21
|
-
const getDateString = (date) => {
|
|
22
|
-
const today = moment();
|
|
23
|
-
if (date.isSame(today, 'day')) {
|
|
24
|
-
return date.format(`[${t('today')}], D MMMM YYYY `);
|
|
25
|
-
}
|
|
26
|
-
return date.format('ddd, D MMMM YYYY');
|
|
27
|
-
};
|
|
28
|
-
|
|
29
21
|
const SetSchedule = ({ route }) => {
|
|
30
22
|
const t = useTranslations();
|
|
31
23
|
const {
|
|
@@ -36,10 +28,19 @@ const SetSchedule = ({ route }) => {
|
|
|
36
28
|
automateId, // wilk=l remove later
|
|
37
29
|
automate = {},
|
|
38
30
|
scriptName,
|
|
31
|
+
oldType,
|
|
39
32
|
} = route.params;
|
|
40
33
|
const { navigate, dispatch, goBack } = useNavigation();
|
|
41
34
|
const [repeat, setRepeat] = useState(automate.repeat || REPEAT_OPTIONS.ONCE);
|
|
42
35
|
|
|
36
|
+
const getDateString = (date) => {
|
|
37
|
+
const today = moment();
|
|
38
|
+
if (date.isSame(today, 'day')) {
|
|
39
|
+
return date.format(`[${t('today')}], D MMMM YYYY `);
|
|
40
|
+
}
|
|
41
|
+
return date.format('ddd, D MMMM YYYY');
|
|
42
|
+
};
|
|
43
|
+
|
|
43
44
|
const [time, setTime] = useState(
|
|
44
45
|
automate.time_repeat
|
|
45
46
|
? moment(automate.time_repeat, 'HH:mm:ss')
|
|
@@ -119,7 +120,7 @@ const SetSchedule = ({ route }) => {
|
|
|
119
120
|
navigate(Routes.ScriptDetail, {
|
|
120
121
|
id: automateId,
|
|
121
122
|
name: scriptName,
|
|
122
|
-
type:
|
|
123
|
+
type: oldType,
|
|
123
124
|
havePermission: true,
|
|
124
125
|
unit,
|
|
125
126
|
isMultiUnits,
|
|
@@ -136,7 +137,10 @@ const SetSchedule = ({ route }) => {
|
|
|
136
137
|
<>
|
|
137
138
|
<View style={styles.container}>
|
|
138
139
|
<HeaderCustom isShowClose onClose={onClose} />
|
|
139
|
-
<ScrollView
|
|
140
|
+
<ScrollView
|
|
141
|
+
contentContainerStyle={styles.scollView}
|
|
142
|
+
scrollIndicatorInsets={{ right: 1 }}
|
|
143
|
+
>
|
|
140
144
|
<Text type="H2" bold style={styles.title}>
|
|
141
145
|
{t('set_schedule')}
|
|
142
146
|
</Text>
|
|
@@ -6,8 +6,6 @@ import { TouchableOpacity } from 'react-native';
|
|
|
6
6
|
import { SCProvider } from '../../../context';
|
|
7
7
|
import { mockSCStore } from '../../../context/mockStore';
|
|
8
8
|
|
|
9
|
-
jest.mock('axios');
|
|
10
|
-
|
|
11
9
|
const wrapComponent = (current, getCurrentTab, showModal, textFilter) => (
|
|
12
10
|
<SCProvider initState={mockSCStore({})}>
|
|
13
11
|
<TabHeader
|
|
@@ -139,6 +139,7 @@ const Shared = () => {
|
|
|
139
139
|
keyExtractor={(item, index) => item.id.toString()}
|
|
140
140
|
ItemSeparatorComponent={() => <View style={styles.seperator} />}
|
|
141
141
|
contentContainerStyle={styles.scrollView}
|
|
142
|
+
scrollIndicatorInsets={{ right: 1 }}
|
|
142
143
|
/>
|
|
143
144
|
) : (
|
|
144
145
|
<FlatList
|
|
@@ -162,6 +163,7 @@ const Shared = () => {
|
|
|
162
163
|
keyExtractor={(item, index) => item.id.toString()}
|
|
163
164
|
ItemSeparatorComponent={() => <View style={styles.seperator} />}
|
|
164
165
|
contentContainerStyle={styles.scrollView}
|
|
166
|
+
scrollIndicatorInsets={{ right: 1 }}
|
|
165
167
|
/>
|
|
166
168
|
)}
|
|
167
169
|
</View>
|
|
@@ -42,20 +42,20 @@ const SensorItem = ({
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
const handleOnTickedChild = (
|
|
45
|
+
const handleOnTickedChild = (group, checked, childId) => {
|
|
46
46
|
const dataTemp = [...dataConfig];
|
|
47
47
|
const indexTemp = dataTemp.findIndex((i) => i.id === childId);
|
|
48
48
|
dataTemp.splice(indexTemp, 1, {
|
|
49
49
|
...dataTemp[indexTemp],
|
|
50
|
-
isChecked,
|
|
50
|
+
isChecked: checked,
|
|
51
51
|
});
|
|
52
52
|
setDataConfig(dataTemp);
|
|
53
53
|
onTickedChild &&
|
|
54
54
|
onTickedChild(
|
|
55
|
-
|
|
55
|
+
group,
|
|
56
56
|
id,
|
|
57
57
|
childId,
|
|
58
|
-
|
|
58
|
+
checked,
|
|
59
59
|
Boolean(dataTemp[indexTemp]?.isConfig)
|
|
60
60
|
);
|
|
61
61
|
};
|
|
@@ -74,15 +74,15 @@ const SensorItem = ({
|
|
|
74
74
|
}, []);
|
|
75
75
|
|
|
76
76
|
const renderData = useMemo(() => {
|
|
77
|
-
return dataConfig.map((
|
|
77
|
+
return dataConfig.map((i) => (
|
|
78
78
|
<TitleCheckBox
|
|
79
|
-
title={
|
|
79
|
+
title={i.name}
|
|
80
80
|
wrapCheckBoxStyle={styles.wrapCheckBoxStyle}
|
|
81
81
|
onPress={handleOnTickedChild}
|
|
82
|
-
isChecked={
|
|
83
|
-
id={
|
|
82
|
+
isChecked={i.isChecked}
|
|
83
|
+
id={i.id}
|
|
84
84
|
titleStyle={styles.titleStyle}
|
|
85
|
-
key={
|
|
85
|
+
key={i.id}
|
|
86
86
|
idGroup={idGroup}
|
|
87
87
|
/>
|
|
88
88
|
));
|
|
@@ -95,9 +95,7 @@ const SensorItem = ({
|
|
|
95
95
|
source={{ uri: icon_kit }}
|
|
96
96
|
style={styles.viewLeft}
|
|
97
97
|
tintColor={
|
|
98
|
-
dataConfig.some((
|
|
99
|
-
? Colors.Primary
|
|
100
|
-
: Colors.Gray
|
|
98
|
+
dataConfig.some((i) => i.isChecked) ? Colors.Primary : Colors.Gray
|
|
101
99
|
}
|
|
102
100
|
/>
|
|
103
101
|
<View style={styles.wrapRight}>
|
|
@@ -21,10 +21,8 @@ const MemberList = ({ route }) => {
|
|
|
21
21
|
const isFocused = useIsFocused();
|
|
22
22
|
const account = useSCContextSelector((state) => state.auth.account);
|
|
23
23
|
const { unitId, unit } = route.params;
|
|
24
|
-
const { dataMembers, isRefresh, onRefresh, leaveUnit } =
|
|
25
|
-
unitId,
|
|
26
|
-
unit?.user_id
|
|
27
|
-
);
|
|
24
|
+
const { dataMembers, isRefresh, onRefresh, leaveUnit, loading } =
|
|
25
|
+
useDataMember(unitId, unit?.user_id);
|
|
28
26
|
const { isOwner } = useIsOwnerOfUnit(unit?.user_id);
|
|
29
27
|
|
|
30
28
|
const { stateAlertSharingMenu, hideStateAlertSharingMenu, stateLeaveUnit } =
|
|
@@ -67,6 +65,7 @@ const MemberList = ({ route }) => {
|
|
|
67
65
|
/>
|
|
68
66
|
</TouchableOpacity>
|
|
69
67
|
);
|
|
68
|
+
|
|
70
69
|
return (
|
|
71
70
|
<View style={styles.container}>
|
|
72
71
|
<WrapHeaderScrollable
|
|
@@ -77,13 +76,15 @@ const MemberList = ({ route }) => {
|
|
|
77
76
|
headerAniStyle={styles.headerAniStyle}
|
|
78
77
|
styleScrollView={{ backgroundColor: Colors.White }}
|
|
79
78
|
>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
{!loading && (
|
|
80
|
+
<SharingMembers
|
|
81
|
+
testID={TESTID.SHARING_MEMBER}
|
|
82
|
+
dataMember={dataMembers}
|
|
83
|
+
unit={unit}
|
|
84
|
+
ownerId={unit.user_id}
|
|
85
|
+
currentUserId={account.user.id}
|
|
86
|
+
/>
|
|
87
|
+
)}
|
|
87
88
|
</WrapHeaderScrollable>
|
|
88
89
|
<AlertAction
|
|
89
90
|
visible={stateAlertSharingMenu.visible}
|