@eohjsc/react-native-smart-city 0.3.59 → 0.3.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.
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.3.59",
4
+ "version": "0.3.60",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -209,11 +209,10 @@ const API = {
209
209
  // NOTE: DEV MODE
210
210
  DEV_MODE: {
211
211
  DASHBOARD: {
212
- DETAIL: (id) =>
213
- `/property_manager/iot_dashboard/dev_mode/templates/${id}/`,
214
- GET_TEMPLATES: '/property_manager/iot_dashboard/dev_mode/templates/',
212
+ DETAIL: (id) => `/property_manager/iot_dashboard/dev_mode/units/${id}/`,
213
+ GET_TEMPLATES: '/property_manager/iot_dashboard/dev_mode/units/',
215
214
  GET_WIDGETS: (templateId) =>
216
- `/property_manager/iot_dashboard/dev_mode/templates/${templateId}/widgets/`,
215
+ `/property_manager/iot_dashboard/dev_mode/units/${templateId}/widgets/`,
217
216
  },
218
217
  GATEWAY: {
219
218
  LIST: () => '/chip_manager/developer_mode_chips/',
@@ -62,7 +62,7 @@ export const SensorDisplayItem = ({
62
62
  if (type === 'compass') {
63
63
  setShowWindDirection && setShowWindDirection(true);
64
64
  }
65
- switch (item.type) {
65
+ switch (item.template) {
66
66
  case 'camera':
67
67
  return (
68
68
  <CardDevMode title={t('camera')} id={idTemplate} isWrap>
@@ -41,7 +41,7 @@ describe('Test EditTemplate', () => {
41
41
  const data = [
42
42
  {
43
43
  id: 1,
44
- type: 'camera',
44
+ template: 'camera',
45
45
  configuration: {
46
46
  uri: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
47
47
  },
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import { FlatList, TouchableOpacity } from 'react-native';
4
4
  import { act, create } from 'react-test-renderer';
5
5
  import Template from '..';
6
+ import { Search } from '../../../commons/DevMode';
6
7
  import { API } from '../../../configs';
7
8
  import api from '../../../utils/Apis/axios';
8
9
 
@@ -39,4 +40,47 @@ describe('Test Template screen', () => {
39
40
  await TouchableOpacities[0].props.onPress();
40
41
  expect(mockNavigate).toBeCalled();
41
42
  });
43
+
44
+ it('Test onSearch', async () => {
45
+ mock.onGet(API.DEV_MODE.DASHBOARD.GET_TEMPLATES).reply(200, [
46
+ {
47
+ id: 1,
48
+ name: 'Template1',
49
+ description: 'test',
50
+ },
51
+ {
52
+ id: 1,
53
+ name: 'Template2',
54
+ description: 'test2',
55
+ },
56
+ ]);
57
+ await act(async () => {
58
+ tree = await create(<Template />);
59
+ });
60
+ const instance = tree.root;
61
+ const search = instance.findByType(Search);
62
+ await act(async () => {
63
+ await search.props.onSearch('Template1');
64
+ });
65
+ const flatList = instance.findByType(FlatList);
66
+ expect(flatList.props.data).toEqual([
67
+ { description: 'test', id: 1, name: 'Template1' },
68
+ ]);
69
+
70
+ await act(async () => {
71
+ await search.props.onSearch('');
72
+ });
73
+ expect(flatList.props.data).toEqual([
74
+ {
75
+ id: 1,
76
+ name: 'Template1',
77
+ description: 'test',
78
+ },
79
+ {
80
+ id: 1,
81
+ name: 'Template2',
82
+ description: 'test2',
83
+ },
84
+ ]);
85
+ });
42
86
  });
@@ -184,7 +184,7 @@ const TemplateDetail = () => {
184
184
  return;
185
185
  }
186
186
 
187
- const _data = _item?.configuration?.configs.map((config) => {
187
+ const _data = (_item?.configuration?.configs || []).map((config) => {
188
188
  const configValue = configValues[config.id]?.value;
189
189
  if ([null, undefined, NaN].includes(configValue)) {
190
190
  return;
@@ -22,6 +22,7 @@ const Template = () => {
22
22
  const [data, setData] = useState([]);
23
23
  const { navigate } = useNavigation();
24
24
  const isFocused = useIsFocused();
25
+ const [isRefreshing, setIsRefreshing] = useState(false);
25
26
 
26
27
  const onSearch = useCallback((value) => {
27
28
  if (value === '') {
@@ -42,6 +43,7 @@ const Template = () => {
42
43
  );
43
44
 
44
45
  const getTemplates = useCallback(async () => {
46
+ setIsRefreshing(true);
45
47
  const { success, data: dataDashboard } = await axiosGet(
46
48
  API.DEV_MODE.DASHBOARD.GET_TEMPLATES
47
49
  );
@@ -49,6 +51,7 @@ const Template = () => {
49
51
  setData(dataDashboard || []);
50
52
  arrTemplates = dataDashboard;
51
53
  }
54
+ setIsRefreshing(false);
52
55
  }, []);
53
56
 
54
57
  const renderListEmptyComponent = useMemo(() => {
@@ -84,6 +87,9 @@ const Template = () => {
84
87
  extraData={data}
85
88
  ListEmptyComponent={renderListEmptyComponent}
86
89
  numColumns={2}
90
+ showsVerticalScrollIndicator={false}
91
+ refreshing={isRefreshing}
92
+ onRefresh={getTemplates}
87
93
  />
88
94
  </View>
89
95
  </TouchableWithoutFeedback>
@@ -75,7 +75,6 @@ const parseErrorResponse = async (error) => {
75
75
  if (message?.message) {
76
76
  message = message.message;
77
77
  }
78
- message = `${firstKey}: ${message}`;
79
78
  } else {
80
79
  message = error.data || error.problem;
81
80
  }