@eohjsc/react-native-smart-city 0.3.24 → 0.3.27
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/package.json +1 -1
- package/src/commons/ActionGroup/SliderRangeTemplate.js +7 -7
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +55 -5
- package/src/commons/Dashboard/MyUnit/index.js +58 -11
- package/src/commons/MenuActionMore/index.js +1 -3
- package/src/commons/Popover/index.js +26 -0
- package/src/configs/Constants.js +4 -0
- package/src/context/actionType.ts +2 -0
- package/src/context/reducer.ts +10 -0
- package/src/hooks/Common/useGGHomeDeviceConnected.js +9 -2
- package/src/hooks/Common/usePopover.js +0 -8
- package/src/hooks/IoT/useGGHomeConnection.js +0 -1
- package/src/navigations/UnitStack.js +10 -2
- package/src/screens/GuestInfo/index.js +11 -4
- package/src/screens/GuestInfo/styles/indexStyles.js +7 -0
- package/src/screens/ManageAccess/index.js +14 -5
- package/src/screens/ManageAccess/styles/ManageAccessStyles.js +9 -0
- package/src/screens/PlayBackCamera/Timer.js +3 -0
- package/src/screens/PlayBackCamera/__test__/index.test.js +8 -1
- package/src/screens/PlayBackCamera/index.js +67 -46
- package/src/screens/ScriptDetail/__test__/index.test.js +0 -3
- package/src/screens/ScriptDetail/index.js +7 -10
- package/src/screens/Unit/Detail.js +16 -10
- package/src/screens/Unit/SmartAccount.js +7 -6
- package/src/screens/Unit/Summaries.js +8 -1
- package/src/screens/Unit/components/Header/index.js +1 -1
- package/src/screens/Unit/components/MyUnitDevice/index.js +29 -12
- package/src/screens/Unit/components/__test__/AutomateScript.test.js +116 -0
- package/src/screens/Unit/components/__test__/Header.test.js +1 -1
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +6 -5
- package/src/screens/Unit/components/MyUnit/index.js +0 -136
- package/src/screens/Unit/components/__test__/MyUnit.test.js +0 -35
package/package.json
CHANGED
|
@@ -12,11 +12,11 @@ const SliderRangeTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
12
12
|
const t = useTranslations();
|
|
13
13
|
const { configuration } = actionGroup;
|
|
14
14
|
const [valueBrightness, setValueBrightness] = useState(0);
|
|
15
|
+
const [valueBrightnessTemp, setValueBrightnessTemp] = useState(0);
|
|
15
16
|
const [configValues] = useConfigGlobalState('configValues');
|
|
16
17
|
|
|
17
18
|
const onChangeBrightness = useCallback(
|
|
18
19
|
(value) => {
|
|
19
|
-
setValueBrightness(value);
|
|
20
20
|
doAction(
|
|
21
21
|
configuration?.action_brightness_data,
|
|
22
22
|
JSON.stringify({ value_brness: value })
|
|
@@ -26,17 +26,17 @@ const SliderRangeTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
const percentBrightness = useMemo(() => {
|
|
29
|
-
return valueBrightness || 0;
|
|
30
|
-
}, [valueBrightness]);
|
|
29
|
+
return valueBrightnessTemp || valueBrightness || 0;
|
|
30
|
+
}, [valueBrightness, valueBrightnessTemp]);
|
|
31
31
|
|
|
32
32
|
useEffect(() => {
|
|
33
33
|
const { config } = configuration;
|
|
34
34
|
const configValue = configValues[config];
|
|
35
35
|
let valueBrness = configValue?.value;
|
|
36
|
-
if (valueBrness >= 0) {
|
|
36
|
+
if (valueBrness >= 0 && valueBrightness >= 0) {
|
|
37
37
|
setValueBrightness(valueBrness);
|
|
38
38
|
}
|
|
39
|
-
}, [configuration.config, configValues, configuration]);
|
|
39
|
+
}, [configuration.config, configValues, configuration, valueBrightness]);
|
|
40
40
|
|
|
41
41
|
return (
|
|
42
42
|
<View style={styles.viewBrightness}>
|
|
@@ -49,9 +49,9 @@ const SliderRangeTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
49
49
|
<View style={styles.RightBrightness}>
|
|
50
50
|
<View style={styles.slider}>
|
|
51
51
|
<SliderRange
|
|
52
|
-
value={
|
|
52
|
+
value={valueBrightnessTemp}
|
|
53
53
|
onSlidingComplete={onChangeBrightness}
|
|
54
|
-
onValueChange={
|
|
54
|
+
onValueChange={setValueBrightnessTemp}
|
|
55
55
|
step={1}
|
|
56
56
|
minimumValue={0}
|
|
57
57
|
maximumValue={100}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
3
4
|
import MyUnit from '..';
|
|
5
|
+
import MyUnitDevice from '../../../../screens/Unit/components/MyUnitDevice';
|
|
4
6
|
import { TESTID } from '../../../../configs/Constants';
|
|
5
7
|
import { SCProvider } from '../../../../context';
|
|
6
8
|
import { mockSCStore } from '../../../../context/mockStore';
|
|
9
|
+
import api from '../../../../utils/Apis/axios';
|
|
10
|
+
import { API } from '../../../../configs';
|
|
11
|
+
|
|
12
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
7
13
|
|
|
8
14
|
const mockedNavigate = jest.fn();
|
|
9
|
-
const mockUseIsFocused = jest.fn();
|
|
10
15
|
const mockedDispatch = jest.fn();
|
|
11
16
|
|
|
12
17
|
jest.mock('@react-navigation/native', () => {
|
|
@@ -15,9 +20,8 @@ jest.mock('@react-navigation/native', () => {
|
|
|
15
20
|
useNavigation: () => ({
|
|
16
21
|
navigate: mockedNavigate,
|
|
17
22
|
}),
|
|
18
|
-
useIsFocused: () =>
|
|
19
|
-
|
|
20
|
-
}),
|
|
23
|
+
useIsFocused: () => true,
|
|
24
|
+
useFocusEffect: jest.fn(),
|
|
21
25
|
};
|
|
22
26
|
});
|
|
23
27
|
|
|
@@ -34,6 +38,42 @@ const wrapComponent = () => (
|
|
|
34
38
|
|
|
35
39
|
describe('Test MyUnit', () => {
|
|
36
40
|
let tree;
|
|
41
|
+
let data = [
|
|
42
|
+
{
|
|
43
|
+
id: 1,
|
|
44
|
+
name: 'name',
|
|
45
|
+
background: 'background',
|
|
46
|
+
abstract_devices: [
|
|
47
|
+
{
|
|
48
|
+
id: 1,
|
|
49
|
+
name: 'device',
|
|
50
|
+
is_managed_by_backend: true,
|
|
51
|
+
device_type: 'GOOGLE_HOME',
|
|
52
|
+
station_name: 'name',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 2,
|
|
56
|
+
name: 'device',
|
|
57
|
+
is_managed_by_backend: true,
|
|
58
|
+
device_type: '',
|
|
59
|
+
station_name: 'name',
|
|
60
|
+
quick_action: {
|
|
61
|
+
config_id: 1,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 2,
|
|
68
|
+
name: 'name2',
|
|
69
|
+
background: 'background',
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
beforeEach(() => {
|
|
74
|
+
mock.resetHistory();
|
|
75
|
+
});
|
|
76
|
+
|
|
37
77
|
const getElement = (instance) => {
|
|
38
78
|
const goToDetail = instance.findAll(
|
|
39
79
|
(item) => item.props.testID === TESTID.MY_UNIT_GO_TO_DETAIL
|
|
@@ -44,7 +84,7 @@ describe('Test MyUnit', () => {
|
|
|
44
84
|
return { goToDetail, textNoUnit };
|
|
45
85
|
};
|
|
46
86
|
|
|
47
|
-
test('
|
|
87
|
+
test('MyUnit no Unit', async () => {
|
|
48
88
|
await act(async () => {
|
|
49
89
|
tree = await renderer.create(wrapComponent());
|
|
50
90
|
});
|
|
@@ -52,4 +92,14 @@ describe('Test MyUnit', () => {
|
|
|
52
92
|
const { textNoUnit } = getElement(instance);
|
|
53
93
|
expect(textNoUnit[0]).toBeDefined();
|
|
54
94
|
});
|
|
95
|
+
|
|
96
|
+
test('MyUnit with unit', async () => {
|
|
97
|
+
mock.onGet(API.UNIT.MY_UNITS()).replyOnce(200, data);
|
|
98
|
+
await act(async () => {
|
|
99
|
+
tree = await renderer.create(wrapComponent());
|
|
100
|
+
});
|
|
101
|
+
const instance = tree.root;
|
|
102
|
+
const devices = instance.findAllByType(MyUnitDevice);
|
|
103
|
+
expect(devices).toHaveLength(2);
|
|
104
|
+
});
|
|
55
105
|
});
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
memo,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useState,
|
|
6
|
+
useContext,
|
|
7
|
+
useMemo,
|
|
8
|
+
} from 'react';
|
|
2
9
|
import { View, Image, TouchableOpacity, Dimensions } from 'react-native';
|
|
10
|
+
import {
|
|
11
|
+
useNavigation,
|
|
12
|
+
useIsFocused,
|
|
13
|
+
useFocusEffect,
|
|
14
|
+
} from '@react-navigation/native';
|
|
15
|
+
import NetInfo from '@react-native-community/netinfo';
|
|
3
16
|
import { API, Colors, Images } from '../../../configs';
|
|
4
17
|
import Text from '../../Text';
|
|
5
18
|
import { fetchWithCache } from '../../../utils/Apis/axios';
|
|
@@ -7,10 +20,13 @@ import { fetchWithCache } from '../../../utils/Apis/axios';
|
|
|
7
20
|
import styles from './styles';
|
|
8
21
|
import { Section } from '../../Section';
|
|
9
22
|
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
10
|
-
import {
|
|
23
|
+
import { useUnitConnectRemoteDevices } from '../../../screens/Unit/hook/useUnitConnectRemoteDevices';
|
|
24
|
+
import { useWatchConfigs } from '../../../hooks/IoT';
|
|
25
|
+
import { SCContext } from '../../../context';
|
|
26
|
+
import { Action } from '../../../context/actionType';
|
|
11
27
|
|
|
12
28
|
import Carousel from 'react-native-snap-carousel';
|
|
13
|
-
import { TESTID } from '../../../configs/Constants';
|
|
29
|
+
import { TESTID, DEVICE_TYPE } from '../../../configs/Constants';
|
|
14
30
|
import Routes from '../../../utils/Route';
|
|
15
31
|
import MyUnitDevice from '../../../screens/Unit/components/MyUnitDevice';
|
|
16
32
|
|
|
@@ -20,21 +36,49 @@ const MyUnit = () => {
|
|
|
20
36
|
const isFocused = useIsFocused();
|
|
21
37
|
const navigation = useNavigation();
|
|
22
38
|
const [myUnits, setMyUnits] = useState([]);
|
|
39
|
+
const [slideIndex, setSlideIndex] = useState(0);
|
|
40
|
+
const { setAction } = useContext(SCContext);
|
|
23
41
|
|
|
24
42
|
const fetchMyUnitDashboard = useCallback(async () => {
|
|
25
43
|
await fetchWithCache(API.UNIT.MY_UNITS(), {}, (response) => {
|
|
26
44
|
const { success, data } = response;
|
|
27
|
-
|
|
28
|
-
setMyUnits(data);
|
|
29
|
-
}
|
|
45
|
+
success && setMyUnits(data);
|
|
30
46
|
});
|
|
31
47
|
}, [setMyUnits]);
|
|
32
48
|
|
|
33
49
|
useEffect(() => {
|
|
34
|
-
|
|
35
|
-
fetchMyUnitDashboard();
|
|
36
|
-
}
|
|
50
|
+
isFocused && fetchMyUnitDashboard();
|
|
37
51
|
}, [fetchMyUnitDashboard, isFocused]);
|
|
52
|
+
|
|
53
|
+
useFocusEffect(
|
|
54
|
+
useCallback(() => {
|
|
55
|
+
const unsubscribe = NetInfo.addEventListener((state) => {
|
|
56
|
+
setAction(Action.SET_NETWORK_CONNECTED, state.isConnected);
|
|
57
|
+
});
|
|
58
|
+
return () => unsubscribe();
|
|
59
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
|
+
}, [])
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
useUnitConnectRemoteDevices(myUnits[slideIndex]);
|
|
64
|
+
|
|
65
|
+
const configsNeedWatching = useMemo(() => {
|
|
66
|
+
const configIds = [];
|
|
67
|
+
myUnits.forEach((unit) => {
|
|
68
|
+
(unit?.abstract_devices || []).forEach((device) => {
|
|
69
|
+
if (
|
|
70
|
+
device?.quick_action?.config_id &&
|
|
71
|
+
device?.device_type !== DEVICE_TYPE.GOOGLE_HOME
|
|
72
|
+
) {
|
|
73
|
+
configIds.push(device.quick_action.config_id);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
return configIds;
|
|
78
|
+
}, [myUnits]);
|
|
79
|
+
|
|
80
|
+
useWatchConfigs(configsNeedWatching);
|
|
81
|
+
|
|
38
82
|
const goToDetail = useCallback(
|
|
39
83
|
(item) => {
|
|
40
84
|
navigation.navigate(Routes.UnitStack, {
|
|
@@ -47,6 +91,7 @@ const MyUnit = () => {
|
|
|
47
91
|
},
|
|
48
92
|
[navigation]
|
|
49
93
|
);
|
|
94
|
+
|
|
50
95
|
const _renderItem = useCallback(
|
|
51
96
|
({ item, index }) => {
|
|
52
97
|
const paddingLeft = index === 0 ? 0 : 8;
|
|
@@ -73,14 +118,15 @@ const MyUnit = () => {
|
|
|
73
118
|
/>
|
|
74
119
|
<Text style={styles.title}>{item.name}</Text>
|
|
75
120
|
</TouchableOpacity>
|
|
76
|
-
{item.
|
|
77
|
-
<MyUnitDevice key={
|
|
121
|
+
{(item?.abstract_devices || []).map((device, indexDevice) => (
|
|
122
|
+
<MyUnitDevice key={indexDevice} device={device} unit={item} />
|
|
78
123
|
))}
|
|
79
124
|
</View>
|
|
80
125
|
);
|
|
81
126
|
},
|
|
82
127
|
[myUnits.length, goToDetail]
|
|
83
128
|
);
|
|
129
|
+
|
|
84
130
|
return (
|
|
85
131
|
<>
|
|
86
132
|
<Section style={styles.boxTxtMyUnit}>
|
|
@@ -96,6 +142,7 @@ const MyUnit = () => {
|
|
|
96
142
|
itemWidth={screenWidth - 32}
|
|
97
143
|
renderItem={_renderItem}
|
|
98
144
|
inactiveSlideScale={1}
|
|
145
|
+
onSnapToItem={setSlideIndex}
|
|
99
146
|
/>
|
|
100
147
|
) : (
|
|
101
148
|
<View>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { memo, useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { TouchableOpacity, ScrollView } from 'react-native';
|
|
3
|
-
import Popover from '
|
|
3
|
+
import Popover from '../Popover';
|
|
4
4
|
|
|
5
5
|
import styles from './MenuActionMoreStyles';
|
|
6
6
|
import Text from '../Text';
|
|
@@ -12,7 +12,6 @@ const MenuActionMore = memo(
|
|
|
12
12
|
({
|
|
13
13
|
isVisible,
|
|
14
14
|
hideMore,
|
|
15
|
-
hideComplete,
|
|
16
15
|
listMenuItem,
|
|
17
16
|
childRef,
|
|
18
17
|
onItemClick,
|
|
@@ -46,7 +45,6 @@ const MenuActionMore = memo(
|
|
|
46
45
|
placement="bottom"
|
|
47
46
|
from={childRef}
|
|
48
47
|
onRequestClose={hideMore}
|
|
49
|
-
onCloseComplete={hideComplete}
|
|
50
48
|
isVisible={isVisible}
|
|
51
49
|
arrowStyle={styles.wrap}
|
|
52
50
|
>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import Popover from 'react-native-popover-view';
|
|
3
|
+
import { SCContext } from '../../context';
|
|
4
|
+
import { Action } from '../../context/actionType';
|
|
5
|
+
|
|
6
|
+
const PopoverComponent = (props) => {
|
|
7
|
+
const { setAction } = useContext(SCContext);
|
|
8
|
+
|
|
9
|
+
const onCloseStart = () => {
|
|
10
|
+
setAction(Action.SET_POPOVER_ANIMATING, true);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const onCloseComplete = () => {
|
|
14
|
+
setAction(Action.SET_POPOVER_ANIMATING, false);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Popover
|
|
19
|
+
onCloseStart={onCloseStart}
|
|
20
|
+
onCloseComplete={onCloseComplete}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default PopoverComponent;
|
package/src/configs/Constants.js
CHANGED
|
@@ -23,6 +23,7 @@ export const Action = {
|
|
|
23
23
|
NEED_UPDATE_VALUE_EVALUATIONS: 'NEED_UPDATE_VALUE_EVALUATIONS',
|
|
24
24
|
ON_RECEIVE_NOTIFICATION: 'ON_RECEIVE_NOTIFICATION',
|
|
25
25
|
SET_DEVICES_STATUS: 'SET_DEVICES_STATUS',
|
|
26
|
+
SET_POPOVER_ANIMATING: 'SET_POPOVER_ANIMATING',
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
export type AuthData = {
|
|
@@ -80,6 +81,7 @@ export type AppType = {
|
|
|
80
81
|
isNetworkConnected: boolean;
|
|
81
82
|
camera_opened: any[];
|
|
82
83
|
notificationData: any;
|
|
84
|
+
popoverAnimating: boolean;
|
|
83
85
|
};
|
|
84
86
|
|
|
85
87
|
export type IoTType = {
|
package/src/context/reducer.ts
CHANGED
|
@@ -60,6 +60,7 @@ export const initialState = {
|
|
|
60
60
|
isNetworkConnected: false,
|
|
61
61
|
camera_opened: [],
|
|
62
62
|
notificationData: null,
|
|
63
|
+
popoverAnimating: false,
|
|
63
64
|
},
|
|
64
65
|
iot: {
|
|
65
66
|
googlehome: {
|
|
@@ -342,6 +343,15 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
342
343
|
},
|
|
343
344
|
};
|
|
344
345
|
|
|
346
|
+
case Action.SET_POPOVER_ANIMATING:
|
|
347
|
+
return {
|
|
348
|
+
...currentState,
|
|
349
|
+
app: {
|
|
350
|
+
...currentState.app,
|
|
351
|
+
popoverAnimating: payload,
|
|
352
|
+
},
|
|
353
|
+
};
|
|
354
|
+
|
|
345
355
|
default:
|
|
346
356
|
return currentState;
|
|
347
357
|
}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { useSCContextSelector } from '../../context';
|
|
2
2
|
|
|
3
3
|
const useGGHomeDeviceConnected = (device) => {
|
|
4
|
-
const
|
|
4
|
+
const connections = useSCContextSelector(
|
|
5
|
+
(state) => state.iot.googlehome.connections
|
|
6
|
+
);
|
|
7
|
+
const isNetworkConnected = useSCContextSelector(
|
|
8
|
+
(state) => state.app.isNetworkConnected
|
|
9
|
+
);
|
|
5
10
|
|
|
6
|
-
const isConnecting =
|
|
11
|
+
const isConnecting =
|
|
12
|
+
isNetworkConnected && !!device?.chip_id && !(device.chip_id in connections);
|
|
7
13
|
|
|
8
14
|
const isConnected =
|
|
15
|
+
isNetworkConnected &&
|
|
9
16
|
!!device?.chip_id &&
|
|
10
17
|
device.chip_id in connections &&
|
|
11
18
|
!!connections[device.chip_id];
|
|
@@ -2,14 +2,12 @@ import { useCallback, useState, useRef } from 'react';
|
|
|
2
2
|
|
|
3
3
|
const usePopover = () => {
|
|
4
4
|
const [showingPopover, setShowingPopover] = useState(false);
|
|
5
|
-
const [hidingPopoverComplete, setHidingPopoverComplete] = useState(true);
|
|
6
5
|
const childRef = useRef(null);
|
|
7
6
|
|
|
8
7
|
const showPopoverWithRef = useCallback(
|
|
9
8
|
(ref) => {
|
|
10
9
|
childRef.current = ref.current;
|
|
11
10
|
setShowingPopover(true);
|
|
12
|
-
setHidingPopoverComplete(false);
|
|
13
11
|
},
|
|
14
12
|
[childRef]
|
|
15
13
|
);
|
|
@@ -19,17 +17,11 @@ const usePopover = () => {
|
|
|
19
17
|
setShowingPopover(false);
|
|
20
18
|
}, [childRef]);
|
|
21
19
|
|
|
22
|
-
const hidePopoverComplete = useCallback(() => {
|
|
23
|
-
setHidingPopoverComplete(true);
|
|
24
|
-
}, []);
|
|
25
|
-
|
|
26
20
|
return {
|
|
27
21
|
childRef,
|
|
28
22
|
showingPopover,
|
|
29
23
|
showPopoverWithRef,
|
|
30
24
|
hidePopover,
|
|
31
|
-
hidingPopoverComplete,
|
|
32
|
-
hidePopoverComplete,
|
|
33
25
|
};
|
|
34
26
|
};
|
|
35
27
|
|
|
@@ -93,7 +93,11 @@ export const UnitStack = memo((props) => {
|
|
|
93
93
|
if (!id) {
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
const { success, data } = await axiosGet(
|
|
96
|
+
const { success, data } = await axiosGet(
|
|
97
|
+
API.UNIT.FAVOURITE_DEVICES(id),
|
|
98
|
+
{},
|
|
99
|
+
true
|
|
100
|
+
);
|
|
97
101
|
success && setAction(Action.SET_FAVORITE_DEVICES, data);
|
|
98
102
|
};
|
|
99
103
|
fetchFavoriteDevices();
|
|
@@ -102,7 +106,11 @@ export const UnitStack = memo((props) => {
|
|
|
102
106
|
|
|
103
107
|
useEffect(() => {
|
|
104
108
|
const fetchStarredScripts = async () => {
|
|
105
|
-
const { success, data } = await axiosGet(
|
|
109
|
+
const { success, data } = await axiosGet(
|
|
110
|
+
API.AUTOMATE.STARRED_SCRIPTS(),
|
|
111
|
+
{},
|
|
112
|
+
true
|
|
113
|
+
);
|
|
106
114
|
success && setAction(Action.SET_STARRED_SCRIPTS, data);
|
|
107
115
|
};
|
|
108
116
|
fetchStarredScripts();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useCallback, useEffect, memo } from 'react';
|
|
2
|
-
import { View, ActivityIndicator } from 'react-native';
|
|
2
|
+
import { View, ActivityIndicator, Image } from 'react-native';
|
|
3
3
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
4
4
|
import { useNavigation } from '@react-navigation/native';
|
|
5
5
|
|
|
@@ -106,9 +106,16 @@ const GuestInfo = ({ route }) => {
|
|
|
106
106
|
<>
|
|
107
107
|
{!!guest && (
|
|
108
108
|
<View style={styles.userWrap}>
|
|
109
|
-
|
|
110
|
-
<
|
|
111
|
-
|
|
109
|
+
{guest?.avatar ? (
|
|
110
|
+
<Image
|
|
111
|
+
source={{ uri: guest?.avatar }}
|
|
112
|
+
style={styles.avatar}
|
|
113
|
+
/>
|
|
114
|
+
) : (
|
|
115
|
+
<CircleView size={88} center style={styles.avatar}>
|
|
116
|
+
<IconOutline name="user" size={44} color={Colors.Pink1} />
|
|
117
|
+
</CircleView>
|
|
118
|
+
)}
|
|
112
119
|
<Text type="H3" bold>
|
|
113
120
|
{guest.name}
|
|
114
121
|
</Text>
|
|
@@ -11,6 +11,13 @@ export default StyleSheet.create({
|
|
|
11
11
|
alignItems: 'center',
|
|
12
12
|
},
|
|
13
13
|
avatar: {
|
|
14
|
+
height: 88,
|
|
15
|
+
width: 88,
|
|
16
|
+
borderRadius: 44,
|
|
17
|
+
borderWidth: 0.5,
|
|
18
|
+
borderColor: Colors.Gray5,
|
|
19
|
+
justifyContent: 'center',
|
|
20
|
+
alignItems: 'center',
|
|
14
21
|
marginBottom: 16,
|
|
15
22
|
backgroundColor: Colors.Primary,
|
|
16
23
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, memo } from 'react';
|
|
2
2
|
import {
|
|
3
|
+
Image,
|
|
3
4
|
View,
|
|
4
5
|
ScrollView,
|
|
5
6
|
RefreshControl,
|
|
@@ -67,11 +68,19 @@ const ManageAccessScreen = memo(({ route }) => {
|
|
|
67
68
|
key={index.toString()}
|
|
68
69
|
index={index}
|
|
69
70
|
leftIcon={
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
item.user?.avatar ? (
|
|
72
|
+
<Image
|
|
73
|
+
source={{ uri: item.user?.avatar }}
|
|
74
|
+
style={styles.avatar}
|
|
75
|
+
// testID={TESTID.SIDE_MENU_AVATAR_USER}
|
|
76
|
+
/>
|
|
77
|
+
) : (
|
|
78
|
+
<IconOutline
|
|
79
|
+
name="user"
|
|
80
|
+
size={20}
|
|
81
|
+
color={Colors.White}
|
|
82
|
+
/>
|
|
83
|
+
)
|
|
75
84
|
}
|
|
76
85
|
text={
|
|
77
86
|
item.user?.name ||
|
|
@@ -61,6 +61,15 @@ export default StyleSheet.create({
|
|
|
61
61
|
paddingLeft16: {
|
|
62
62
|
paddingLeft: 16,
|
|
63
63
|
},
|
|
64
|
+
avatar: {
|
|
65
|
+
height: 40,
|
|
66
|
+
width: 40,
|
|
67
|
+
borderRadius: 20,
|
|
68
|
+
borderWidth: 0.5,
|
|
69
|
+
borderColor: Colors.Gray5,
|
|
70
|
+
justifyContent: 'center',
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
},
|
|
64
73
|
textNoGuest: {
|
|
65
74
|
alignSelf: 'center',
|
|
66
75
|
marginTop: Constants.height * 0.3,
|
|
@@ -25,6 +25,7 @@ const Timer = ({
|
|
|
25
25
|
normalHeight = 20,
|
|
26
26
|
value,
|
|
27
27
|
selected,
|
|
28
|
+
onScrollEndDrag,
|
|
28
29
|
}) => {
|
|
29
30
|
const scrollViewRef = useRef();
|
|
30
31
|
const [scrollX] = useState(new Animated.Value(0));
|
|
@@ -113,6 +114,8 @@ const Timer = ({
|
|
|
113
114
|
],
|
|
114
115
|
{ useNativeDriver: true }
|
|
115
116
|
)}
|
|
117
|
+
onScrollEndDrag={onScrollEndDrag}
|
|
118
|
+
onMomentumScrollEnd={onScrollEndDrag}
|
|
116
119
|
>
|
|
117
120
|
{renderTime}
|
|
118
121
|
</Animated.ScrollView>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import moment from 'moment';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Animated, TouchableOpacity } from 'react-native';
|
|
4
|
+
import { Calendar } from 'react-native-calendars';
|
|
5
|
+
|
|
4
6
|
import { act, create } from 'react-test-renderer';
|
|
5
7
|
import PlayBackCamera from '..';
|
|
6
8
|
import { ModalCustom } from '../../../commons/Modal';
|
|
@@ -58,6 +60,11 @@ describe('Test PlayBackCamera', () => {
|
|
|
58
60
|
await textOpenModal[0].props.onPress();
|
|
59
61
|
expect(mockSetState).toBeCalledWith(true);
|
|
60
62
|
|
|
63
|
+
const Calendars = instance.findAllByType(Calendar);
|
|
64
|
+
expect(Calendars).toHaveLength(1);
|
|
65
|
+
await Calendars[0].props.onDayPress({ dateString: '2022-07-01' });
|
|
66
|
+
expect(mockSetState).toBeCalledWith('2022-07-01');
|
|
67
|
+
|
|
61
68
|
mockSetState.mockClear();
|
|
62
69
|
const buttonCancel = instance.findAll(
|
|
63
70
|
(el) =>
|
|
@@ -83,7 +90,7 @@ describe('Test PlayBackCamera', () => {
|
|
|
83
90
|
el.type === TouchableOpacity
|
|
84
91
|
);
|
|
85
92
|
await buttonAddDate[0].props.onPress();
|
|
86
|
-
expect(mockSetState).
|
|
93
|
+
expect(mockSetState).toBeCalled();
|
|
87
94
|
|
|
88
95
|
mockSetState.mockClear();
|
|
89
96
|
const buttonSubDate = instance.findAll(
|