@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
|
@@ -8,14 +8,11 @@ export default (unit, sensor) => {
|
|
|
8
8
|
const [isLoading, setIsLoading] = useState(false);
|
|
9
9
|
const fetchData = useCallback(async () => {
|
|
10
10
|
setIsLoading(true);
|
|
11
|
-
const { success, data
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
params: { sensor_id: sensor.id },
|
|
15
|
-
}
|
|
16
|
-
);
|
|
11
|
+
const { success, data } = await axiosGet(API.UNIT.MANAGE_ACCESS(unit.id), {
|
|
12
|
+
params: { sensor_id: sensor.id },
|
|
13
|
+
});
|
|
17
14
|
if (success) {
|
|
18
|
-
setData(
|
|
15
|
+
setData(data);
|
|
19
16
|
}
|
|
20
17
|
setIsLoading(false);
|
|
21
18
|
}, [unit.id, sensor.id]);
|
|
@@ -19,7 +19,7 @@ import { RowItem } from '../../commons/RowItem';
|
|
|
19
19
|
const ManageAccessScreen = memo(({ route }) => {
|
|
20
20
|
const t = useTranslations();
|
|
21
21
|
const { params = {} } = route;
|
|
22
|
-
const { unit
|
|
22
|
+
const { unit, sensor } = params;
|
|
23
23
|
const { navigate } = useNavigation();
|
|
24
24
|
const isFocused = useIsFocused();
|
|
25
25
|
const { data, isRefresh, isLoading, onRefresh } = useManageAccess(
|
|
@@ -46,7 +46,6 @@ const ManageAccessScreen = memo(({ route }) => {
|
|
|
46
46
|
refreshControl={
|
|
47
47
|
<RefreshControl refreshing={false} onRefresh={onRefresh} />
|
|
48
48
|
}
|
|
49
|
-
scrollIndicatorInsets={{ right: 1 }}
|
|
50
49
|
>
|
|
51
50
|
<View style={styles.container}>
|
|
52
51
|
<Text semibold style={styles.titleGuest}>
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import axios from 'axios';
|
|
3
3
|
import { create } from 'react-test-renderer';
|
|
4
4
|
import { act } from '@testing-library/react-hooks';
|
|
5
|
-
import { TouchableOpacity } from 'react-native';
|
|
6
5
|
|
|
7
6
|
import { TESTID } from '../../../configs/Constants';
|
|
8
7
|
import { API } from '../../../configs';
|
|
@@ -10,20 +9,8 @@ import MoveToAnotherSubUnit from '../';
|
|
|
10
9
|
import { SCProvider } from '../../../context';
|
|
11
10
|
import { mockSCStore } from '../../../context/mockStore';
|
|
12
11
|
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
13
|
-
import api from '../../../utils/Apis/axios';
|
|
14
|
-
|
|
15
|
-
const mock = new MockAdapter(api.axiosInstance);
|
|
16
|
-
|
|
17
|
-
const mockNavigate = jest.fn();
|
|
18
|
-
jest.mock('@react-navigation/native', () => {
|
|
19
|
-
return {
|
|
20
|
-
...jest.requireActual('@react-navigation/native'),
|
|
21
|
-
useNavigation: () => ({
|
|
22
|
-
navigate: mockNavigate,
|
|
23
|
-
}),
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
12
|
|
|
13
|
+
jest.mock('axios');
|
|
27
14
|
jest.mock('react', () => {
|
|
28
15
|
return {
|
|
29
16
|
...jest.requireActual('react'),
|
|
@@ -98,17 +85,6 @@ describe('Test Render ListSubUnit', () => {
|
|
|
98
85
|
},
|
|
99
86
|
};
|
|
100
87
|
|
|
101
|
-
it('render ListSubUnit with out params', async () => {
|
|
102
|
-
await act(async () => {
|
|
103
|
-
tree = await create(wrapComponent({}));
|
|
104
|
-
});
|
|
105
|
-
const instance = tree.root;
|
|
106
|
-
const rowSubUnit = instance.findAll(
|
|
107
|
-
(el) => el.props.testID === TESTID.ROW_SUB_UNIT
|
|
108
|
-
);
|
|
109
|
-
expect(rowSubUnit).toHaveLength(0);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
88
|
it('render ListSubUnit', async () => {
|
|
113
89
|
await act(async () => {
|
|
114
90
|
tree = await create(wrapComponent(route));
|
|
@@ -136,14 +112,15 @@ describe('Test Render ListSubUnit', () => {
|
|
|
136
112
|
sensors: [],
|
|
137
113
|
});
|
|
138
114
|
});
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
115
|
+
act(() => {
|
|
116
|
+
bottomButtonView.props.onPressMain();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
expect(axios.patch).toHaveBeenCalledWith(
|
|
120
|
+
API.SENSOR.CHANGE_SUB_UNIT(200, 3, 73),
|
|
121
|
+
{
|
|
122
|
+
station_id: 4,
|
|
123
|
+
}
|
|
124
|
+
);
|
|
148
125
|
});
|
|
149
126
|
});
|
|
@@ -36,12 +36,12 @@ const MoveToAnotherSubUnit = memo(({ route }) => {
|
|
|
36
36
|
const { unit, sensor, station } = params;
|
|
37
37
|
const { navigate } = useNavigation();
|
|
38
38
|
const [selectedSubUnit, setSelectedSubUnit] = useState(
|
|
39
|
-
unit
|
|
39
|
+
unit.stations?.find((subUnit) => subUnit.id === station.id)
|
|
40
40
|
);
|
|
41
41
|
|
|
42
42
|
const listStationUnit = useMemo(() => {
|
|
43
|
-
return unit
|
|
44
|
-
}, [unit
|
|
43
|
+
return unit.stations.slice(2);
|
|
44
|
+
}, [unit.stations]);
|
|
45
45
|
|
|
46
46
|
const handleOnSelect = useCallback((item) => {
|
|
47
47
|
setSelectedSubUnit(item);
|
|
@@ -49,7 +49,7 @@ const MoveToAnotherSubUnit = memo(({ route }) => {
|
|
|
49
49
|
|
|
50
50
|
const onSubmit = useCallback(async () => {
|
|
51
51
|
const { success } = await axiosPatch(
|
|
52
|
-
API.
|
|
52
|
+
API.SENSOR.CHANGE_SUB_UNIT(unit.id, station.id, sensor.id),
|
|
53
53
|
{
|
|
54
54
|
station_id: selectedSubUnit.id,
|
|
55
55
|
}
|
|
@@ -57,12 +57,12 @@ const MoveToAnotherSubUnit = memo(({ route }) => {
|
|
|
57
57
|
if (success) {
|
|
58
58
|
navigate(Routes.UnitDetail);
|
|
59
59
|
}
|
|
60
|
-
}, [navigate, selectedSubUnit
|
|
60
|
+
}, [navigate, selectedSubUnit.id, sensor.id, station.id, unit.id]);
|
|
61
61
|
|
|
62
62
|
return (
|
|
63
63
|
<View style={styles.wrap}>
|
|
64
64
|
<HeaderCustom title={t('move_to_another_sub_unit')} isShowSeparator />
|
|
65
|
-
<ScrollView
|
|
65
|
+
<ScrollView>
|
|
66
66
|
<View style={styles.container}>
|
|
67
67
|
<View>
|
|
68
68
|
{listStationUnit.map((item, index) => (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
|
-
import
|
|
3
|
+
import axios from 'axios';
|
|
4
4
|
import { Animated, RefreshControl } from 'react-native';
|
|
5
5
|
|
|
6
6
|
import { SCProvider } from '../../../context';
|
|
@@ -8,7 +8,6 @@ import { mockSCStore } from '../../../context/mockStore';
|
|
|
8
8
|
import Notification from '../index';
|
|
9
9
|
import NotificationItem from '../components/NotificationItem';
|
|
10
10
|
import { API } from '../../../configs';
|
|
11
|
-
import api from '../../../utils/Apis/axios';
|
|
12
11
|
|
|
13
12
|
const wrapComponent = () => (
|
|
14
13
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -16,7 +15,7 @@ const wrapComponent = () => (
|
|
|
16
15
|
</SCProvider>
|
|
17
16
|
);
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
jest.mock('axios');
|
|
20
19
|
|
|
21
20
|
jest.mock('react', () => {
|
|
22
21
|
return {
|
|
@@ -54,9 +53,9 @@ describe('test Notification', () => {
|
|
|
54
53
|
],
|
|
55
54
|
},
|
|
56
55
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
axios.get.mockImplementation(async () => {
|
|
57
|
+
return response;
|
|
58
|
+
});
|
|
60
59
|
await act(async () => {
|
|
61
60
|
tree = await create(wrapComponent());
|
|
62
61
|
});
|
|
@@ -64,6 +63,10 @@ describe('test Notification', () => {
|
|
|
64
63
|
const notificationItem = instance.findAllByType(NotificationItem);
|
|
65
64
|
|
|
66
65
|
expect(notificationItem).toHaveLength(2);
|
|
66
|
+
expect(axios.get).toHaveBeenCalledWith(
|
|
67
|
+
API.NOTIFICATION.LIST_EOH_NOTIFICATIONS(1, ''),
|
|
68
|
+
{}
|
|
69
|
+
);
|
|
67
70
|
});
|
|
68
71
|
|
|
69
72
|
test('test handleOnLoadMore', async () => {
|
|
@@ -92,18 +95,22 @@ describe('test Notification', () => {
|
|
|
92
95
|
],
|
|
93
96
|
},
|
|
94
97
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
axios.get.mockImplementation(async () => {
|
|
99
|
+
return response;
|
|
100
|
+
});
|
|
98
101
|
await act(async () => {
|
|
99
102
|
tree = await create(wrapComponent());
|
|
100
103
|
});
|
|
101
104
|
const instance = tree.root;
|
|
102
105
|
const scrollView = instance.findByType(Animated.ScrollView);
|
|
106
|
+
|
|
103
107
|
act(() => {
|
|
104
108
|
scrollView.props.onMomentumScrollEnd();
|
|
105
109
|
});
|
|
106
|
-
expect(
|
|
110
|
+
expect(axios.get).toHaveBeenCalledWith(
|
|
111
|
+
API.NOTIFICATION.LIST_EOH_NOTIFICATIONS(1, ''),
|
|
112
|
+
{}
|
|
113
|
+
);
|
|
107
114
|
});
|
|
108
115
|
|
|
109
116
|
test('test onRefresh', async () => {
|
|
@@ -132,17 +139,21 @@ describe('test Notification', () => {
|
|
|
132
139
|
],
|
|
133
140
|
},
|
|
134
141
|
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
142
|
+
axios.get.mockImplementation(async () => {
|
|
143
|
+
return response;
|
|
144
|
+
});
|
|
138
145
|
await act(async () => {
|
|
139
146
|
tree = await create(wrapComponent());
|
|
140
147
|
});
|
|
141
148
|
const instance = tree.root;
|
|
142
149
|
const refreshControl = instance.findByType(RefreshControl);
|
|
150
|
+
|
|
143
151
|
act(() => {
|
|
144
152
|
refreshControl.props.onRefresh();
|
|
145
153
|
});
|
|
146
|
-
expect(
|
|
154
|
+
expect(axios.get).toHaveBeenCalledWith(
|
|
155
|
+
API.NOTIFICATION.LIST_EOH_NOTIFICATIONS(1, ''),
|
|
156
|
+
{}
|
|
157
|
+
);
|
|
147
158
|
});
|
|
148
159
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
3
|
import { TouchableOpacity } from 'react-native';
|
|
4
|
-
import
|
|
4
|
+
import axios from 'axios';
|
|
5
5
|
|
|
6
6
|
import { SCProvider } from '../../../context';
|
|
7
7
|
import { mockSCStore } from '../../../context/mockStore';
|
|
@@ -9,7 +9,6 @@ import NotificationItem from '../components/NotificationItem';
|
|
|
9
9
|
import { NOTIFICATION_TYPES, SENSOR_TYPE } from '../../../configs/Constants';
|
|
10
10
|
import Routes from '../../../utils/Route';
|
|
11
11
|
import { API } from '../../../configs';
|
|
12
|
-
import api from '../../../utils/Apis/axios';
|
|
13
12
|
|
|
14
13
|
const wrapComponent = (item) => (
|
|
15
14
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -17,7 +16,7 @@ const wrapComponent = (item) => (
|
|
|
17
16
|
</SCProvider>
|
|
18
17
|
);
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
jest.mock('axios');
|
|
21
20
|
|
|
22
21
|
const mockNavigate = jest.fn();
|
|
23
22
|
jest.mock('@react-navigation/native', () => {
|
|
@@ -239,10 +238,10 @@ describe('test NotificationItem', () => {
|
|
|
239
238
|
});
|
|
240
239
|
const instance = tree.root;
|
|
241
240
|
const button = instance.findByType(TouchableOpacity);
|
|
242
|
-
mock.onPost(API.NOTIFICATION.SET_READ(1)).reply(200);
|
|
243
241
|
act(() => {
|
|
244
242
|
button.props.onPress();
|
|
245
243
|
});
|
|
244
|
+
expect(axios.post).toHaveBeenCalledWith(API.NOTIFICATION.SET_READ(1));
|
|
246
245
|
expect(mockNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
|
|
247
246
|
screen: Routes.UnitSummary,
|
|
248
247
|
params: {
|
|
@@ -254,10 +253,10 @@ describe('test NotificationItem', () => {
|
|
|
254
253
|
|
|
255
254
|
test('test render Notify not in any case', () => {
|
|
256
255
|
item.content_code = 'NEW CASE';
|
|
257
|
-
item.params = "{ 'unit_id': 1 }"
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
256
|
+
(item.params = "{ 'unit_id': 1 }"),
|
|
257
|
+
act(() => {
|
|
258
|
+
tree = create(wrapComponent(item));
|
|
259
|
+
});
|
|
261
260
|
const instance = tree.root;
|
|
262
261
|
const button = instance.findByType(TouchableOpacity);
|
|
263
262
|
act(() => {
|
|
@@ -41,7 +41,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
41
41
|
return values;
|
|
42
42
|
}, [paramsJSON]);
|
|
43
43
|
|
|
44
|
-
const customColorText = (text,
|
|
44
|
+
const customColorText = (text, params) => {
|
|
45
45
|
return text.split('**').map((str, i) =>
|
|
46
46
|
i % 2 === 0 ? (
|
|
47
47
|
<Text type="Body" key={i} style={styles.textNotification}>
|
|
@@ -49,7 +49,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
49
49
|
</Text>
|
|
50
50
|
) : (
|
|
51
51
|
<Text type="Body" bold key={i} style={styles.textNotification}>
|
|
52
|
-
{
|
|
52
|
+
{params[(i - 1) / 2]}
|
|
53
53
|
</Text>
|
|
54
54
|
)
|
|
55
55
|
);
|
|
@@ -167,6 +167,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
167
167
|
}),
|
|
168
168
|
};
|
|
169
169
|
case NOTIFICATION_TYPES.BOOKING_EXPIRED_AND_VIOLATION_CREATED:
|
|
170
|
+
const violated_booking_id = paramsJSON.violated_booking_id;
|
|
170
171
|
return {
|
|
171
172
|
content: customColorText(
|
|
172
173
|
t(
|
|
@@ -177,7 +178,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
177
178
|
redirect: () =>
|
|
178
179
|
navigation.navigate(Routes.SmartParkingStack, {
|
|
179
180
|
screen: Routes.SmartParkingBookingDetails,
|
|
180
|
-
params: { id:
|
|
181
|
+
params: { id: violated_booking_id || booking_id },
|
|
181
182
|
}),
|
|
182
183
|
};
|
|
183
184
|
case NOTIFICATION_TYPES.MOVE_CAR_WITHOUT_PAY_VIOLATION:
|
|
@@ -205,6 +206,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
205
206
|
}),
|
|
206
207
|
};
|
|
207
208
|
case NOTIFICATION_TYPES.PAY_FINE_AND_EXTEND_SUCCESSFULLY:
|
|
209
|
+
const new_booking_id = paramsJSON.booking_id_new;
|
|
208
210
|
return {
|
|
209
211
|
content: customColorText(
|
|
210
212
|
t('text_notification_content_pay_fine_and_extend_successfully'),
|
|
@@ -213,7 +215,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
213
215
|
redirect: () =>
|
|
214
216
|
navigation.navigate(Routes.SmartParkingStack, {
|
|
215
217
|
screen: Routes.SmartParkingBookingDetails,
|
|
216
|
-
params: { id:
|
|
218
|
+
params: { id: new_booking_id },
|
|
217
219
|
}),
|
|
218
220
|
};
|
|
219
221
|
case NOTIFICATION_TYPES.STOP_VIOLATION_FREE_PARKING_ZONE:
|
|
@@ -229,7 +231,8 @@ const NotificationItem = memo(({ item }) => {
|
|
|
229
231
|
}),
|
|
230
232
|
};
|
|
231
233
|
case NOTIFICATION_TYPES.NOTIFY_INDICATOR:
|
|
232
|
-
|
|
234
|
+
const { sensor_type, summary_id } = paramsJSON;
|
|
235
|
+
switch (sensor_type) {
|
|
233
236
|
case SENSOR_TYPE.AIR_QUALITY:
|
|
234
237
|
return {
|
|
235
238
|
content: customColorText(
|
|
@@ -240,7 +243,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
240
243
|
navigation.navigate(Routes.UnitStack, {
|
|
241
244
|
screen: Routes.UnitSummary,
|
|
242
245
|
params: {
|
|
243
|
-
summaryId:
|
|
246
|
+
summaryId: summary_id,
|
|
244
247
|
unitId,
|
|
245
248
|
},
|
|
246
249
|
}),
|
|
@@ -256,7 +259,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
256
259
|
navigation.navigate(Routes.UnitStack, {
|
|
257
260
|
screen: Routes.UnitSummary,
|
|
258
261
|
params: {
|
|
259
|
-
summaryId:
|
|
262
|
+
summaryId: summary_id,
|
|
260
263
|
unitId,
|
|
261
264
|
},
|
|
262
265
|
}),
|
|
@@ -272,7 +275,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
272
275
|
navigation.navigate(Routes.UnitStack, {
|
|
273
276
|
screen: Routes.UnitSummary,
|
|
274
277
|
params: {
|
|
275
|
-
summaryId:
|
|
278
|
+
summaryId: summary_id,
|
|
276
279
|
unitId,
|
|
277
280
|
},
|
|
278
281
|
}),
|
|
@@ -288,7 +291,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
288
291
|
navigation.navigate(Routes.UnitStack, {
|
|
289
292
|
screen: Routes.UnitSummary,
|
|
290
293
|
params: {
|
|
291
|
-
summaryId:
|
|
294
|
+
summaryId: summary_id,
|
|
292
295
|
unitId,
|
|
293
296
|
},
|
|
294
297
|
}),
|
|
@@ -304,7 +307,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
304
307
|
navigation.navigate(Routes.UnitStack, {
|
|
305
308
|
screen: Routes.UnitSummary,
|
|
306
309
|
params: {
|
|
307
|
-
summaryId:
|
|
310
|
+
summaryId: summary_id,
|
|
308
311
|
unitId,
|
|
309
312
|
},
|
|
310
313
|
}),
|
|
@@ -385,13 +388,12 @@ const NotificationItem = memo(({ item }) => {
|
|
|
385
388
|
}
|
|
386
389
|
|
|
387
390
|
case NOTIFICATION_TYPES.NOTIFY_REMOVE_UNIT:
|
|
391
|
+
const unitOwerName = paramsJSON?.unit_owner_name;
|
|
392
|
+
const textNotify = unitOwerName
|
|
393
|
+
? t('text_notification_content_remove_unit_to_member')
|
|
394
|
+
: t('text_notification_content_remove_unit_to_owner');
|
|
388
395
|
return {
|
|
389
|
-
content: customColorText(
|
|
390
|
-
paramsJSON?.unit_owner_name
|
|
391
|
-
? t('text_notification_content_remove_unit_to_member')
|
|
392
|
-
: t('text_notification_content_remove_unit_to_owner'),
|
|
393
|
-
arrParams
|
|
394
|
-
),
|
|
396
|
+
content: customColorText(textNotify, arrParams),
|
|
395
397
|
redirect: () => null,
|
|
396
398
|
iconContent: (
|
|
397
399
|
<IconComponent icon={'home'} style={styles.backgroundSummer} />
|
|
@@ -472,6 +474,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
472
474
|
),
|
|
473
475
|
};
|
|
474
476
|
case NOTIFICATION_TYPES.NOTIFY_RENAME_SUB_UNIT:
|
|
477
|
+
const stationId = paramsJSON?.sub_unit_id;
|
|
475
478
|
return {
|
|
476
479
|
content: customColorText(
|
|
477
480
|
t('text_notification_content_rename_sub_unit'),
|
|
@@ -482,7 +485,7 @@ const NotificationItem = memo(({ item }) => {
|
|
|
482
485
|
screen: Routes.UnitDetail,
|
|
483
486
|
params: {
|
|
484
487
|
unitId,
|
|
485
|
-
stationId
|
|
488
|
+
stationId,
|
|
486
489
|
},
|
|
487
490
|
});
|
|
488
491
|
},
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
unwatchNotificationData,
|
|
14
14
|
} from '../../utils/Monitor';
|
|
15
15
|
import { useSCContextSelector } from '../../context';
|
|
16
|
-
import { notImplemented } from '../../utils/Utils';
|
|
17
16
|
|
|
18
17
|
let page = 1;
|
|
19
18
|
|
|
@@ -27,18 +26,12 @@ const Notification = memo(() => {
|
|
|
27
26
|
<View style={styles.rightComponent}>
|
|
28
27
|
<TouchableOpacity
|
|
29
28
|
style={styles.iconPlus}
|
|
30
|
-
onPress={() =>
|
|
31
|
-
notImplemented(t);
|
|
32
|
-
}}
|
|
29
|
+
onPress={() => alert(t('feature_under_development'))}
|
|
33
30
|
>
|
|
34
31
|
<Icon name={'plus'} size={27} color={Colors.Black} />
|
|
35
32
|
</TouchableOpacity>
|
|
36
33
|
|
|
37
|
-
<TouchableOpacity
|
|
38
|
-
onPress={() => {
|
|
39
|
-
notImplemented(t);
|
|
40
|
-
}}
|
|
41
|
-
>
|
|
34
|
+
<TouchableOpacity onPress={() => alert(t('feature_under_development'))}>
|
|
42
35
|
<Icon name={'search'} size={27} color={Colors.Black} />
|
|
43
36
|
</TouchableOpacity>
|
|
44
37
|
</View>
|
|
@@ -70,8 +70,8 @@ const Timer = ({
|
|
|
70
70
|
}, []);
|
|
71
71
|
|
|
72
72
|
useEffect(() => {
|
|
73
|
-
const scrollListener = scrollX.addListener(({ value
|
|
74
|
-
!isFirstTime && onChangeValue && onChangeValue(
|
|
73
|
+
const scrollListener = scrollX.addListener(({ value }) => {
|
|
74
|
+
!isFirstTime && onChangeValue && onChangeValue(value, selected);
|
|
75
75
|
});
|
|
76
76
|
return () => scrollX.removeListener(scrollListener);
|
|
77
77
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
2
1
|
import React from 'react';
|
|
3
|
-
import { Animated, TouchableOpacity } from 'react-native';
|
|
4
2
|
import { act, create } from 'react-test-renderer';
|
|
5
3
|
import PlayBackCamera from '..';
|
|
6
4
|
import { ModalCustom } from '../../../commons/Modal';
|
|
7
|
-
import Text from '../../../commons/Text';
|
|
8
|
-
import { TESTID } from '../../../configs/Constants';
|
|
9
5
|
import { SCProvider } from '../../../context';
|
|
10
6
|
import { mockSCStore } from '../../../context/mockStore';
|
|
11
7
|
|
|
@@ -30,95 +26,14 @@ const wrapComponent = () => (
|
|
|
30
26
|
</SCProvider>
|
|
31
27
|
);
|
|
32
28
|
|
|
33
|
-
const mockSetState = jest.fn();
|
|
34
|
-
jest.mock('react', () => {
|
|
35
|
-
return {
|
|
36
|
-
...jest.requireActual('react'),
|
|
37
|
-
useState: jest.fn((init) => [init, mockSetState]),
|
|
38
|
-
memo: (x) => x,
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
let dateTemp = moment().format('YYYY-MM-DD');
|
|
43
|
-
|
|
44
29
|
describe('Test PlayBackCamera', () => {
|
|
45
30
|
let tree;
|
|
46
|
-
jest.useFakeTimers();
|
|
47
|
-
|
|
48
31
|
it('Test render', async () => {
|
|
49
|
-
await act(
|
|
50
|
-
tree =
|
|
32
|
+
await act(() => {
|
|
33
|
+
tree = create(wrapComponent());
|
|
51
34
|
});
|
|
52
35
|
const instance = tree.root;
|
|
53
36
|
const HeaderCustoms = instance.findAllByType(ModalCustom);
|
|
54
37
|
expect(HeaderCustoms).toHaveLength(2);
|
|
55
|
-
const textOpenModal = instance.findAll(
|
|
56
|
-
(el) => el.props.testID === TESTID.OPEN_DATE_MODAL && el.type === Text
|
|
57
|
-
);
|
|
58
|
-
await textOpenModal[0].props.onPress();
|
|
59
|
-
expect(mockSetState).toBeCalledWith(true);
|
|
60
|
-
|
|
61
|
-
mockSetState.mockClear();
|
|
62
|
-
const buttonCancel = instance.findAll(
|
|
63
|
-
(el) =>
|
|
64
|
-
el.props.testID === TESTID.ON_PRESS_CANCEL &&
|
|
65
|
-
el.type === TouchableOpacity
|
|
66
|
-
);
|
|
67
|
-
await buttonCancel[0].props.onPress();
|
|
68
|
-
expect(mockSetState).toBeCalledWith(false);
|
|
69
|
-
expect(mockSetState).toBeCalledWith(dateTemp);
|
|
70
|
-
|
|
71
|
-
mockSetState.mockClear();
|
|
72
|
-
const buttonOK = instance.findAll(
|
|
73
|
-
(el) =>
|
|
74
|
-
el.props.testID === TESTID.ON_PRESS_OK && el.type === TouchableOpacity
|
|
75
|
-
);
|
|
76
|
-
await buttonOK[0].props.onPress();
|
|
77
|
-
expect(mockSetState).toBeCalledWith(false);
|
|
78
|
-
|
|
79
|
-
mockSetState.mockClear();
|
|
80
|
-
const buttonAddDate = instance.findAll(
|
|
81
|
-
(el) =>
|
|
82
|
-
el.props.testID === TESTID.ON_PRESS_ADD_DATE &&
|
|
83
|
-
el.type === TouchableOpacity
|
|
84
|
-
);
|
|
85
|
-
await buttonAddDate[0].props.onPress();
|
|
86
|
-
expect(mockSetState).not.toBeCalled();
|
|
87
|
-
|
|
88
|
-
mockSetState.mockClear();
|
|
89
|
-
const buttonSubDate = instance.findAll(
|
|
90
|
-
(el) =>
|
|
91
|
-
el.props.testID === TESTID.ON_PRESS_SUB_DATE &&
|
|
92
|
-
el.type === TouchableOpacity
|
|
93
|
-
);
|
|
94
|
-
await buttonSubDate[0].props.onPress();
|
|
95
|
-
expect(mockSetState).toBeCalledWith(
|
|
96
|
-
moment(dateTemp).subtract(1, 'days').format('YYYY-MM-DD')
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
mockSetState.mockClear();
|
|
100
|
-
const timer = instance.findAllByType(Animated.ScrollView);
|
|
101
|
-
//NOTE: isFirstTime = true
|
|
102
|
-
timer[0].props.onScroll({
|
|
103
|
-
nativeEvent: {
|
|
104
|
-
contentInset: { bottom: 10, left: 10, right: 10, top: 10 },
|
|
105
|
-
contentOffset: { x: 10, y: 0 },
|
|
106
|
-
contentSize: { height: 10, width: 10 },
|
|
107
|
-
layoutMeasurement: { height: 10, width: 10 },
|
|
108
|
-
zoomScale: 1,
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
jest.runAllTimers();
|
|
112
|
-
//NOTE: isFirstTime = false
|
|
113
|
-
timer[0].props.onScroll({
|
|
114
|
-
nativeEvent: {
|
|
115
|
-
contentInset: { bottom: 10, left: 10, right: 10, top: 10 },
|
|
116
|
-
contentOffset: { x: 60, y: 0 },
|
|
117
|
-
contentSize: { height: 10, width: 10 },
|
|
118
|
-
layoutMeasurement: { height: 10, width: 10 },
|
|
119
|
-
zoomScale: 1,
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
expect(mockSetState).toBeCalledWith({ h: '00', m: '37', s: 30 });
|
|
123
38
|
});
|
|
124
39
|
});
|
|
@@ -13,7 +13,6 @@ import Text from '../../commons/Text';
|
|
|
13
13
|
import Timer from './Timer';
|
|
14
14
|
import { useStatusBarPreview } from '../../hooks/Common/useStatusBar';
|
|
15
15
|
import MediaPlayerFull from '../../commons/MediaPlayerDetail/MediaPlayerFull';
|
|
16
|
-
import { TESTID } from '../../configs/Constants';
|
|
17
16
|
|
|
18
17
|
let dateTemp = moment().format('YYYY-MM-DD');
|
|
19
18
|
let isFirstTime = true;
|
|
@@ -62,7 +61,7 @@ const PlayBackCamera = () => {
|
|
|
62
61
|
dateTemp = date;
|
|
63
62
|
}, [selected]);
|
|
64
63
|
|
|
65
|
-
const onChangeValue = (value,
|
|
64
|
+
const onChangeValue = (value, selected) => {
|
|
66
65
|
if (!isFirstTime) {
|
|
67
66
|
const currentTime =
|
|
68
67
|
parseFloat(arrHourTemp[0]) +
|
|
@@ -78,11 +77,11 @@ const PlayBackCamera = () => {
|
|
|
78
77
|
const m = t4[0] < 10 ? '0' + t4[0] : t4[0];
|
|
79
78
|
const s = t5 < 10 ? '0' + t5 : t5;
|
|
80
79
|
setHour({ h, m, s });
|
|
81
|
-
if (value + 0.5 > currentTime * 96 &&
|
|
80
|
+
if (value + 0.5 > currentTime * 96 && selected === now) {
|
|
82
81
|
setUri(item?.configuration?.uri);
|
|
83
82
|
} else {
|
|
84
83
|
const playback = item?.configuration?.playback || '';
|
|
85
|
-
const date =
|
|
84
|
+
const date = selected.split('-');
|
|
86
85
|
setUri(
|
|
87
86
|
`${playback.split('=')[0]}=${date[0]}${date[1]}${
|
|
88
87
|
date[2]
|
|
@@ -152,18 +151,12 @@ const PlayBackCamera = () => {
|
|
|
152
151
|
<View style={styles.container}>
|
|
153
152
|
<View style={styles.row}>
|
|
154
153
|
<TouchableOpacity
|
|
155
|
-
testID={TESTID.ON_PRESS_SUB_DATE}
|
|
156
154
|
onPress={onSubtractDate}
|
|
157
155
|
style={styles.commomButton}
|
|
158
156
|
>
|
|
159
157
|
<Image source={Images.arrowLeft} />
|
|
160
158
|
</TouchableOpacity>
|
|
161
|
-
<Text
|
|
162
|
-
testID={TESTID.OPEN_DATE_MODAL}
|
|
163
|
-
onPress={onOpenDateModal}
|
|
164
|
-
style={styles.textDate}
|
|
165
|
-
type="h4"
|
|
166
|
-
>
|
|
159
|
+
<Text onPress={onOpenDateModal} style={styles.textDate} type="h4">
|
|
167
160
|
{moment(selected).format('DD/MM/YYYY')}
|
|
168
161
|
</Text>
|
|
169
162
|
<TouchableOpacity
|
|
@@ -172,11 +165,7 @@ const PlayBackCamera = () => {
|
|
|
172
165
|
>
|
|
173
166
|
<Image source={Images.file} style={styles.iconDate} />
|
|
174
167
|
</TouchableOpacity>
|
|
175
|
-
<TouchableOpacity
|
|
176
|
-
testID={TESTID.ON_PRESS_ADD_DATE}
|
|
177
|
-
onPress={onAddDate}
|
|
178
|
-
style={styles.commomButton}
|
|
179
|
-
>
|
|
168
|
+
<TouchableOpacity onPress={onAddDate} style={styles.commomButton}>
|
|
180
169
|
<Image source={Images.arrowLeft} style={styles.arrowRight} />
|
|
181
170
|
</TouchableOpacity>
|
|
182
171
|
</View>
|
|
@@ -242,17 +231,12 @@ const PlayBackCamera = () => {
|
|
|
242
231
|
<TouchableOpacity
|
|
243
232
|
onPress={onPressCancel}
|
|
244
233
|
style={styles.commomButton}
|
|
245
|
-
testID={TESTID.ON_PRESS_CANCEL}
|
|
246
234
|
>
|
|
247
235
|
<Text type="h4" semibold hilight>
|
|
248
236
|
{t('cancel')}
|
|
249
237
|
</Text>
|
|
250
238
|
</TouchableOpacity>
|
|
251
|
-
<TouchableOpacity
|
|
252
|
-
testID={TESTID.ON_PRESS_OK}
|
|
253
|
-
onPress={onPressOk}
|
|
254
|
-
style={styles.commomButton}
|
|
255
|
-
>
|
|
239
|
+
<TouchableOpacity onPress={onPressOk} style={styles.commomButton}>
|
|
256
240
|
<Text type="h4" semibold hilight>
|
|
257
241
|
{t('done')}
|
|
258
242
|
</Text>
|