@eohjsc/react-native-smart-city 0.3.4 → 0.3.7
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 +15 -36
- package/package.json +5 -9
- package/react-native-smart-city.podspec +0 -1
- package/src/commons/Action/ItemQuickAction.js +4 -16
- package/src/commons/Action/__test__/ItemQuickAction.test.js +6 -11
- package/src/commons/ActionGroup/ColorPickerTemplate.js +24 -37
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +5 -10
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +31 -12
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +0 -4
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +0 -14
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +0 -1
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +2 -8
- package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
- package/src/commons/ActionGroup/OnOffTemplate/index.js +2 -3
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +9 -7
- package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -6
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +3 -7
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +8 -22
- package/src/commons/ActionGroup/TimerActionTemplate.js +3 -11
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +5 -1
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +4 -53
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +83 -3
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +78 -53
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +20 -36
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +57 -1
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +6 -58
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -49
- package/src/commons/ActionGroup/__test__/index.test.js +4 -142
- package/src/commons/Auth/AccountList.js +1 -1
- package/src/commons/Automate/ItemAutomate.js +3 -1
- package/src/commons/Connecting/__test__/Connecting.test.js +2 -19
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +3 -7
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +11 -8
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +3 -136
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +2 -3
- package/src/commons/ConnectingProcess/index.js +25 -75
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +13 -16
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +5 -0
- package/src/commons/Device/ConnectedViewHeader.js +1 -1
- package/src/commons/Device/HistoryChart.js +3 -7
- package/src/commons/Device/ItemDevice.js +12 -19
- package/src/commons/Device/LinearChart.js +0 -15
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +12 -16
- package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +0 -3
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +0 -1
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +2 -7
- package/src/commons/Explore/__test__/CityItem.test.js +54 -33
- package/src/commons/Form/CurrencyInput.js +1 -15
- package/src/commons/Form/TextInputPassword.js +1 -1
- package/src/commons/FullLoading/index.js +1 -2
- package/src/commons/Header/HeaderCustom.js +1 -2
- package/src/commons/HeaderAni/index.js +1 -6
- package/src/commons/HorizontalPicker/index.js +2 -2
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +6 -0
- package/src/commons/MediaPlayerDetail/index.js +47 -25
- package/src/commons/MenuActionAddnew/index.js +0 -1
- package/src/commons/MenuActionList/index.js +0 -1
- package/src/commons/MenuActionMore/index.js +1 -1
- package/src/commons/PreventAccess/index.js +1 -9
- package/src/commons/Sharing/MemberList.js +2 -10
- package/src/commons/Sharing/WrapHeaderScrollable.js +0 -2
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +1 -0
- package/src/commons/SubUnit/Favorites/index.js +3 -2
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +35 -8
- package/src/commons/SubUnit/OneTap/index.js +2 -1
- package/src/commons/SubUnit/ShortDetail.js +9 -25
- package/src/commons/SubUnit/__test__/Item.test.js +1 -0
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +2 -9
- package/src/commons/Unit/SharedUnit.js +0 -1
- package/src/commons/Unit/__test__/SharedUnit.test.js +183 -38
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +13 -2
- package/src/commons/UnitSummary/ConfigHistoryChart.js +13 -22
- package/src/commons/WheelDateTimePicker/index.js +3 -4
- package/src/configs/API.js +143 -87
- package/src/configs/Constants.js +2 -57
- package/src/configs/SCConfig.js +0 -4
- package/src/context/actionType.ts +0 -8
- package/src/context/mockStore.ts +0 -10
- package/src/context/reducer.ts +2 -38
- package/src/hooks/Common/index.js +0 -2
- package/src/hooks/Common/useGetIdUser.js +5 -1
- package/src/hooks/Common/useSensorsStatus.js +4 -4
- package/src/hooks/useReceiveNotifications.js +5 -9
- package/src/iot/Monitor.js +2 -3
- package/src/iot/RemoteControl/Bluetooth.js +1 -1
- package/src/iot/RemoteControl/GoogleHome.js +49 -75
- package/src/iot/RemoteControl/Internet.js +1 -1
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +48 -95
- package/src/iot/RemoteControl/__test__/Internet.test.js +7 -18
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +177 -36
- package/src/iot/RemoteControl/index.js +52 -52
- package/src/navigations/UnitStack.js +20 -11
- package/src/screens/AQIGuide/index.js +1 -1
- package/src/screens/ActivityLog/FilterPopup.js +0 -2
- package/src/screens/ActivityLog/__test__/index.test.js +23 -38
- package/src/screens/ActivityLog/hooks/__test__/index.test.js +90 -51
- package/src/screens/ActivityLog/hooks/index.js +1 -1
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddCommon/SelectSubUnit.js +0 -1
- package/src/screens/AddCommon/SelectUnit.js +0 -1
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +24 -13
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +33 -9
- package/src/screens/AddLocationMaps/index.js +5 -9
- package/src/screens/AddNewAction/SelectAction.js +8 -8
- package/src/screens/AddNewAction/SelectSensorDevices.js +2 -8
- package/src/screens/AddNewAction/SetupSensor.js +7 -7
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +91 -10
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +26 -40
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +1 -3
- package/src/screens/AddNewAutoSmart/index.js +2 -5
- package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +34 -42
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +4 -0
- 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 +0 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +17 -23
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +4 -7
- package/src/screens/AddNewGateway/SelectGateway.js +0 -1
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +0 -2
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +6 -4
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +4 -0
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +29 -5
- package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +4 -0
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +4 -0
- package/src/screens/AddNewGateway/index.js +0 -1
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +24 -10
- package/src/screens/AddNewOneTap/index.js +2 -3
- package/src/screens/AllCamera/index.js +4 -4
- package/src/screens/Automate/MultiUnits.js +8 -8
- package/src/screens/Automate/__test__/MultiUnits.test.js +9 -6
- package/src/screens/Automate/__test__/index.test.js +12 -7
- package/src/screens/Automate/index.js +3 -5
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +8 -36
- package/src/screens/ConfirmUnitDeletion/index.js +1 -7
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +22 -71
- package/src/screens/Device/EditDevice/index.js +15 -17
- package/src/screens/Device/__test__/detail.test.js +86 -33
- package/src/screens/Device/components/DetailHistoryChart.js +1 -1
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +0 -1
- package/src/screens/Device/components/SensorDisplayItem.js +2 -5
- package/src/screens/Device/detail.js +24 -80
- package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
- package/src/screens/Device/hooks/useFavoriteDevice.js +9 -5
- package/src/screens/DeviceInfo/__test__/index.test.js +2 -0
- package/src/screens/EditActionsList/index.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -6
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +19 -7
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +2 -20
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +23 -40
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EmergencySetting/index.js +1 -4
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +25 -41
- package/src/screens/Explore/index.js +0 -2
- package/src/screens/GuestInfo/__test__/index.test.js +41 -14
- package/src/screens/GuestInfo/components/RecurringDetail.js +0 -1
- 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 +12 -8
- package/src/screens/HanetCamera/__test__/Detail.test.js +42 -27
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +5 -8
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +32 -10
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -3
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +35 -43
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +21 -10
- 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 +22 -33
- package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +45 -44
- package/src/screens/ManageAccess/hooks/index.js +4 -7
- package/src/screens/ManageAccess/index.js +1 -2
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +12 -35
- package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
- package/src/screens/Notification/__test__/Notification.test.js +25 -14
- package/src/screens/Notification/__test__/NotificationItem.test.js +7 -8
- package/src/screens/Notification/components/NotificationItem.js +20 -17
- package/src/screens/Notification/index.js +2 -9
- package/src/screens/PlayBackCamera/Timer.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +2 -87
- package/src/screens/PlayBackCamera/index.js +6 -22
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +20 -7
- package/src/screens/ScanChipQR/components/QRScan/index.js +0 -1
- package/src/screens/ScanChipQR/hooks/index.js +16 -15
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +24 -8
- package/src/screens/ScriptDetail/__test__/index.test.js +86 -17
- package/src/screens/ScriptDetail/index.js +14 -19
- package/src/screens/SelectUnit/__test__/index.test.js +55 -12
- package/src/screens/SelectUnit/index.js +4 -9
- package/src/screens/SetSchedule/index.js +11 -15
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +2 -0
- package/src/screens/SharedUnit/index.js +0 -2
- package/src/screens/Sharing/Components/SensorItem.js +12 -10
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/MemberList.js +11 -12
- package/src/screens/Sharing/SelectPermission.js +76 -121
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +29 -47
- package/src/screens/Sharing/__test__/MemberList.test.js +127 -13
- package/src/screens/Sharing/__test__/SelectPermission.test.js +38 -28
- package/src/screens/Sharing/__test__/SelectUser.test.js +38 -17
- package/src/screens/Sharing/hooks/index.js +0 -3
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +2 -3
- package/src/screens/SmartIr/components/SelectBrand.js +1 -1
- package/src/screens/SubUnit/AddSubUnit.js +17 -23
- package/src/screens/SubUnit/Detail.js +2 -1
- package/src/screens/SubUnit/EditSubUnit.js +13 -15
- package/src/screens/SubUnit/ManageSubUnit.js +7 -13
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +89 -29
- package/src/screens/SubUnit/__test__/Detail.test.js +8 -31
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +89 -21
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +1 -27
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +45 -48
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
- package/src/screens/SyncLGDevice/AddLGDevice.js +0 -1
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +91 -22
- package/src/screens/TDSGuide/index.js +1 -4
- package/src/screens/UVIndexGuide/index.js +1 -1
- package/src/screens/Unit/ChooseLocation.js +14 -7
- package/src/screens/Unit/Detail.js +75 -30
- package/src/screens/Unit/ManageUnit.js +0 -1
- package/src/screens/Unit/SelectAddress.js +23 -45
- package/src/screens/Unit/SmartAccount.js +4 -4
- package/src/screens/Unit/Station/index.js +0 -4
- package/src/screens/Unit/Summaries.js +2 -18
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +29 -24
- package/src/screens/Unit/__test__/ChooseLocation.test.js +14 -27
- package/src/screens/Unit/__test__/Detail.test.js +200 -99
- package/src/screens/Unit/__test__/ManageUnit.test.js +42 -18
- package/src/screens/Unit/__test__/SelectAddress.test.js +49 -159
- package/src/screens/Unit/__test__/SmartAccount.test.js +9 -17
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +1 -0
- package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
- package/src/screens/Unit/components/SharedUnit/index.js +0 -1
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +34 -31
- package/src/screens/Unit/styles.js +0 -4
- package/src/screens/UnitSummary/__test__/index.test.js +30 -91
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +2 -31
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +4 -7
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +13 -2
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +1 -0
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +16 -14
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -11
- package/src/screens/UnitSummary/components/RunningDevices/index.js +10 -7
- package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +2 -10
- package/src/screens/UnitSummary/index.js +1 -15
- package/src/screens/WaterQualityGuide/index.js +1 -1
- package/src/utils/Apis/axios.js +31 -54
- package/src/utils/Converter/time.js +18 -0
- package/src/utils/I18n/translations/en.json +1 -7
- package/src/utils/I18n/translations/vi.json +1 -8
- package/src/utils/Route/index.js +0 -1
- package/src/utils/Utils.js +7 -11
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +0 -24
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplateWithNullConfigValue.test.js +0 -60
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +0 -77
- package/src/commons/Calendar/__test__/Calendar.test.js +0 -33
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +0 -58
- package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +0 -25
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +0 -96
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +0 -39
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +0 -118
- package/src/commons/FieldTemplate/ChooseUserField/index.js +0 -62
- package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +0 -30
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +0 -90
- package/src/commons/FieldTemplate/PasscodeField/index.js +0 -43
- package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +0 -13
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +0 -179
- package/src/commons/FieldTemplate/ScheduleField/index.js +0 -176
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +0 -62
- package/src/hooks/Common/useGGHomeDeviceConnected.js +0 -16
- package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +0 -198
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +0 -198
- package/src/hooks/IoT/index.js +0 -4
- package/src/hooks/IoT/useGGHomeConnection.js +0 -91
- package/src/hooks/IoT/useRemoteControl.js +0 -79
- package/src/hooks/index.js +0 -4
- package/src/navigations/UnitStackStyles.js +0 -21
- package/src/screens/Sharing/__test__/MemberList2.test.js +0 -80
- package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +0 -28
- package/src/screens/SideMenuDetail/__test__/index.test.js +0 -154
- package/src/screens/SideMenuDetail/index.js +0 -148
- package/src/screens/Unit/__test__/Summaries.test.js +0 -100
- package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +0 -36
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -54
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +0 -50
- package/src/utils/Permission/common.js +0 -67
- package/src/utils/Setting/Location.js +0 -30
- package/src/utils/__test__/Utils.test.js +0 -12
package/src/utils/Apis/axios.js
CHANGED
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getData, storeData } from '../Storage';
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { deleteData, getData, storeData } from '../Storage';
|
|
3
3
|
import { ToastBottomHelper } from '../Utils';
|
|
4
4
|
import NetInfo from '@react-native-community/netinfo';
|
|
5
|
-
import { PROBLEM_CODE } from '../../configs/Constants';
|
|
6
|
-
import { getTranslate } from '../I18n';
|
|
7
|
-
import { SCConfig } from '../../configs';
|
|
8
5
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
6
|
+
export const replaceParams = (apiURL, params) => {
|
|
7
|
+
let _result = apiURL;
|
|
8
|
+
if (typeof params === 'object') {
|
|
9
|
+
Object.keys(params).forEach((key) => {
|
|
10
|
+
_result = _result.replace(`{${key}}`, params[key]);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return _result;
|
|
14
|
+
};
|
|
15
15
|
|
|
16
16
|
const parseErrorResponse = async (error) => {
|
|
17
17
|
let message;
|
|
18
18
|
let data = {};
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
data
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
if (
|
|
20
|
+
error.response &&
|
|
21
|
+
error.response.data &&
|
|
22
|
+
error.response.data instanceof Object
|
|
23
|
+
) {
|
|
24
|
+
data = error.response.data;
|
|
25
|
+
const firstKey = Object.keys(error.response.data)[0];
|
|
26
|
+
message = error.response.data[firstKey];
|
|
25
27
|
|
|
26
28
|
if (message instanceof Array) {
|
|
27
29
|
message = message[0];
|
|
28
30
|
}
|
|
29
|
-
if (message?.message) {
|
|
30
|
-
message = message.message;
|
|
31
|
-
}
|
|
32
31
|
} else {
|
|
33
|
-
message = error.
|
|
32
|
+
message = error.message;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
if (typeof message === 'string') {
|
|
@@ -42,11 +41,6 @@ const parseErrorResponse = async (error) => {
|
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
if (!hideError) {
|
|
45
|
-
switch (error.problem) {
|
|
46
|
-
case PROBLEM_CODE.SERVER_ERROR:
|
|
47
|
-
message = getTranslate(SCConfig.language, 'server_error');
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
44
|
ToastBottomHelper.error(message);
|
|
51
45
|
}
|
|
52
46
|
}
|
|
@@ -56,7 +50,7 @@ const parseErrorResponse = async (error) => {
|
|
|
56
50
|
error,
|
|
57
51
|
message,
|
|
58
52
|
data,
|
|
59
|
-
resp_status: error?.
|
|
53
|
+
resp_status: error?.response?.status,
|
|
60
54
|
};
|
|
61
55
|
};
|
|
62
56
|
|
|
@@ -81,7 +75,6 @@ export async function fetchWithCache(url, config = {}, updateMethod) {
|
|
|
81
75
|
if (cacheResponse) {
|
|
82
76
|
updateMethod(cacheResponse);
|
|
83
77
|
}
|
|
84
|
-
// eslint-disable-next-line no-empty
|
|
85
78
|
} catch {}
|
|
86
79
|
const response = await axiosGet(url, config, true);
|
|
87
80
|
if (!response.cache) {
|
|
@@ -90,34 +83,25 @@ export async function fetchWithCache(url, config = {}, updateMethod) {
|
|
|
90
83
|
}
|
|
91
84
|
|
|
92
85
|
export async function axiosGet(URL, config = {}, cache = false) {
|
|
86
|
+
const cacheKey = `@CACHE_REQUEST_${URL}`;
|
|
93
87
|
let response;
|
|
94
88
|
try {
|
|
95
|
-
response = await
|
|
89
|
+
response = await axios.get(URL, config);
|
|
96
90
|
} catch (error) {
|
|
97
91
|
if (cache) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
(await axiosCache(URL, 500)) || (await parseErrorResponse(error))
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
if (!error?.response || error?.response?.status >= 500) {
|
|
92
|
+
// only network error or server error
|
|
93
|
+
if (!error.response || error.response.status >= 500) {
|
|
104
94
|
return (
|
|
105
|
-
(await axiosCache(URL, error
|
|
95
|
+
(await axiosCache(URL, error.response.status)) ||
|
|
106
96
|
(await parseErrorResponse(error))
|
|
107
97
|
);
|
|
98
|
+
} else {
|
|
99
|
+
await deleteData(cacheKey);
|
|
108
100
|
}
|
|
109
101
|
}
|
|
110
102
|
return await parseErrorResponse(error);
|
|
111
103
|
}
|
|
112
|
-
const { data
|
|
113
|
-
if (problem) {
|
|
114
|
-
if (cache) {
|
|
115
|
-
return (
|
|
116
|
-
(await axiosCache(URL, 500)) || (await parseErrorResponse(response))
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
return await parseErrorResponse(response);
|
|
120
|
-
}
|
|
104
|
+
const { data } = response;
|
|
121
105
|
if (response.status === 200) {
|
|
122
106
|
if (cache) {
|
|
123
107
|
await storeData(`@CACHE_REQUEST_${URL}`, JSON.stringify(data));
|
|
@@ -137,23 +121,18 @@ export async function axiosGet(URL, config = {}, cache = false) {
|
|
|
137
121
|
async function axiosCall(method, ...args) {
|
|
138
122
|
let response;
|
|
139
123
|
try {
|
|
140
|
-
response = await
|
|
124
|
+
response = await axios[method](...args);
|
|
141
125
|
} catch (error) {
|
|
142
126
|
return await parseErrorResponse(error);
|
|
143
127
|
}
|
|
144
128
|
|
|
145
|
-
const { data
|
|
146
|
-
if (problem) {
|
|
147
|
-
return await parseErrorResponse(response);
|
|
148
|
-
}
|
|
149
|
-
|
|
129
|
+
const { data } = response;
|
|
150
130
|
if (response.status >= 200 && response.status < 300) {
|
|
151
131
|
return {
|
|
152
132
|
success: true,
|
|
153
133
|
data,
|
|
154
134
|
};
|
|
155
135
|
}
|
|
156
|
-
await parseErrorResponse(response);
|
|
157
136
|
|
|
158
137
|
return {
|
|
159
138
|
success: false,
|
|
@@ -207,5 +186,3 @@ export function createFormData(data, list_file_field) {
|
|
|
207
186
|
|
|
208
187
|
return formData;
|
|
209
188
|
}
|
|
210
|
-
|
|
211
|
-
export default api;
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import t from '../../hooks/Common/useTranslations';
|
|
2
2
|
import moment from 'moment';
|
|
3
3
|
|
|
4
|
+
export const transformDatetime = (data = {}, listFieldName = []) => {
|
|
5
|
+
listFieldName.forEach((name) => {
|
|
6
|
+
const value = data[name];
|
|
7
|
+
const isArray = Array.isArray(value);
|
|
8
|
+
|
|
9
|
+
if (!data.hasOwnProperty(name)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (isArray) {
|
|
14
|
+
data[name] = value.map((item) => (item ? moment(item) : item));
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
data[name] = value ? moment(value) : value;
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
4
22
|
export const timeDifference = (current, previous, symbol = false) => {
|
|
5
23
|
let msPerMinute = 60 * 1000;
|
|
6
24
|
let msPerHour = msPerMinute * 60;
|
|
@@ -985,11 +985,5 @@
|
|
|
985
985
|
"you_need_to_enter_password": "You need to enter password to perform this action",
|
|
986
986
|
"note": "Note",
|
|
987
987
|
"back": "Back",
|
|
988
|
-
"
|
|
989
|
-
"This {name} was removed!" : "This {name} was removed!",
|
|
990
|
-
"camera_request_permission": "Camera request permission",
|
|
991
|
-
"camera_request_permission_des": "To use camera, please unlock camera permission",
|
|
992
|
-
"location_require_message": "EoH needs your location permission to get current location.",
|
|
993
|
-
"turn_on_location_service": "Turn on location service for your phone",
|
|
994
|
-
"turn_on_location_service_des": "To continue, let your device turn on location by turning on location service in Settings"
|
|
988
|
+
"This {name} was removed!" : "This {name} was removed!"
|
|
995
989
|
}
|
|
@@ -985,12 +985,5 @@
|
|
|
985
985
|
"maxmium_contacts": "Địa chỉ liên hệ tối đa",
|
|
986
986
|
"note": "Lưu ý ",
|
|
987
987
|
"back": "Quay lại",
|
|
988
|
-
"
|
|
989
|
-
"This {name} was removed!" : "{Name} này đã bị xóa!",
|
|
990
|
-
"location_perm_denied": "Ứng dụng không cho phép truy cập vị trí.",
|
|
991
|
-
"camera_request_permission": "Quyền yêu cầu máy ảnh",
|
|
992
|
-
"camera_request_permission_des": "Để sử dụng máy ảnh, vui lòng mở khóa quyền đối với máy ảnh",
|
|
993
|
-
"location_require_message": "Eoh cần quyền truy cập vị trí của bạn để lấy vị trí hiện tại.",
|
|
994
|
-
"turn_on_location_service": "Bật dịch vụ vị trí cho điện thoại của bạn",
|
|
995
|
-
"turn_on_location_service_des": "Để tiếp tục, bật dịch vụ vị trí cho điện thoại của bạn trong Cài Đặt"
|
|
988
|
+
"This {name} was removed!" : "{Name} này đã bị xóa!"
|
|
996
989
|
}
|
package/src/utils/Route/index.js
CHANGED
|
@@ -136,7 +136,6 @@ const Routes = {
|
|
|
136
136
|
SmartAccount: 'SmartAccount',
|
|
137
137
|
SmartHomeDashboard: 'SmartHomeDashboard',
|
|
138
138
|
SetupGeneratePasscode: 'SetupGeneratePasscode',
|
|
139
|
-
SideMenuDetail: 'SideMenuDetail',
|
|
140
139
|
SelectDeviceType: 'SelectDeviceType',
|
|
141
140
|
SelectBrand: 'SelectBrand',
|
|
142
141
|
GroupButtonByType: 'GroupButtonByType',
|
package/src/utils/Utils.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { PixelRatio, Linking
|
|
1
|
+
import { PixelRatio, Linking } from 'react-native';
|
|
2
2
|
import Toast from 'react-native-toast-message';
|
|
3
3
|
import validator from 'validator';
|
|
4
|
+
import axios from 'axios';
|
|
4
5
|
import { Constants } from '../configs';
|
|
5
|
-
import api from './Apis/axios';
|
|
6
6
|
|
|
7
7
|
export const setAxiosDefaultAuthToken = (token) => {
|
|
8
|
-
|
|
8
|
+
axios.defaults.headers.common.Accept = 'application/json';
|
|
9
|
+
axios.defaults.headers.common.Authorization = `Token ${token}`;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
export const setAxiosDefaultLanguage = (language) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
13
|
+
axios.defaults.headers.common['Accept-Language'] =
|
|
14
|
+
language || Constants.LANGUAGE.DEFAULT;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export const deleteDefaultAuthToken = () => {
|
|
18
|
-
delete
|
|
18
|
+
delete axios.defaults.headers.common.Authorization;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
export const validateEmail = (text) => {
|
|
@@ -129,10 +129,6 @@ export const object_Ids = (data) => {
|
|
|
129
129
|
return listObject;
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
-
export const notImplemented = (t) => {
|
|
133
|
-
Alert.alert(t('feature_under_development'));
|
|
134
|
-
};
|
|
135
|
-
|
|
136
132
|
export default {
|
|
137
133
|
validateEmail,
|
|
138
134
|
isObjectEmpty,
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TouchableOpacity } from 'react-native';
|
|
3
|
-
import { act, create } from 'react-test-renderer';
|
|
4
|
-
import { SCProvider } from '../../../../../context';
|
|
5
|
-
import { mockSCStore } from '../../../../../context/mockStore';
|
|
6
|
-
import ItemPasscode from '../ItemPasscode';
|
|
7
|
-
|
|
8
|
-
const wrapComponent = (route = {}) => (
|
|
9
|
-
<SCProvider initState={mockSCStore({})}>
|
|
10
|
-
<ItemPasscode route={route} />
|
|
11
|
-
</SCProvider>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
describe('Test ItemPasscode', () => {
|
|
15
|
-
let tree;
|
|
16
|
-
test('test render without params', async () => {
|
|
17
|
-
await act(async () => {
|
|
18
|
-
tree = await create(wrapComponent());
|
|
19
|
-
});
|
|
20
|
-
const instance = tree.root;
|
|
21
|
-
const TouchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
22
|
-
expect(TouchableOpacities).toHaveLength(2);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TouchableOpacity } from 'react-native';
|
|
3
|
-
import { act, create } from 'react-test-renderer';
|
|
4
|
-
import Text from '../../../commons/Text';
|
|
5
|
-
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
6
|
-
import NumberUpDownActionTemplate from '../NumberUpDownActionTemplate';
|
|
7
|
-
|
|
8
|
-
jest.mock('../../../iot/Monitor');
|
|
9
|
-
|
|
10
|
-
jest.mock('../../../iot/states', () => ({
|
|
11
|
-
useConfigGlobalState: () => [{ 5: null }, null],
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
describe('Test NumberUpDownActionTemplate', () => {
|
|
15
|
-
const action_data = {
|
|
16
|
-
color: '#00979D',
|
|
17
|
-
command_prefer_over_bluetooth: true,
|
|
18
|
-
command_prefer_over_googlehome: false,
|
|
19
|
-
command_prefer_over_internet: false,
|
|
20
|
-
googlehome_actions: [],
|
|
21
|
-
icon: 'caret-up',
|
|
22
|
-
id: 20,
|
|
23
|
-
key: '5ed1d4dc-a905-47cd-b0c9-f979644bd21a',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
let actionGroup;
|
|
27
|
-
let wrapper;
|
|
28
|
-
|
|
29
|
-
beforeEach(() => {
|
|
30
|
-
watchMultiConfigs.mockClear();
|
|
31
|
-
actionGroup = {
|
|
32
|
-
configuration: {
|
|
33
|
-
config: 5,
|
|
34
|
-
action_data,
|
|
35
|
-
min_value: 16,
|
|
36
|
-
max_value: 30,
|
|
37
|
-
text_format: '{number} *C',
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('render template', async () => {
|
|
43
|
-
const mockDoAction = jest.fn();
|
|
44
|
-
await act(async () => {
|
|
45
|
-
wrapper = await create(
|
|
46
|
-
<NumberUpDownActionTemplate
|
|
47
|
-
actionGroup={actionGroup}
|
|
48
|
-
doAction={mockDoAction}
|
|
49
|
-
sensor={{ is_managed_by_backend: true }}
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
const instance = wrapper.root;
|
|
54
|
-
const text = instance.findByType(Text);
|
|
55
|
-
expect(text.props.children).toEqual('28 *C');
|
|
56
|
-
|
|
57
|
-
const touchs = instance.findAllByType(TouchableOpacity);
|
|
58
|
-
expect(touchs).toHaveLength(2);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TouchableOpacity } from 'react-native';
|
|
3
|
-
import { act, create } from 'react-test-renderer';
|
|
4
|
-
import Text from '../../Text';
|
|
5
|
-
import StatesGridActionTemplate from '../StatesGridActionTemplate';
|
|
6
|
-
|
|
7
|
-
const mockDoAction = jest.fn();
|
|
8
|
-
const mockActionData = jest.fn();
|
|
9
|
-
|
|
10
|
-
describe('Test StatesGridActionTemplate', () => {
|
|
11
|
-
let tree;
|
|
12
|
-
const actionGroup = {
|
|
13
|
-
configuration: {
|
|
14
|
-
options: [
|
|
15
|
-
{
|
|
16
|
-
config: true,
|
|
17
|
-
active: false,
|
|
18
|
-
text: 'item 1',
|
|
19
|
-
icon_kit_data: 'icon_kit_data',
|
|
20
|
-
icon: '123',
|
|
21
|
-
icon_outlined: 'icon_outlined',
|
|
22
|
-
action_data: mockActionData,
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
config: false,
|
|
26
|
-
active: true,
|
|
27
|
-
text: 'item 2',
|
|
28
|
-
icon_kit_data: 'icon_kit_data',
|
|
29
|
-
icon: 'icon',
|
|
30
|
-
icon_outlined: 'icon_outlined',
|
|
31
|
-
action_data: mockActionData,
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
is_on_value: true,
|
|
35
|
-
},
|
|
36
|
-
title: 'Title',
|
|
37
|
-
};
|
|
38
|
-
const sensor = {
|
|
39
|
-
is_managed_by_backend: true,
|
|
40
|
-
device_type: '',
|
|
41
|
-
name: 'Sensor name',
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
test('test render without params', async () => {
|
|
45
|
-
await act(async () => {
|
|
46
|
-
tree = await create(<StatesGridActionTemplate />);
|
|
47
|
-
});
|
|
48
|
-
const instance = tree.root;
|
|
49
|
-
const Texts = instance.findAllByType(Text);
|
|
50
|
-
expect(Texts).toHaveLength(1);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test('test render with params', async () => {
|
|
54
|
-
await act(async () => {
|
|
55
|
-
tree = await create(
|
|
56
|
-
<StatesGridActionTemplate
|
|
57
|
-
doAction={mockDoAction}
|
|
58
|
-
sensor={sensor}
|
|
59
|
-
actionGroup={actionGroup}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
});
|
|
63
|
-
const instance = tree.root;
|
|
64
|
-
const Texts = instance.findAllByType(Text);
|
|
65
|
-
expect(Texts).toHaveLength(3);
|
|
66
|
-
const TouchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
67
|
-
expect(TouchableOpacities).toHaveLength(2);
|
|
68
|
-
await TouchableOpacities[0].props.onPress();
|
|
69
|
-
expect(mockDoAction).toBeCalledWith(
|
|
70
|
-
mockActionData,
|
|
71
|
-
null,
|
|
72
|
-
`${sensor.name} ${actionGroup.title.toLowerCase()} ${
|
|
73
|
-
actionGroup.configuration.options[0].text
|
|
74
|
-
}`
|
|
75
|
-
);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import renderer, { act } from 'react-test-renderer';
|
|
3
|
-
import CalendarComponent from '../';
|
|
4
|
-
import { Calendar } from 'react-native-calendars';
|
|
5
|
-
// eslint-disable-next-line no-unused-vars
|
|
6
|
-
import BottomSheet from '../../BottomSheet';
|
|
7
|
-
import { SCProvider } from '../../../context';
|
|
8
|
-
import { mockSCStore } from '../../../context/mockStore';
|
|
9
|
-
|
|
10
|
-
const mockSetState = jest.fn();
|
|
11
|
-
jest.mock('react', () => {
|
|
12
|
-
return {
|
|
13
|
-
...jest.requireActual('react'),
|
|
14
|
-
useState: jest.fn((init) => [init, mockSetState]),
|
|
15
|
-
};
|
|
16
|
-
});
|
|
17
|
-
const wrapComponent = (route, navigation) => (
|
|
18
|
-
<SCProvider initState={mockSCStore({})}>
|
|
19
|
-
<CalendarComponent route={route} />
|
|
20
|
-
</SCProvider>
|
|
21
|
-
);
|
|
22
|
-
describe('Test Calendar component', () => {
|
|
23
|
-
let tree;
|
|
24
|
-
|
|
25
|
-
test('create Calendar', () => {
|
|
26
|
-
act(() => {
|
|
27
|
-
tree = renderer.create(wrapComponent());
|
|
28
|
-
});
|
|
29
|
-
const instance = tree.root;
|
|
30
|
-
const calendar = instance.findAllByType(Calendar);
|
|
31
|
-
expect(calendar).toHaveLength(1);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TouchableWithoutFeedback } from 'react-native';
|
|
3
|
-
import renderer, { act } from 'react-test-renderer';
|
|
4
|
-
import ItemHanetDevice from './ItemHanetDevice';
|
|
5
|
-
import { SCProvider } from '../../../context';
|
|
6
|
-
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
-
|
|
8
|
-
const wrapComponent = (props) => (
|
|
9
|
-
<SCProvider initState={mockSCStore({})}>
|
|
10
|
-
<ItemHanetDevice {...props} />
|
|
11
|
-
</SCProvider>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
const mockNavigate = jest.fn();
|
|
15
|
-
jest.mock('@react-navigation/native', () => {
|
|
16
|
-
return {
|
|
17
|
-
...jest.requireActual('@react-navigation/native'),
|
|
18
|
-
useNavigation: () => ({
|
|
19
|
-
navigate: mockNavigate,
|
|
20
|
-
}),
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
describe('Test ItemHanetDevice', () => {
|
|
25
|
-
let tree, props;
|
|
26
|
-
|
|
27
|
-
beforeEach(() => {
|
|
28
|
-
props = {
|
|
29
|
-
svgMain: 'icon',
|
|
30
|
-
title: 'title',
|
|
31
|
-
sensor: {},
|
|
32
|
-
unit: {},
|
|
33
|
-
station: {},
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('render ItemHanetDevice', () => {
|
|
38
|
-
act(() => {
|
|
39
|
-
tree = renderer.create(wrapComponent(props));
|
|
40
|
-
});
|
|
41
|
-
const instance = tree.root;
|
|
42
|
-
const touches = instance.findAllByType(TouchableWithoutFeedback);
|
|
43
|
-
act(() => {
|
|
44
|
-
tree = touches[0].props.onPress();
|
|
45
|
-
});
|
|
46
|
-
expect(mockNavigate).toBeCalled();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('render ItemHanetDevice sensor has icon', () => {
|
|
50
|
-
props.sensor.icon_kit = 'icon';
|
|
51
|
-
act(() => {
|
|
52
|
-
tree = renderer.create(wrapComponent(props));
|
|
53
|
-
});
|
|
54
|
-
const instance = tree.root;
|
|
55
|
-
const touches = instance.findAllByType(TouchableWithoutFeedback);
|
|
56
|
-
expect(touches.length).toBeGreaterThan(0);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { Colors } from '../../../configs';
|
|
3
|
-
|
|
4
|
-
export default StyleSheet.create({
|
|
5
|
-
wrapper: {
|
|
6
|
-
flexDirection: 'row',
|
|
7
|
-
paddingTop: 30,
|
|
8
|
-
},
|
|
9
|
-
textHeadLine: {
|
|
10
|
-
fontSize: 16,
|
|
11
|
-
color: Colors.Gray9,
|
|
12
|
-
fontWeight: 'bold',
|
|
13
|
-
},
|
|
14
|
-
buttonValue: {
|
|
15
|
-
flex: 1,
|
|
16
|
-
flexDirection: 'row',
|
|
17
|
-
justifyContent: 'flex-end',
|
|
18
|
-
alignItems: 'center',
|
|
19
|
-
},
|
|
20
|
-
value: {
|
|
21
|
-
marginRight: 20,
|
|
22
|
-
fontSize: 14,
|
|
23
|
-
color: Colors.Gray8,
|
|
24
|
-
},
|
|
25
|
-
});
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import React, { useState, useCallback } from 'react';
|
|
2
|
-
import { View, ScrollView, TouchableOpacity } from 'react-native';
|
|
3
|
-
import { Colors } from '../../../configs';
|
|
4
|
-
import { TESTID } from '../../../configs/Constants';
|
|
5
|
-
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
6
|
-
import BottomButtonView from '../../BottomButtonView';
|
|
7
|
-
import { ModalCustom } from '../../Modal';
|
|
8
|
-
import RadioCircle from '../../RadioCircle';
|
|
9
|
-
import Text from '../../Text';
|
|
10
|
-
|
|
11
|
-
import styles from './ChoosePopupStyles';
|
|
12
|
-
|
|
13
|
-
const RowMember = ({ member, isSelected, onSelect }) => {
|
|
14
|
-
const handleOnPress = useCallback(() => {
|
|
15
|
-
onSelect(member);
|
|
16
|
-
}, [onSelect, member]);
|
|
17
|
-
return (
|
|
18
|
-
<TouchableOpacity
|
|
19
|
-
style={styles.row}
|
|
20
|
-
onPress={handleOnPress}
|
|
21
|
-
testID={TESTID.CHOOSE_ITEM}
|
|
22
|
-
>
|
|
23
|
-
<RadioCircle active={isSelected} />
|
|
24
|
-
<View style={styles.wrapText}>
|
|
25
|
-
<Text type="H4" color={Colors.Gray9}>
|
|
26
|
-
{member.name
|
|
27
|
-
? member.name
|
|
28
|
-
: member.phone_number
|
|
29
|
-
? member.phone_number
|
|
30
|
-
: member.email}
|
|
31
|
-
</Text>
|
|
32
|
-
</View>
|
|
33
|
-
</TouchableOpacity>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const ChoosePopup = ({ isVisible, title, onHide, members, onApply }) => {
|
|
38
|
-
const t = useTranslations();
|
|
39
|
-
const [selectedUsers, setSelectedUsers] = useState({});
|
|
40
|
-
|
|
41
|
-
const handleOnSelectUser = useCallback((user) => {
|
|
42
|
-
setSelectedUsers(user);
|
|
43
|
-
}, []);
|
|
44
|
-
|
|
45
|
-
const handleOnApply = useCallback(() => {
|
|
46
|
-
onApply(selectedUsers);
|
|
47
|
-
onHide();
|
|
48
|
-
}, [selectedUsers, onApply, onHide]);
|
|
49
|
-
|
|
50
|
-
const handleOnCancel = useCallback(() => {
|
|
51
|
-
onHide();
|
|
52
|
-
}, [onHide]);
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<ModalCustom
|
|
56
|
-
testID={TESTID.CHOOSE_POPUP}
|
|
57
|
-
isVisible={isVisible}
|
|
58
|
-
onBackButtonPress={handleOnCancel}
|
|
59
|
-
onBackdropPress={handleOnCancel}
|
|
60
|
-
useNativeDriver={true}
|
|
61
|
-
useNativeDriverForBackdrop={true}
|
|
62
|
-
animationIn={'zoomIn'}
|
|
63
|
-
animationOut={'zoomOut'}
|
|
64
|
-
style={styles.wrapPopup}
|
|
65
|
-
>
|
|
66
|
-
<View style={[styles.popup, styles.heigh50percent]}>
|
|
67
|
-
<Text type="H4" style={styles.title} bold>
|
|
68
|
-
{title}
|
|
69
|
-
</Text>
|
|
70
|
-
<View style={styles.separator} />
|
|
71
|
-
<ScrollView>
|
|
72
|
-
{members.map((member, index) => (
|
|
73
|
-
<RowMember
|
|
74
|
-
key={index}
|
|
75
|
-
member={member}
|
|
76
|
-
isSelected={selectedUsers.id === member.id}
|
|
77
|
-
onSelect={handleOnSelectUser}
|
|
78
|
-
/>
|
|
79
|
-
))}
|
|
80
|
-
</ScrollView>
|
|
81
|
-
<View style={styles.separator} />
|
|
82
|
-
<BottomButtonView
|
|
83
|
-
rowButton={true}
|
|
84
|
-
testIDPrefix={TESTID.CHOOSE_POPUP}
|
|
85
|
-
style={styles.bottomButtonView}
|
|
86
|
-
secondaryTitle={t('cancel')}
|
|
87
|
-
mainTitle={t('apply')}
|
|
88
|
-
onPressSecondary={handleOnCancel}
|
|
89
|
-
onPressMain={handleOnApply}
|
|
90
|
-
/>
|
|
91
|
-
</View>
|
|
92
|
-
</ModalCustom>
|
|
93
|
-
);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export default ChoosePopup;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native';
|
|
2
|
-
import { Colors, Constants } from '../../../configs';
|
|
3
|
-
|
|
4
|
-
export default StyleSheet.create({
|
|
5
|
-
wrapPopup: {
|
|
6
|
-
marginHorizontal: 16,
|
|
7
|
-
},
|
|
8
|
-
popup: {
|
|
9
|
-
backgroundColor: Colors.White,
|
|
10
|
-
width: '100%',
|
|
11
|
-
height: (Constants.height * 80) / 100,
|
|
12
|
-
padding: 24,
|
|
13
|
-
paddingBottom: 100,
|
|
14
|
-
borderRadius: 10,
|
|
15
|
-
},
|
|
16
|
-
heigh50percent: {
|
|
17
|
-
height: (Constants.height * 50) / 100,
|
|
18
|
-
},
|
|
19
|
-
title: {
|
|
20
|
-
marginBottom: 16,
|
|
21
|
-
},
|
|
22
|
-
bottomButtonView: {
|
|
23
|
-
marginBottom: 24,
|
|
24
|
-
},
|
|
25
|
-
separator: {
|
|
26
|
-
height: 0.5,
|
|
27
|
-
backgroundColor: Colors.Gray4,
|
|
28
|
-
},
|
|
29
|
-
row: {
|
|
30
|
-
flexDirection: 'row',
|
|
31
|
-
alignItems: 'center',
|
|
32
|
-
},
|
|
33
|
-
wrapText: {
|
|
34
|
-
flex: 1,
|
|
35
|
-
paddingVertical: 8,
|
|
36
|
-
marginRight: 24,
|
|
37
|
-
marginLeft: 16,
|
|
38
|
-
},
|
|
39
|
-
});
|