@eohjsc/react-native-smart-city 0.2.99 → 0.3.2
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 +1 -1
- package/package.json +6 -4
- package/react-native-smart-city.podspec +1 -0
- 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 +31 -20
- 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/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 +0 -1
- 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/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 +72 -25
- 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/__test__/index.test.js +19 -14
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +0 -3
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +0 -3
- package/src/commons/FieldTemplate/ScheduleField/index.js +2 -2
- 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 +24 -55
- 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 +8 -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 +2 -2
- package/src/configs/API.js +85 -144
- package/src/configs/Constants.js +24 -0
- package/src/configs/SCConfig.js +2 -0
- package/src/context/actionType.ts +8 -0
- package/src/context/mockStore.ts +10 -0
- package/src/context/reducer.ts +38 -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 +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 +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/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/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/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 +9 -23
- 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 +32 -85
- 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 +53 -22
- 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 +1 -1
- 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 +13 -40
- 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/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 +16 -11
- package/src/screens/SelectUnit/__test__/index.test.js +11 -54
- package/src/screens/SelectUnit/index.js +4 -2
- package/src/screens/SetSchedule/index.js +9 -9
- 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 -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/SideMenuDetail/__test__/index.test.js +12 -23
- package/src/screens/SideMenuDetail/index.js +2 -3
- 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/components/WaterQuality/Item/index.js +10 -2
- 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 +4 -1
- package/src/utils/I18n/translations/vi.json +5 -1
- package/src/utils/Permission/common.js +67 -0
- package/src/utils/Utils.js +11 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
|
-
import
|
|
3
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
4
4
|
import AddLGDevice from '../AddLGDevice';
|
|
5
5
|
import API from '../../../configs/API';
|
|
6
6
|
import GroupCheckBox from '../../../commons/GroupCheckBox';
|
|
@@ -11,8 +11,9 @@ import { ToastBottomHelper } from '../../../utils/Utils';
|
|
|
11
11
|
import Routes from '../../../utils/Route';
|
|
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 mock = new MockAdapter(api.axiosInstance);
|
|
16
17
|
|
|
17
18
|
const mockedNavigate = jest.fn();
|
|
18
19
|
const mockedGoBack = jest.fn();
|
|
@@ -54,11 +55,6 @@ describe('Test Add LG Device', () => {
|
|
|
54
55
|
};
|
|
55
56
|
});
|
|
56
57
|
|
|
57
|
-
afterEach(() => {
|
|
58
|
-
axios.get.mockClear();
|
|
59
|
-
axios.post.mockClear();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
58
|
const getText = (instance, id) => {
|
|
63
59
|
return instance.find((el) => el.props.testID === id);
|
|
64
60
|
};
|
|
@@ -91,16 +87,11 @@ describe('Test Add LG Device', () => {
|
|
|
91
87
|
stations: [{ id: 2, name: 'Station name' }],
|
|
92
88
|
},
|
|
93
89
|
};
|
|
94
|
-
|
|
95
|
-
return response;
|
|
96
|
-
});
|
|
97
|
-
|
|
90
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, response.data);
|
|
98
91
|
await act(async () => {
|
|
99
92
|
tree = await create(wrapComponent(route));
|
|
100
93
|
});
|
|
101
94
|
const instance = tree.root;
|
|
102
|
-
expect(axios.get).toHaveBeenCalledWith(API.UNIT.UNIT_DETAIL(1), {});
|
|
103
|
-
|
|
104
95
|
const groupCheckBox = instance.findByType(GroupCheckBox);
|
|
105
96
|
expect(groupCheckBox.props.data).toEqual([
|
|
106
97
|
{ id: 2, name: 'Station name', title: 'Station name' },
|
|
@@ -108,19 +99,11 @@ describe('Test Add LG Device', () => {
|
|
|
108
99
|
});
|
|
109
100
|
|
|
110
101
|
test('fetchDetails fail', async () => {
|
|
111
|
-
|
|
112
|
-
data: {},
|
|
113
|
-
};
|
|
114
|
-
axios.get.mockImplementation(async () => {
|
|
115
|
-
return response;
|
|
116
|
-
});
|
|
117
|
-
|
|
102
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(400);
|
|
118
103
|
await act(async () => {
|
|
119
104
|
tree = await create(wrapComponent(route));
|
|
120
105
|
});
|
|
121
106
|
const instance = tree.root;
|
|
122
|
-
expect(axios.get).toHaveBeenCalledWith(API.UNIT.UNIT_DETAIL(1), {});
|
|
123
|
-
|
|
124
107
|
const groupCheckBox = instance.findByType(GroupCheckBox);
|
|
125
108
|
expect(groupCheckBox.props.data).toEqual([]);
|
|
126
109
|
});
|
|
@@ -161,7 +144,7 @@ describe('Test Add LG Device', () => {
|
|
|
161
144
|
await act(async () => {
|
|
162
145
|
viewButtonBottom.props.onRightClick();
|
|
163
146
|
});
|
|
164
|
-
expect(mockedNavigate).
|
|
147
|
+
expect(mockedNavigate).toHaveBeenCalled();
|
|
165
148
|
});
|
|
166
149
|
|
|
167
150
|
test('ViewButtonBottom onRightClick with stationId', async () => {
|
|
@@ -173,9 +156,7 @@ describe('Test Add LG Device', () => {
|
|
|
173
156
|
stations: [{ id: 2, name: 'Station name' }],
|
|
174
157
|
},
|
|
175
158
|
};
|
|
176
|
-
|
|
177
|
-
return response;
|
|
178
|
-
});
|
|
159
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, response.data);
|
|
179
160
|
|
|
180
161
|
const responseToken = {
|
|
181
162
|
status: 200,
|
|
@@ -183,20 +164,9 @@ describe('Test Add LG Device', () => {
|
|
|
183
164
|
access_token: 'ACCESS_TOKEN',
|
|
184
165
|
},
|
|
185
166
|
};
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
const responseSync = {
|
|
191
|
-
status: 200,
|
|
192
|
-
data: {},
|
|
193
|
-
};
|
|
194
|
-
axios.post.mockImplementationOnce(async () => {
|
|
195
|
-
return responseSync;
|
|
196
|
-
});
|
|
197
|
-
|
|
167
|
+
mock.onPost(API.IOT.LG.GET_TOKEN()).reply(200, responseToken.data);
|
|
168
|
+
mock.onPost(API.IOT.LG.SYNC_DEVICE()).reply(200, {});
|
|
198
169
|
const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
|
|
199
|
-
|
|
200
170
|
await act(async () => {
|
|
201
171
|
tree = await create(wrapComponent(route));
|
|
202
172
|
});
|
|
@@ -210,10 +180,6 @@ describe('Test Add LG Device', () => {
|
|
|
210
180
|
await act(async () => {
|
|
211
181
|
viewButtonBottom.props.onRightClick();
|
|
212
182
|
});
|
|
213
|
-
|
|
214
|
-
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
215
|
-
expect(axios.post).toHaveBeenCalledTimes(2);
|
|
216
|
-
expect(spyToastSuccess).toBeCalled();
|
|
217
183
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.Dashboard);
|
|
218
184
|
|
|
219
185
|
spyToastSuccess.mockReset();
|
|
@@ -229,27 +195,8 @@ describe('Test Add LG Device', () => {
|
|
|
229
195
|
stations: [{ id: 2, name: 'Station name' }],
|
|
230
196
|
},
|
|
231
197
|
};
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
const responseToken = {
|
|
237
|
-
status: 200,
|
|
238
|
-
data: {
|
|
239
|
-
access_token: 'ACCESS_TOKEN',
|
|
240
|
-
},
|
|
241
|
-
};
|
|
242
|
-
axios.post.mockImplementationOnce(async () => {
|
|
243
|
-
return responseToken;
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
const responseSync = {
|
|
247
|
-
data: {},
|
|
248
|
-
};
|
|
249
|
-
axios.post.mockImplementationOnce(async () => {
|
|
250
|
-
return responseSync;
|
|
251
|
-
});
|
|
252
|
-
|
|
198
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, response.data);
|
|
199
|
+
mock.onPost(API.IOT.LG.GET_TOKEN()).reply(200, response.data);
|
|
253
200
|
const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
|
|
254
201
|
const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
|
|
255
202
|
|
|
@@ -266,13 +213,9 @@ describe('Test Add LG Device', () => {
|
|
|
266
213
|
await act(async () => {
|
|
267
214
|
viewButtonBottom.props.onRightClick();
|
|
268
215
|
});
|
|
269
|
-
|
|
270
|
-
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
271
|
-
expect(axios.post).toHaveBeenCalledTimes(2);
|
|
272
216
|
expect(spyToastSuccess).not.toBeCalled();
|
|
273
217
|
expect(spyToastError).toBeCalled();
|
|
274
218
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.Dashboard);
|
|
275
|
-
|
|
276
219
|
spyToastSuccess.mockReset();
|
|
277
220
|
spyToastSuccess.mockRestore();
|
|
278
221
|
});
|
|
@@ -286,10 +229,7 @@ describe('Test Add LG Device', () => {
|
|
|
286
229
|
stations: [{ id: 2, name: 'Station name' }],
|
|
287
230
|
},
|
|
288
231
|
};
|
|
289
|
-
|
|
290
|
-
return response;
|
|
291
|
-
});
|
|
292
|
-
|
|
232
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, response.data);
|
|
293
233
|
const responseToken = {
|
|
294
234
|
status: 200,
|
|
295
235
|
data: {
|
|
@@ -300,10 +240,7 @@ describe('Test Add LG Device', () => {
|
|
|
300
240
|
},
|
|
301
241
|
},
|
|
302
242
|
};
|
|
303
|
-
|
|
304
|
-
return responseToken;
|
|
305
|
-
});
|
|
306
|
-
|
|
243
|
+
mock.onPost(API.IOT.LG.GET_TOKEN()).reply(200, responseToken.data);
|
|
307
244
|
const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
|
|
308
245
|
const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
|
|
309
246
|
|
|
@@ -321,8 +258,6 @@ describe('Test Add LG Device', () => {
|
|
|
321
258
|
viewButtonBottom.props.onRightClick();
|
|
322
259
|
});
|
|
323
260
|
|
|
324
|
-
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
325
|
-
expect(axios.post).toHaveBeenCalledTimes(1); // called once
|
|
326
261
|
expect(spyToastSuccess).not.toBeCalled();
|
|
327
262
|
expect(spyToastError).toBeCalled();
|
|
328
263
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.Dashboard);
|
|
@@ -340,16 +275,7 @@ describe('Test Add LG Device', () => {
|
|
|
340
275
|
stations: [{ id: 2, name: 'Station name' }],
|
|
341
276
|
},
|
|
342
277
|
};
|
|
343
|
-
|
|
344
|
-
return response;
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
const responseToken = {
|
|
348
|
-
data: {},
|
|
349
|
-
};
|
|
350
|
-
axios.post.mockImplementationOnce(async () => {
|
|
351
|
-
return responseToken;
|
|
352
|
-
});
|
|
278
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(200, response.data);
|
|
353
279
|
|
|
354
280
|
const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
|
|
355
281
|
const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
|
|
@@ -368,8 +294,6 @@ describe('Test Add LG Device', () => {
|
|
|
368
294
|
viewButtonBottom.props.onRightClick();
|
|
369
295
|
});
|
|
370
296
|
|
|
371
|
-
expect(axios.get).toHaveBeenCalledTimes(1);
|
|
372
|
-
expect(axios.post).toHaveBeenCalledTimes(1); // called once
|
|
373
297
|
expect(spyToastSuccess).not.toBeCalled();
|
|
374
298
|
expect(spyToastError).toBeCalled();
|
|
375
299
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.Dashboard);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
1
|
import React, { memo, useCallback, useRef, useState } from 'react';
|
|
3
2
|
import { View } from 'react-native';
|
|
4
3
|
import MapView, { PROVIDER_GOOGLE } from 'react-native-maps';
|
|
@@ -8,24 +7,17 @@ import BottomButtonView from '../../commons/BottomButtonView';
|
|
|
8
7
|
import { FullLoading } from '../../commons';
|
|
9
8
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
10
9
|
|
|
11
|
-
navigator.geolocation = require('@react-native-community/geolocation');
|
|
12
|
-
|
|
13
10
|
import styles from './ChooseLocationStyles';
|
|
14
11
|
import { API } from '../../configs';
|
|
15
12
|
import { axiosGet } from '../../utils/Apis/axios';
|
|
16
13
|
import { SCConfig } from '../../configs';
|
|
14
|
+
import { MAP_INITIAL_REGION, EOH_LOCATION } from '../../configs/Constants';
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
latitudeDelta: 0.0922,
|
|
20
|
-
longitudeDelta: 0.0421,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const DEFAULT_LATITUDE = 10.7974046; // EoH center
|
|
24
|
-
const DEFAULT_LONGITUDE = 106.7035663;
|
|
16
|
+
navigator.geolocation = require('@react-native-community/geolocation');
|
|
25
17
|
|
|
26
18
|
const ChooseLocation = memo(({ route }) => {
|
|
27
19
|
const t = useTranslations();
|
|
28
|
-
const { location, setAddress, setLocation } = route.params;
|
|
20
|
+
const { location, setAddress, setLocation } = route.params || {};
|
|
29
21
|
const { goBack } = useNavigation();
|
|
30
22
|
const [currentLocation, setCurrentLocation] = useState(location);
|
|
31
23
|
const [loading, setLoading] = useState(false);
|
|
@@ -76,9 +68,10 @@ const ChooseLocation = memo(({ route }) => {
|
|
|
76
68
|
provider={PROVIDER_GOOGLE}
|
|
77
69
|
style={styles.mapView}
|
|
78
70
|
initialRegion={{
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
latitude: location?.latitude || EOH_LOCATION.LAT,
|
|
72
|
+
longitude: location?.longitude || EOH_LOCATION.LNG,
|
|
73
|
+
latitudeDelta: MAP_INITIAL_REGION.LAT,
|
|
74
|
+
longitudeDelta: MAP_INITIAL_REGION.LNG,
|
|
82
75
|
}}
|
|
83
76
|
followUserLocation={true}
|
|
84
77
|
onRegionChangeComplete={onRegionChange}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
useCallback,
|
|
3
|
-
useContext,
|
|
4
3
|
useEffect,
|
|
5
4
|
useState,
|
|
6
5
|
useRef,
|
|
6
|
+
useContext,
|
|
7
7
|
} from 'react';
|
|
8
8
|
import { AppState, RefreshControl, View } from 'react-native';
|
|
9
9
|
import { useIsFocused } from '@react-navigation/native';
|
|
10
|
-
import {
|
|
10
|
+
import { VLCPlayer } from 'react-native-vlc-media-player';
|
|
11
11
|
|
|
12
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
12
13
|
import styles from './styles';
|
|
13
14
|
import AddMenu from './AddMenu';
|
|
14
15
|
import MoreMenu from './MoreMenu';
|
|
@@ -23,10 +24,8 @@ import {
|
|
|
23
24
|
usePopover,
|
|
24
25
|
} from '../../hooks/Common';
|
|
25
26
|
import { useFavorites } from './hook/useFavorites';
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import { axiosPost, fetchWithCache, axiosGet } from '../../utils/Apis/axios';
|
|
29
|
-
import { lgThinqConnect } from '../../iot/RemoteControl/LG';
|
|
27
|
+
import { useUnitConnectRemoteDevices } from './hook/useUnitConnectRemoteDevices';
|
|
28
|
+
import { fetchWithCache, axiosGet } from '../../utils/Apis/axios';
|
|
30
29
|
import ShortDetailSubUnit from '../../commons/SubUnit/ShortDetail';
|
|
31
30
|
import NavBar from '../../commons/NavBar';
|
|
32
31
|
import WrapParallaxScrollView from '../../commons/WrapParallaxScrollView';
|
|
@@ -51,6 +50,7 @@ import PreventAccess from '../../commons/PreventAccess';
|
|
|
51
50
|
|
|
52
51
|
const UnitDetail = ({ route }) => {
|
|
53
52
|
const t = useTranslations();
|
|
53
|
+
const { setAction } = useContext(SCContext);
|
|
54
54
|
|
|
55
55
|
const {
|
|
56
56
|
unitId,
|
|
@@ -63,7 +63,6 @@ const UnitDetail = ({ route }) => {
|
|
|
63
63
|
} = route.params;
|
|
64
64
|
|
|
65
65
|
const isFocused = useIsFocused();
|
|
66
|
-
const { stateData, setAction } = useContext(SCContext);
|
|
67
66
|
const { navigate, goBack } = useNavigation();
|
|
68
67
|
const RouterHardware = useCallback(
|
|
69
68
|
(routeHardware) => () => {
|
|
@@ -76,15 +75,14 @@ const UnitDetail = ({ route }) => {
|
|
|
76
75
|
isSuccessfullyConnected ? RouterHardware(Routes.Dashboard) : goBack
|
|
77
76
|
);
|
|
78
77
|
const user = useSCContextSelector((state) => state?.auth?.account?.user);
|
|
79
|
-
const isLavidaSource = useSCContextSelector(
|
|
80
|
-
(state) => state.app
|
|
78
|
+
const { isLavidaSource, isFirstOpenCamera } = useSCContextSelector(
|
|
79
|
+
(state) => state.app
|
|
81
80
|
);
|
|
82
81
|
|
|
83
82
|
const [unit, setUnit] = useState(unitData || { id: unitId });
|
|
84
83
|
const [listMenuItem, setListMenuItem] = useState([]);
|
|
85
84
|
const [listStation, setListStation] = useState([]);
|
|
86
85
|
const [listAutomate, setListAutomate] = useState([]);
|
|
87
|
-
const [isGGHomeConnected, setIsGGHomeConnected] = useState(false);
|
|
88
86
|
const [station, setStation] = useState({});
|
|
89
87
|
const [indexStation, setIndexStation] = useState(0);
|
|
90
88
|
const [showAdd, setShowAdd, setHideAdd] = useBoolean();
|
|
@@ -191,61 +189,7 @@ const UnitDetail = ({ route }) => {
|
|
|
191
189
|
};
|
|
192
190
|
}, [fetchDetails]);
|
|
193
191
|
|
|
194
|
-
|
|
195
|
-
async (options) => {
|
|
196
|
-
let isConnected = await googleHomeConnect(options); // this may wrong if have multiple connection
|
|
197
|
-
setIsGGHomeConnected(isConnected);
|
|
198
|
-
let chipId = options[0].chip_id;
|
|
199
|
-
if (!isConnected) {
|
|
200
|
-
setAction(Action.LIST_DEVICE_TYPES, {
|
|
201
|
-
chipId: chipId,
|
|
202
|
-
sentEmail: true,
|
|
203
|
-
});
|
|
204
|
-
await axiosPost(API.GOOGLE_HOME.CHECK_SEND_EMAIL(), {
|
|
205
|
-
chip_id: chipId,
|
|
206
|
-
is_connected: false,
|
|
207
|
-
});
|
|
208
|
-
} else if (isConnected && stateData?.listDevice[chipId]?.sentEmail) {
|
|
209
|
-
setAction(Action.LIST_DEVICE_TYPES, {
|
|
210
|
-
chipId: chipId,
|
|
211
|
-
sentEmail: false,
|
|
212
|
-
});
|
|
213
|
-
await axiosPost(API.GOOGLE_HOME.CHECK_SEND_EMAIL(), {
|
|
214
|
-
chip_id: chipId,
|
|
215
|
-
is_connected: true,
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
220
|
-
[]
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
let isCalled = false;
|
|
224
|
-
|
|
225
|
-
const handleLgThinqConnect = useCallback(async (options) => {
|
|
226
|
-
if (isCalled) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
230
|
-
isCalled = true;
|
|
231
|
-
await lgThinqConnect(options);
|
|
232
|
-
}, []);
|
|
233
|
-
|
|
234
|
-
useEffect(() => {
|
|
235
|
-
if (unit.remote_control_options) {
|
|
236
|
-
if (unit.remote_control_options.bluetooth) {
|
|
237
|
-
scanBluetoothDevices(unit.remote_control_options.bluetooth);
|
|
238
|
-
}
|
|
239
|
-
if (unit.remote_control_options.googlehome?.length) {
|
|
240
|
-
handleGoogleHomeConnect(unit.remote_control_options.googlehome);
|
|
241
|
-
}
|
|
242
|
-
if (unit.remote_control_options.lg_thinq) {
|
|
243
|
-
(async () => {
|
|
244
|
-
await handleLgThinqConnect(unit.remote_control_options.lg_thinq);
|
|
245
|
-
})();
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}, [handleGoogleHomeConnect, handleLgThinqConnect, unit]);
|
|
192
|
+
useUnitConnectRemoteDevices(unit);
|
|
249
193
|
|
|
250
194
|
useEffect(() => {
|
|
251
195
|
if (isFocused) {
|
|
@@ -264,7 +208,7 @@ const UnitDetail = ({ route }) => {
|
|
|
264
208
|
setListMenuItem(listMenu);
|
|
265
209
|
setListStation(listMenu.concat([{ text: '' }]));
|
|
266
210
|
}
|
|
267
|
-
}, [unit, indexStation
|
|
211
|
+
}, [unit, indexStation]);
|
|
268
212
|
|
|
269
213
|
useEffect(() => {
|
|
270
214
|
isOneTap && setIndexStation(1);
|
|
@@ -308,7 +252,6 @@ const UnitDetail = ({ route }) => {
|
|
|
308
252
|
favoriteDevices={favoriteDevices}
|
|
309
253
|
favoriteAutomates={favoriteAutomates}
|
|
310
254
|
wrapItemStyle={styles.wrapItemStyle}
|
|
311
|
-
isGGHomeConnected={isGGHomeConnected}
|
|
312
255
|
/>
|
|
313
256
|
);
|
|
314
257
|
}
|
|
@@ -330,13 +273,7 @@ const UnitDetail = ({ route }) => {
|
|
|
330
273
|
/>
|
|
331
274
|
);
|
|
332
275
|
} else if (station) {
|
|
333
|
-
return
|
|
334
|
-
<ShortDetailSubUnit
|
|
335
|
-
unit={unit}
|
|
336
|
-
station={station}
|
|
337
|
-
isGGHomeConnected={isGGHomeConnected}
|
|
338
|
-
/>
|
|
339
|
-
);
|
|
276
|
+
return <ShortDetailSubUnit unit={unit} station={station} />;
|
|
340
277
|
}
|
|
341
278
|
};
|
|
342
279
|
|
|
@@ -353,6 +290,15 @@ const UnitDetail = ({ route }) => {
|
|
|
353
290
|
return () => unwatchNotificationData(user);
|
|
354
291
|
}, [user, onRefresh]);
|
|
355
292
|
|
|
293
|
+
useEffect(() => {
|
|
294
|
+
if (isFirstOpenCamera) {
|
|
295
|
+
const to = setTimeout(() => {
|
|
296
|
+
setAction(Action.IS_FIRST_OPEN_CAMERA, false);
|
|
297
|
+
clearTimeout(to);
|
|
298
|
+
}, 5000);
|
|
299
|
+
}
|
|
300
|
+
}, [isFirstOpenCamera, setAction]);
|
|
301
|
+
|
|
356
302
|
return (
|
|
357
303
|
<WrapParallaxScrollView
|
|
358
304
|
uriImg={unit.background}
|
|
@@ -367,6 +313,16 @@ const UnitDetail = ({ route }) => {
|
|
|
367
313
|
hideRightPlus={!isOwner}
|
|
368
314
|
onBack={(isSuccessfullyConnected && Dashboard) || (routeName && onBack)}
|
|
369
315
|
>
|
|
316
|
+
{/* NOTE: This is a trick to fix camera not full screen on first open app */}
|
|
317
|
+
{isFirstOpenCamera && (
|
|
318
|
+
<VLCPlayer
|
|
319
|
+
source={{
|
|
320
|
+
uri: 'rtsp://admin:Eoh@2020@101.99.33.220:30554/main',
|
|
321
|
+
}}
|
|
322
|
+
style={styles.camera}
|
|
323
|
+
/>
|
|
324
|
+
)}
|
|
325
|
+
|
|
370
326
|
<View style={styles.container}>
|
|
371
327
|
<Summaries unit={unit} />
|
|
372
328
|
<NavBar
|
|
@@ -383,7 +339,6 @@ const UnitDetail = ({ route }) => {
|
|
|
383
339
|
</View>
|
|
384
340
|
)}
|
|
385
341
|
</View>
|
|
386
|
-
|
|
387
342
|
<AddMenu
|
|
388
343
|
unit={unit}
|
|
389
344
|
afterItemClick={hidePopover}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
1
|
import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
3
2
|
import { TouchableOpacity, View, ScrollView } from 'react-native';
|
|
4
3
|
import MapView, { Marker, Circle, PROVIDER_GOOGLE } from 'react-native-maps';
|
|
5
4
|
import { useNavigation } from '@react-navigation/native';
|
|
6
5
|
import { IconOutline, IconFill } from '@ant-design/icons-react-native';
|
|
6
|
+
import { check, RESULTS } from 'react-native-permissions';
|
|
7
7
|
|
|
8
8
|
import BottomButtonView from '../../commons/BottomButtonView';
|
|
9
9
|
import SearchBarLocation from '../../commons/SearchLocation';
|
|
@@ -11,22 +11,23 @@ import RowLocation from '../../commons/SearchLocation/RowLocation';
|
|
|
11
11
|
import Text from '../../commons/Text';
|
|
12
12
|
import { FullLoading } from '../../commons';
|
|
13
13
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
import {
|
|
15
|
+
GEOLOCATION_ERROR,
|
|
16
|
+
keyPermission,
|
|
17
|
+
OpenSetting,
|
|
18
|
+
} from '../../utils/Permission/common';
|
|
16
19
|
|
|
17
20
|
import styles from './SelectAddressStyles';
|
|
18
21
|
import { API, Colors, SCConfig } from '../../configs';
|
|
19
22
|
import { axiosGet } from '../../utils/Apis/axios';
|
|
20
23
|
import Routes from '../../utils/Route';
|
|
21
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
TESTID,
|
|
26
|
+
MAP_INITIAL_REGION,
|
|
27
|
+
EOH_LOCATION,
|
|
28
|
+
} from '../../configs/Constants';
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
latitudeDelta: 0.0922,
|
|
25
|
-
longitudeDelta: 0.0421,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const DEFAULT_LATITUDE = 10.7974046; // EoH center
|
|
29
|
-
const DEFAULT_LONGITUDE = 106.7035663;
|
|
30
|
+
navigator.geolocation = require('@react-native-community/geolocation');
|
|
30
31
|
|
|
31
32
|
const SelectAddress = memo(({ route }) => {
|
|
32
33
|
const t = useTranslations();
|
|
@@ -46,9 +47,9 @@ const SelectAddress = memo(({ route }) => {
|
|
|
46
47
|
goBack();
|
|
47
48
|
}, [goBack, updateLocation, searchedLocation]);
|
|
48
49
|
|
|
49
|
-
const onTextInput = useCallback(async (
|
|
50
|
-
setInput(
|
|
51
|
-
if (
|
|
50
|
+
const onTextInput = useCallback(async (value) => {
|
|
51
|
+
setInput(value);
|
|
52
|
+
if (value === '') {
|
|
52
53
|
setSearchData([]);
|
|
53
54
|
setSearchedLocation(null);
|
|
54
55
|
return;
|
|
@@ -56,7 +57,7 @@ const SelectAddress = memo(({ route }) => {
|
|
|
56
57
|
try {
|
|
57
58
|
const config = {
|
|
58
59
|
params: {
|
|
59
|
-
input:
|
|
60
|
+
input: value,
|
|
60
61
|
key: SCConfig.GOOGLE_MAP_API_KEY,
|
|
61
62
|
sessiontoken: 123456324,
|
|
62
63
|
strictBounds: false,
|
|
@@ -71,6 +72,7 @@ const SelectAddress = memo(({ route }) => {
|
|
|
71
72
|
if (success) {
|
|
72
73
|
setSearchData(data.predictions);
|
|
73
74
|
}
|
|
75
|
+
// eslint-disable-next-line no-empty
|
|
74
76
|
} catch (error) {}
|
|
75
77
|
}, []);
|
|
76
78
|
|
|
@@ -83,7 +85,8 @@ const SelectAddress = memo(({ route }) => {
|
|
|
83
85
|
{
|
|
84
86
|
latitude: lat,
|
|
85
87
|
longitude: lng,
|
|
86
|
-
|
|
88
|
+
latitudeDelta: MAP_INITIAL_REGION.LAT,
|
|
89
|
+
longitudeDelta: MAP_INITIAL_REGION.LNG,
|
|
87
90
|
},
|
|
88
91
|
600
|
|
89
92
|
);
|
|
@@ -140,10 +143,19 @@ const SelectAddress = memo(({ route }) => {
|
|
|
140
143
|
setLoading(false);
|
|
141
144
|
},
|
|
142
145
|
// eslint-disable-next-line promise/prefer-await-to-callbacks
|
|
143
|
-
(error) => {
|
|
146
|
+
async (error) => {
|
|
147
|
+
if (error.code === GEOLOCATION_ERROR.PERMISSION_DENIED) {
|
|
148
|
+
const permissionResult = await check(keyPermission.LOCATION);
|
|
149
|
+
permissionResult === RESULTS.BLOCKED &&
|
|
150
|
+
OpenSetting(
|
|
151
|
+
t('location_rationale_title'),
|
|
152
|
+
t('location_require_message')
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
144
156
|
// { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 } enable on emulator
|
|
145
157
|
);
|
|
146
|
-
}, []);
|
|
158
|
+
}, [t]);
|
|
147
159
|
|
|
148
160
|
const chooseOnMap = useCallback(() => {
|
|
149
161
|
navigate(Routes.ChooseLocation, {
|
|
@@ -202,9 +214,10 @@ const SelectAddress = memo(({ route }) => {
|
|
|
202
214
|
provider={PROVIDER_GOOGLE}
|
|
203
215
|
style={styles.mapView}
|
|
204
216
|
initialRegion={{
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
217
|
+
latitude: EOH_LOCATION.LAT,
|
|
218
|
+
longitude: EOH_LOCATION.LNG,
|
|
219
|
+
latitudeDelta: MAP_INITIAL_REGION.LAT,
|
|
220
|
+
longitudeDelta: MAP_INITIAL_REGION.LNG,
|
|
208
221
|
}}
|
|
209
222
|
followUserLocation={true}
|
|
210
223
|
>
|
|
@@ -29,13 +29,13 @@ const ListSmartAccount = ({ route }) => {
|
|
|
29
29
|
const [loadingRemoveItem, setLoadingRemoveItem] = useState(false);
|
|
30
30
|
|
|
31
31
|
const getAllSmartAccounts = useCallback(async () => {
|
|
32
|
-
const { success, data } = await axiosGet(
|
|
33
|
-
API.SMART_ACCOUNT.LIST_SMART_ACCOUNT()
|
|
32
|
+
const { success, data: accountData } = await axiosGet(
|
|
33
|
+
API.SMART_ACCOUNT.LIST_SMART_ACCOUNT(unitId)
|
|
34
34
|
);
|
|
35
35
|
if (success) {
|
|
36
|
-
setData(
|
|
36
|
+
setData(accountData);
|
|
37
37
|
}
|
|
38
|
-
}, []);
|
|
38
|
+
}, [unitId]);
|
|
39
39
|
|
|
40
40
|
const { childRef, showingPopover, showPopoverWithRef, hidePopover } =
|
|
41
41
|
usePopover();
|
|
@@ -5,6 +5,7 @@ import Routes from '../../utils/Route';
|
|
|
5
5
|
import { useIsFocused, useNavigation } from '@react-navigation/native';
|
|
6
6
|
import { axiosGet } from '../../utils/Apis/axios';
|
|
7
7
|
import { API } from '../../configs';
|
|
8
|
+
import { useReceiveNotifications } from '../../hooks';
|
|
8
9
|
|
|
9
10
|
const Summaries = memo(({ unit }) => {
|
|
10
11
|
const [unitSummaries, setUnitSummaries] = useState([]);
|
|
@@ -33,6 +34,8 @@ const Summaries = memo(({ unit }) => {
|
|
|
33
34
|
const goToSummary = useCallback(
|
|
34
35
|
(summary) => {
|
|
35
36
|
navigation.navigate(Routes.UnitSummary, {
|
|
37
|
+
summaryId: summary.id,
|
|
38
|
+
unitId: unit.id,
|
|
36
39
|
summaryData: summary,
|
|
37
40
|
unitData: unit,
|
|
38
41
|
});
|
|
@@ -50,7 +53,7 @@ const Summaries = memo(({ unit }) => {
|
|
|
50
53
|
if (success) {
|
|
51
54
|
localState.timeoutId = setTimeout(() => {
|
|
52
55
|
continuousFetchSummary();
|
|
53
|
-
},
|
|
56
|
+
}, 10000);
|
|
54
57
|
}
|
|
55
58
|
}, [localState, fetchUnitSummary]);
|
|
56
59
|
|
|
@@ -82,6 +85,19 @@ const Summaries = memo(({ unit }) => {
|
|
|
82
85
|
};
|
|
83
86
|
}, [localState, continuousFetchSummary, isFocused]);
|
|
84
87
|
|
|
88
|
+
const { dataNotification } = useReceiveNotifications();
|
|
89
|
+
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (dataNotification) {
|
|
92
|
+
const { params = {} } = dataNotification;
|
|
93
|
+
const { summary_id } = params;
|
|
94
|
+
if (summary_id) {
|
|
95
|
+
fetchUnitSummary();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
99
|
+
}, [dataNotification]);
|
|
100
|
+
|
|
85
101
|
return (
|
|
86
102
|
<>
|
|
87
103
|
{!unitSummaries || !unitSummaries.length ? null : (
|