@eohjsc/react-native-smart-city 0.2.59 → 0.2.60

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.
Files changed (50) hide show
  1. package/assets/images/Map/MarkerGeolocation.svg +4 -0
  2. package/package.json +1 -1
  3. package/src/commons/DateTimeRangeChange/DateTimeButton.js +1 -1
  4. package/src/commons/Device/HistoryChart.js +12 -16
  5. package/src/commons/Device/HorizontalBarChart.js +46 -30
  6. package/src/commons/FourButtonFilterHistory/__test__/FourButtonFilterHistory.test.js +48 -0
  7. package/src/commons/FourButtonFilterHistory/index.js +72 -0
  8. package/src/commons/FourButtonFilterHistory/styles.js +22 -0
  9. package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +11 -1
  10. package/src/commons/MediaPlayerDetail/index.js +14 -5
  11. package/src/commons/UnitSummary/ConfigHistoryChart.js +2 -1
  12. package/src/configs/API.js +3 -0
  13. package/src/configs/Constants.js +6 -0
  14. package/src/navigations/UnitStack.js +16 -0
  15. package/src/screens/ActivityLog/ItemLog.js +3 -3
  16. package/src/screens/ActivityLog/__test__/ItemLog.test.js +5 -2
  17. package/src/screens/ActivityLog/hooks/index.js +1 -0
  18. package/src/screens/ActivityLog/index.js +0 -1
  19. package/src/screens/AddLocationMaps/index.js +4 -2
  20. package/src/screens/Device/__test__/detail.test.js +3 -2
  21. package/src/screens/Device/detail.js +48 -15
  22. package/src/screens/Device/hooks/useDisconnectedDevice.js +2 -1
  23. package/src/screens/Device/styles.js +3 -3
  24. package/src/screens/EmergencySetting/__test__/DropDownItem.test.js +59 -0
  25. package/src/screens/EmergencySetting/__test__/index.test.js +27 -0
  26. package/src/screens/EmergencySetting/components/DropDownItem.js +54 -0
  27. package/src/screens/EmergencySetting/index.js +90 -0
  28. package/src/screens/EmergencySetting/styles/DropDownItem.js +38 -0
  29. package/src/screens/EmergencySetting/styles.js +19 -0
  30. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +126 -0
  31. package/src/screens/MoveToAnotherSubUnit/index.js +88 -0
  32. package/src/screens/MoveToAnotherSubUnit/styles/MoveToAnotherSubUnitStyles.js +50 -0
  33. package/src/screens/ScriptDetail/Styles/indexStyles.js +0 -1
  34. package/src/screens/SubUnit/AddSubUnitStyles.js +0 -2
  35. package/src/screens/Unit/ChooseLocation.js +3 -7
  36. package/src/screens/Unit/ChooseLocationStyles.js +5 -8
  37. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +1 -1
  38. package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -1
  39. package/src/screens/WaterQualityGuide/index.js +1 -0
  40. package/src/utils/I18n/translations/en.json +6 -0
  41. package/src/utils/I18n/translations/vi.json +6 -0
  42. package/src/utils/Route/index.js +2 -0
  43. package/src/commons/ThreeButtonHistory/CalendarHeader.js +0 -35
  44. package/src/commons/ThreeButtonHistory/CalendarHeaderStyles.js +0 -17
  45. package/src/commons/ThreeButtonHistory/SelectMonth.js +0 -53
  46. package/src/commons/ThreeButtonHistory/SelectMonthStyles.js +0 -29
  47. package/src/commons/ThreeButtonHistory/__test__/SelectMonth.test.js +0 -37
  48. package/src/commons/ThreeButtonHistory/__test__/ThreeButtonHistory.test.js +0 -240
  49. package/src/commons/ThreeButtonHistory/index.js +0 -310
  50. package/src/commons/ThreeButtonHistory/styles.js +0 -65
@@ -0,0 +1,4 @@
1
+ <svg width="24" height="39" viewBox="0 0 24 39" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M12 8.21875C11.0656 8.21875 10.1875 8.58125 9.525 9.24375C9.19945 9.56837 8.94129 9.95415 8.76538 10.3789C8.58947 10.8037 8.49928 11.259 8.5 11.7188C8.5 12.6531 8.86562 13.5312 9.525 14.1938C9.84962 14.5193 10.2354 14.7775 10.6602 14.9534C11.0849 15.1293 11.5403 15.2195 12 15.2188C12.9344 15.2188 13.8125 14.8531 14.475 14.1938C15.1375 13.5312 15.5 12.6531 15.5 11.7188C15.5 10.7844 15.1375 9.90625 14.475 9.24375C13.8125 8.58125 12.9344 8.21875 12 8.21875ZM22.7062 7.03438C22.1179 5.67775 21.2697 4.44944 20.2094 3.41875C19.1456 2.37875 17.8915 1.55331 16.5156 0.9875C15.0844 0.39375 13.5656 0.09375 12 0.09375C10.4344 0.09375 8.91562 0.39375 7.48438 0.984375C6.1 1.55625 4.85938 2.375 3.79063 3.41563C2.73101 4.44689 1.88286 5.67506 1.29375 7.03125C0.684375 8.4375 0.375 9.93125 0.375 11.4688C0.375 13.675 0.903125 15.8719 1.94063 17.9906C2.775 19.6938 3.94063 21.3531 5.40938 22.9312C7.91875 25.625 10.55 27.2719 11.2969 27.7125C11.5089 27.8377 11.7507 27.9036 11.9969 27.9031C12.2406 27.9031 12.4812 27.8406 12.6969 27.7125C13.4437 27.2719 16.075 25.625 18.5844 22.9312C20.0531 21.3562 21.2188 19.6938 22.0531 17.9906C23.0969 15.875 23.625 13.6812 23.625 11.4719C23.625 9.93437 23.3156 8.44063 22.7062 7.03438ZM12 17.2188C8.9625 17.2188 6.5 14.7563 6.5 11.7188C6.5 8.68125 8.9625 6.21875 12 6.21875C15.0375 6.21875 17.5 8.68125 17.5 11.7188C17.5 14.7563 15.0375 17.2188 12 17.2188Z" fill="#1890FF"/>
3
+ <path d="M16.6666 30.2735L15.7266 29.3335L12 33.0602L8.27331 29.3335L7.33331 30.2735L11.06 34.0002L7.33331 37.7268L8.27331 38.6668L12 34.9402L15.7266 38.6668L16.6666 37.7268L12.94 34.0002L16.6666 30.2735Z" fill="#262626"/>
4
+ </svg>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eohjsc/react-native-smart-city",
3
3
  "title": "React Native Smart Home",
4
- "version": "0.2.59",
4
+ "version": "0.2.60",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -7,7 +7,7 @@ import Text from '../Text';
7
7
  import { Colors } from '../../configs';
8
8
 
9
9
  const DateTimeButton = memo(({ onPress, time, date, formatType, style }) => {
10
- let format = 'DD.MM.YY hh:mm';
10
+ let format = 'DD.MM.YY HH:mm';
11
11
  if (formatType === 'date') {
12
12
  format = 'DD.MM.YY';
13
13
  }
@@ -11,7 +11,7 @@ import DateTimeRangeChange from '../DateTimeRangeChange';
11
11
  import HorizontalBarChart from './HorizontalBarChart';
12
12
  import DateTimePickerModal from 'react-native-modal-datetime-picker';
13
13
  import LinearChart from './LinearChart';
14
- import ThreeButtonHistory from '../ThreeButtonHistory';
14
+ import FourButtonFilterHistory from '../FourButtonFilterHistory';
15
15
  import { formatMoney } from '../../utils/Utils';
16
16
 
17
17
  export const dateTimeType = {
@@ -33,6 +33,7 @@ const HistoryChart = memo(
33
33
  endDate,
34
34
  setEndDate,
35
35
  setStartDate,
36
+ groupBy,
36
37
  setGroupBy,
37
38
  configuration,
38
39
  }) => {
@@ -179,25 +180,20 @@ const HistoryChart = memo(
179
180
  {t('history')}
180
181
  </Text>
181
182
  {configuration.type === 'horizontal_bar_chart' && (
182
- <ThreeButtonHistory
183
- setStartDate={setStartDate}
184
- setEndDate={setEndDate}
183
+ <FourButtonFilterHistory
184
+ groupBy={groupBy}
185
185
  setGroupBy={setGroupBy}
186
- startDate={startDate}
187
- endDate={endDate}
188
186
  />
189
187
  )}
190
188
  </View>
191
- {configuration.type !== 'horizontal_bar_chart' && (
192
- <DateTimeRangeChange
193
- startTime={eventPicker.startTime}
194
- onStart={onStart}
195
- onEnd={onEnd}
196
- endTime={eventPicker.endTime}
197
- date={dateNow}
198
- formatType={formatType}
199
- />
200
- )}
189
+ <DateTimeRangeChange
190
+ startTime={eventPicker.startTime}
191
+ onStart={onStart}
192
+ onEnd={onEnd}
193
+ endTime={eventPicker.endTime}
194
+ date={dateNow}
195
+ formatType={formatType}
196
+ />
201
197
  </View>
202
198
  {configuration.config === 'power_consumption' && (
203
199
  <View style={styles.wrapCalculateCost}>
@@ -1,34 +1,18 @@
1
- import React, { memo, useMemo } from 'react';
1
+ import React, { memo, useEffect, useMemo, useState } from 'react';
2
2
  import { View, StyleSheet } from 'react-native';
3
3
  import HighchartsReactNative from '@highcharts/highcharts-react-native/src/HighchartsReactNative';
4
+ import { isEmpty } from 'lodash';
4
5
 
5
6
  import { Colors } from '../../configs';
6
7
  import { getMaxValueIndex } from '../../utils/chartHelper/getMaxValueIndex';
7
8
 
8
9
  const HorizontalBarChart = memo(({ datas, config }) => {
9
- const dataY = datas[0].data.map((item, index) => {
10
- return {
11
- color: index % 2 === 0 ? Colors.Primary + '20' : Colors.Primary + '16',
12
- y: item.y,
13
- };
14
- });
15
- const dataX = datas[0].data.map((item) => item.x);
16
- const heightChart = useMemo(() => {
17
- return dataX.length > 1 ? dataX.length * 55 : 90;
18
- }, [dataX]);
19
- const maxY = getMaxValueIndex(dataY);
20
- dataY.splice(maxY._index, 1, { ...maxY.max, color: Colors.Primary });
21
-
22
- // eslint-disable-next-line no-unused-vars
23
- const chartOptions = {
10
+ const [chartOptions, setChartOptions] = useState({
24
11
  chart: {
25
12
  type: 'bar',
26
13
  style: {
27
14
  fontFamily: 'Arial',
28
15
  },
29
- scrollablePlotArea: {
30
- minHeight: dataY.length * 32,
31
- },
32
16
  },
33
17
  credits: {
34
18
  enabled: false,
@@ -37,7 +21,6 @@ const HorizontalBarChart = memo(({ datas, config }) => {
37
21
  text: '',
38
22
  },
39
23
  xAxis: {
40
- categories: dataX,
41
24
  title: {
42
25
  text: null,
43
26
  },
@@ -45,14 +28,6 @@ const HorizontalBarChart = memo(({ datas, config }) => {
45
28
  enabled: true,
46
29
  },
47
30
  },
48
- series: [
49
- {
50
- marker: { enabled: true },
51
- color: Colors.Primary + '50',
52
- name: JSON.stringify(config),
53
- data: dataY,
54
- },
55
- ],
56
31
  time: {
57
32
  timezoneOffset: -7 * 60,
58
33
  },
@@ -85,7 +60,7 @@ const HorizontalBarChart = memo(({ datas, config }) => {
85
60
  const costStyle = valueStyle + 'font-weight:bold;';
86
61
 
87
62
  let label = `<span style="${valueStyle}">` + `${this.y}${unit}`;
88
- if (price === null || isNaN(price)) {
63
+ if (price === '' || price === null || isNaN(price)) {
89
64
  return label + '</span>';
90
65
  }
91
66
 
@@ -119,7 +94,48 @@ const HorizontalBarChart = memo(({ datas, config }) => {
119
94
  shadow: false,
120
95
  },
121
96
  },
122
- };
97
+ });
98
+
99
+ const heightChart = useMemo(() => {
100
+ const dataX = datas[0].data.map((item) => item.x);
101
+ return dataX.length > 1 ? dataX.length * 55 : 90;
102
+ }, [datas]);
103
+
104
+ useEffect(() => {
105
+ const dataY = datas[0].data.map((item, index) => {
106
+ return {
107
+ color: index % 2 === 0 ? Colors.Primary + '20' : Colors.Primary + '16',
108
+ y: item.y,
109
+ };
110
+ });
111
+ const dataX = datas[0].data.map((item) => item.x);
112
+ const maxY = getMaxValueIndex(dataY);
113
+ if (!isEmpty(maxY.max)) {
114
+ dataY.splice(maxY._index, 1, { ...maxY.max, color: Colors.Primary });
115
+ }
116
+
117
+ setChartOptions((options) => ({
118
+ ...options,
119
+ chart: {
120
+ ...options.chart,
121
+ scrollablePlotArea: {
122
+ minHeight: dataY.length * 32,
123
+ },
124
+ },
125
+ xAxis: {
126
+ ...options.xAxis,
127
+ categories: dataX,
128
+ },
129
+ series: [
130
+ {
131
+ marker: { enabled: true },
132
+ color: Colors.Primary + '50',
133
+ name: JSON.stringify(config),
134
+ data: dataY,
135
+ },
136
+ ],
137
+ }));
138
+ }, [datas, config]);
123
139
 
124
140
  return (
125
141
  <View style={[styles.container, { height: heightChart }]}>
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import { act, create } from 'react-test-renderer';
3
+ import { SCProvider } from '../../../context';
4
+ import { mockSCStore } from '../../../context/mockStore';
5
+ import FourButtonFilterHistory from '../index';
6
+ import { TouchableOpacity } from 'react-native';
7
+
8
+ const wrapComponent = (props) => (
9
+ <SCProvider initState={mockSCStore({})}>
10
+ <FourButtonFilterHistory {...props} />
11
+ </SCProvider>
12
+ );
13
+
14
+ jest.mock('react', () => {
15
+ return {
16
+ ...jest.requireActual('react'),
17
+ memo: (x) => x,
18
+ };
19
+ });
20
+
21
+ test('test', async () => {
22
+ const mockSetGroupBy = jest.fn();
23
+ let tree;
24
+ let props = {
25
+ groupBy: 'date',
26
+ setGroupBy: mockSetGroupBy,
27
+ };
28
+
29
+ await act(async () => {
30
+ tree = await create(wrapComponent(props));
31
+ });
32
+ const instance = tree.root;
33
+ const buttons = instance.findAllByType(TouchableOpacity);
34
+ expect(buttons).toHaveLength(4);
35
+
36
+ const clickButton = async (index, data) => {
37
+ mockSetGroupBy.mockClear();
38
+ await act(async () => {
39
+ await buttons[index].props.onPress();
40
+ });
41
+ expect(mockSetGroupBy).toBeCalledWith(data);
42
+ };
43
+
44
+ await clickButton(0, 'date');
45
+ await clickButton(1, 'week');
46
+ await clickButton(2, 'month');
47
+ await clickButton(3, 'year');
48
+ });
@@ -0,0 +1,72 @@
1
+ import React, { memo, useCallback, useMemo } from 'react';
2
+ import { View, TouchableOpacity } from 'react-native';
3
+ import Text from '../Text';
4
+ import { Colors } from '../../configs';
5
+ import styles from './styles';
6
+
7
+ const FourButtonFilterHistory = memo(({ groupBy, setGroupBy }) => {
8
+ const listItem = useMemo(
9
+ () => [
10
+ {
11
+ title: 'D',
12
+ data: 'date',
13
+ },
14
+
15
+ {
16
+ title: 'W',
17
+ data: 'week',
18
+ },
19
+
20
+ {
21
+ title: 'M',
22
+ data: 'month',
23
+ },
24
+
25
+ {
26
+ title: 'Y',
27
+ data: 'year',
28
+ },
29
+ ],
30
+ []
31
+ );
32
+
33
+ const ItemButton = memo(({ title, onPress, isSelected }) => {
34
+ return (
35
+ <TouchableOpacity
36
+ onPress={onPress}
37
+ style={[styles.button, isSelected && styles.selectedButton]}
38
+ >
39
+ <View>
40
+ <Text bold color={isSelected && Colors.Primary}>
41
+ {title}
42
+ </Text>
43
+ </View>
44
+ </TouchableOpacity>
45
+ );
46
+ }, []);
47
+
48
+ const onPressButton = useCallback(
49
+ (data) => () => {
50
+ setGroupBy(data);
51
+ },
52
+ [setGroupBy]
53
+ );
54
+
55
+ return (
56
+ <View style={styles.row}>
57
+ {listItem &&
58
+ listItem.map((item, index) => {
59
+ return (
60
+ <ItemButton
61
+ key={index}
62
+ title={item.title}
63
+ onPress={onPressButton(item.data)}
64
+ isSelected={item.data === groupBy}
65
+ />
66
+ );
67
+ })}
68
+ </View>
69
+ );
70
+ });
71
+
72
+ export default FourButtonFilterHistory;
@@ -0,0 +1,22 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { Colors } from '../../configs';
3
+
4
+ export default StyleSheet.create({
5
+ row: {
6
+ flexDirection: 'row',
7
+ alignItems: 'center',
8
+ backgroundColor: Colors.Gray4,
9
+ borderRadius: 5,
10
+ padding: 2,
11
+ },
12
+ button: {
13
+ width: 31,
14
+ height: 28,
15
+ alignItems: 'center',
16
+ justifyContent: 'center',
17
+ borderRadius: 5,
18
+ },
19
+ selectedButton: {
20
+ backgroundColor: Colors.White,
21
+ },
22
+ });
@@ -69,7 +69,17 @@ export default StyleSheet.create({
69
69
  bottom: 0,
70
70
  },
71
71
  firstOpenCamera: {
72
- zIndex: -10,
72
+ zIndex: -9999,
73
73
  position: 'absolute',
74
+ width: 1,
75
+ height: 1,
76
+ },
77
+ loading: {
78
+ position: 'absolute',
79
+ zIndex: 10,
80
+ width: '100%',
81
+ height: '100%',
82
+ justifyContent: 'center',
83
+ alignItems: 'center',
74
84
  },
75
85
  });
@@ -13,6 +13,7 @@ import {
13
13
  Text,
14
14
  TouchableOpacity,
15
15
  Platform,
16
+ ActivityIndicator,
16
17
  } from 'react-native';
17
18
  import { VLCPlayer } from 'react-native-vlc-media-player';
18
19
  import { useTranslations } from '../../hooks/Common/useTranslations';
@@ -46,9 +47,10 @@ const MediaPlayerDetail = ({
46
47
  );
47
48
  const t = useTranslations();
48
49
  const [paused, setPaused] = useState(isPaused);
50
+
49
51
  const onTapPause = useCallback(() => {
50
- setPaused(false);
51
- }, []);
52
+ !isFirstOpenCamera && setPaused(false);
53
+ }, [isFirstOpenCamera]);
52
54
 
53
55
  const onTapGoDetail = useCallback(() => {
54
56
  if (!paused) {
@@ -139,7 +141,7 @@ const MediaPlayerDetail = ({
139
141
  const to = setTimeout(() => {
140
142
  setAction(Action.IS_FIRST_OPEN_CAMERA, false);
141
143
  clearTimeout(to);
142
- }, 500);
144
+ }, 1000);
143
145
  }
144
146
  // eslint-disable-next-line react-hooks/exhaustive-deps
145
147
  }, [isFirstOpenCamera]);
@@ -147,7 +149,14 @@ const MediaPlayerDetail = ({
147
149
  const source = !thumbnail || !thumbnail.uri ? Images.BgDevice : thumbnail;
148
150
  return (
149
151
  <View style={[styles.wrap, wrapStyles]}>
150
- {isFirstOpenCamera && Platform.OS === 'ios' && renderCamera}
152
+ {isFirstOpenCamera && Platform.OS === 'ios' && (
153
+ <>
154
+ {renderCamera}
155
+ <View style={styles.loading}>
156
+ <ActivityIndicator size={'small'} color={Colors.Primary} />
157
+ </View>
158
+ </>
159
+ )}
151
160
  <View style={[styles.loadingWrap]}>
152
161
  <Text style={styles.loadingText}>{t('loading')}</Text>
153
162
  </View>
@@ -172,7 +181,7 @@ const MediaPlayerDetail = ({
172
181
  />
173
182
  </View>
174
183
  ) : (
175
- renderCamera
184
+ !isFirstOpenCamera && renderCamera
176
185
  )}
177
186
 
178
187
  <View style={styles.buttonView}>
@@ -45,7 +45,8 @@ const ConfigHistoryChart = memo(({ configs }) => {
45
45
  }
46
46
  };
47
47
  fetchData();
48
- }, [startDate, endDate, configs]);
48
+ // eslint-disable-next-line react-hooks/exhaustive-deps
49
+ }, [startDate, endDate]);
49
50
 
50
51
  if (!chartData.length) {
51
52
  return false;
@@ -82,6 +82,9 @@ const API = {
82
82
  SCConfig.apiRoot + `/property_manager/sensors/${id}/`,
83
83
  REMOVE_SENSOR: (id) =>
84
84
  SCConfig.apiRoot + `/property_manager/sensors/${id}/`,
85
+ CHANGE_SUB_UNIT: (unit_id, station_id, id) =>
86
+ SCConfig.apiRoot +
87
+ `/property_manager/${unit_id}/sub_units/${station_id}/devices/${id}/change_sub_unit/`,
85
88
  },
86
89
  SHARED_SENSOR: {
87
90
  ACCESS: (id) =>
@@ -573,9 +573,15 @@ export const TESTID = {
573
573
  HISTORY_BUTTON: 'HISTORY_BUTTON',
574
574
  HISTORY_CALENDAR: 'HISTORY_CALENDAR',
575
575
 
576
+ // DropDownPicker
577
+ DROP_DOWN_PICKER_ITEM: 'DROP_DOWN_PICKER_ITEM',
578
+
576
579
  // SelectAddress
577
580
  BUTTON_YOUR_LOCATION: 'BUTTON_YOUR_LOCATION',
578
581
  BUTTON_CHOOSE_ON_MAP: 'BUTTON_CHOOSE_ON_MAP',
582
+
583
+ // MoveToAnotherSubUnit
584
+ ROW_SUB_UNIT: 'ROW_SUB_UNIT',
579
585
  };
580
586
 
581
587
  export const NOTIFICATION_TYPES = {
@@ -31,6 +31,7 @@ import AddNewAutoSmart from '../screens/AddNewAutoSmart';
31
31
  import PlaybackCamera from '../screens/PlayBackCamera';
32
32
  import AllCamera from '../screens/AllCamera';
33
33
  import ManageAccessScreen from '../screens/ManageAccess';
34
+ import MoveToAnotherSubUnit from '../screens/MoveToAnotherSubUnit';
34
35
  import GuestInfo from '../screens/GuestInfo';
35
36
  import ScriptDetail from '../screens/ScriptDetail';
36
37
  import EditActionsList from '../screens/EditActionsList';
@@ -41,6 +42,7 @@ import SelectAction from '../screens/AddNewAction/SelectAction';
41
42
  import EditSubUnit from '../screens/SubUnit/EditSubUnit';
42
43
  import SetUpSensor from '../screens/AddNewAction/SetupSensor';
43
44
  import EditDevice from '../screens/Device/EditDevice/index';
45
+ import EmergencySetting from '../screens/EmergencySetting';
44
46
 
45
47
  const Stack = createStackNavigator();
46
48
 
@@ -229,6 +231,13 @@ export const UnitStack = memo((props) => {
229
231
  headerShown: false,
230
232
  }}
231
233
  />
234
+ <Stack.Screen
235
+ name={Route.MoveToAnotherSubUnit}
236
+ component={MoveToAnotherSubUnit}
237
+ options={{
238
+ headerShown: false,
239
+ }}
240
+ />
232
241
  <Stack.Screen
233
242
  name={Route.GuestInfo}
234
243
  component={GuestInfo}
@@ -291,6 +300,13 @@ export const UnitStack = memo((props) => {
291
300
  headerShown: false,
292
301
  }}
293
302
  />
303
+ <Stack.Screen
304
+ name={Route.EmergencySetting}
305
+ component={EmergencySetting}
306
+ options={{
307
+ headerShown: false,
308
+ }}
309
+ />
294
310
  </Stack.Navigator>
295
311
  );
296
312
  });
@@ -29,14 +29,14 @@ const DetailLog = ({ item }) => {
29
29
  {item.action_name
30
30
  ? `${item.action_name} ${t('by')} `
31
31
  : `${t('activated_by')} `}
32
- <Text style={styles.name}>{item.name || item.params?.username}</Text>
32
+ <Text style={styles.name}>{item.name || item.username}</Text>
33
33
  </Text>
34
34
  );
35
35
  case ACTIVITY_LOG_TYPES.SCRIPT_UPDATED_BY:
36
36
  return (
37
37
  <Text style={styles.text}>
38
38
  {`${t('script_updated_by')} `}
39
- <Text style={styles.name}>{item.name || item.params?.username}</Text>
39
+ <Text style={styles.name}>{item.name || item.username}</Text>
40
40
  </Text>
41
41
  );
42
42
  default:
@@ -45,7 +45,7 @@ const DetailLog = ({ item }) => {
45
45
  {item.action_name
46
46
  ? `${item.action_name} ${t('by')} `
47
47
  : `${t('activated_by')} `}
48
- <Text style={styles.name}>{item.name || item.params?.username}</Text>
48
+ <Text style={styles.name}>{item.name || item.username}</Text>
49
49
  </Text>
50
50
  );
51
51
  }
@@ -46,6 +46,7 @@ test('test ItemLog one tap', () => {
46
46
  params: {
47
47
  username: 'username',
48
48
  },
49
+ username: 'username',
49
50
  created_at: '2021-07-02T15:48:24.917932Z',
50
51
  },
51
52
  type: `automate.${AUTOMATE_TYPE.ONE_TAP}`,
@@ -68,6 +69,7 @@ test('test ItemLog script update', () => {
68
69
  params: {
69
70
  username: 'username',
70
71
  },
72
+ username: 'username',
71
73
  created_at: '2021-07-02T15:48:24.917932Z',
72
74
  },
73
75
  type: 'automate',
@@ -79,7 +81,7 @@ test('test ItemLog script update', () => {
79
81
  });
80
82
  const instance = tree.root;
81
83
  const texts = instance.findAllByType(Text);
82
- expect(texts[2].props.children).toBe(props.item.params.username);
84
+ expect(texts[2].props.children).toBe(props.item.username);
83
85
  });
84
86
 
85
87
  test('test ItemLog no content_code', () => {
@@ -91,6 +93,7 @@ test('test ItemLog no content_code', () => {
91
93
  },
92
94
  created_at: '2021-07-02T15:48:24.917932Z',
93
95
  },
96
+ username: 'username',
94
97
  type: 'action',
95
98
  length: 2,
96
99
  index: 1,
@@ -100,7 +103,7 @@ test('test ItemLog no content_code', () => {
100
103
  });
101
104
  const instance = tree.root;
102
105
  const texts = instance.findAllByType(Text);
103
- expect(texts[2].props.children).toBe(props.item.params.username);
106
+ expect(texts[2].props.children).toBe(props.item.username);
104
107
  });
105
108
 
106
109
  describe('test ItemLog emergency event', () => {
@@ -12,6 +12,7 @@ const apiMaps = {
12
12
  url: () => API.SENSOR.ACTIVITY_LOG(),
13
13
  params: (id) => ({ id: id }),
14
14
  standardizeData: getDataForList,
15
+ memberUrl: (id) => API.SHARE.UNITS_MEMBERS(id),
15
16
  },
16
17
  ['emergency_event']: {
17
18
  url: () => API.EMERGENCY_BUTTON.ACTIVITY_LOG(),
@@ -66,7 +66,6 @@ const ActivityLogScreen = ({ route }) => {
66
66
  {getTitleFromTime(data[0].created_at, new Date())}
67
67
  </Text>
68
68
  );
69
-
70
69
  useEffect(() => {
71
70
  onRefresh();
72
71
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -24,6 +24,8 @@ const initialRegion = {
24
24
  const DEFAULT_LATITUDE = 10.7974046; // EoH center
25
25
  const DEFAULT_LONGITUDE = 106.7035663;
26
26
 
27
+ navigator.geolocation = require('@react-native-community/geolocation');
28
+
27
29
  const AddLocationMaps = memo(() => {
28
30
  const t = useTranslations();
29
31
  const { goBack, navigate } = useNavigation();
@@ -135,7 +137,7 @@ const AddLocationMaps = memo(() => {
135
137
  }
136
138
  },
137
139
  (error) => {},
138
- { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 }
140
+ {}
139
141
  );
140
142
  }, []);
141
143
 
@@ -231,7 +233,7 @@ const AddLocationMaps = memo(() => {
231
233
  latitude: searchedLocation.latitude,
232
234
  longitude: searchedLocation.longitude,
233
235
  }}
234
- radius={1000}
236
+ radius={300}
235
237
  fillColor={Colors.BlueTransparent5}
236
238
  strokeColor={Colors.Blue10}
237
239
  />
@@ -812,9 +812,10 @@ describe('test DeviceDetail', () => {
812
812
  expect(mockedNavigate).toHaveBeenCalledWith(Routes.ActivityLog, {
813
813
  id: route.params.sensor.id,
814
814
  type: 'action',
815
+ share: route.params.unit,
815
816
  filterEnabled: {
816
- date: false,
817
- user: false,
817
+ date: true,
818
+ user: Boolean(route.params.unit.id),
818
819
  },
819
820
  });
820
821
  });