@eohjsc/react-native-smart-city 0.7.11 → 0.7.13

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 (25) hide show
  1. package/package.json +4 -3
  2. package/src/commons/Header/Styles/HeaderCustomStyles.js +2 -1
  3. package/src/commons/Sharing/MemberList.js +28 -20
  4. package/src/commons/Sharing/RowMember.js +80 -135
  5. package/src/commons/Sharing/__test__/MemberList.test.js +7 -10
  6. package/src/commons/Sharing/__test__/RowMember.test.js +111 -14
  7. package/src/configs/AccessibilityLabel.js +6 -2
  8. package/src/hooks/Common/useIsOwnerOfUnit.js +0 -1
  9. package/src/screens/Automate/AddNewAction/SetupScriptReceiverEmail.js +2 -1
  10. package/src/screens/Automate/AddNewAction/Styles/SetupScriptReceiverEmailStyles.js +7 -1
  11. package/src/screens/Automate/EditActionsList/Styles/UpdateReceiverEmailScriptStyles.js +6 -0
  12. package/src/screens/Automate/EditActionsList/Styles/indexStyles.js +6 -3
  13. package/src/screens/Automate/EditActionsList/UpdateNotifyScript.js +5 -3
  14. package/src/screens/Automate/EditActionsList/UpdateReceiverEmailScript.js +1 -0
  15. package/src/screens/Automate/EditActionsList/index.js +5 -2
  16. package/src/screens/Automate/ScriptDetail/Styles/indexStyles.js +4 -0
  17. package/src/screens/Automate/ScriptDetail/index.js +5 -2
  18. package/src/screens/Sharing/UnitMemberList.js +75 -52
  19. package/src/screens/Sharing/__test__/UnitMemberList.test.js +129 -32
  20. package/src/screens/Sharing/hooks/__test__/index.test.js +6 -5
  21. package/src/screens/Sharing/hooks/index.js +5 -4
  22. package/src/screens/SubUnit/ManageSubUnit.js +12 -9
  23. package/src/screens/SubUnit/RearrageSubUnit.js +8 -7
  24. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +24 -9
  25. package/src/screens/SubUnit/__test__/RearrangeSubUnit.test.js +20 -10
@@ -12,6 +12,7 @@ export default StyleSheet.create({
12
12
  wrapContent: {
13
13
  flex: 1,
14
14
  paddingHorizontal: 20,
15
+ marginBottom: 100,
15
16
  },
16
17
  wrapItem: {
17
18
  flexDirection: 'row',
@@ -50,12 +51,14 @@ export default StyleSheet.create({
50
51
  noBorder: {
51
52
  borderWidth: 0,
52
53
  },
54
+ icon: {
55
+ alignItems: 'center',
56
+ justifyContent: 'center',
57
+ marginRight: 10,
58
+ },
53
59
  iconItem: {
54
60
  width: 35,
55
61
  height: 35,
56
- marginTop: 6,
57
- marginRight: 15,
58
- alignItems: 'center',
59
62
  },
60
63
  contentItem: {
61
64
  flex: 1,
@@ -20,7 +20,7 @@ const UpdateNotifyScript = ({
20
20
  updateIndex,
21
21
  setNeedRefresh,
22
22
  }) => {
23
- const { title, message } = notify_script;
23
+ const { title, message, unit_id, unit_name } = notify_script;
24
24
  const [newValue, setNewValue] = useState({
25
25
  newTitle: title,
26
26
  newMessage: message,
@@ -31,7 +31,7 @@ const UpdateNotifyScript = ({
31
31
  API.AUTOMATE.UPDATE_SCRIPT_NOTIFY(automateId),
32
32
  {
33
33
  id: scriptItemId,
34
- unit: unitId,
34
+ unit: unit_id,
35
35
  title: newValue.newTitle,
36
36
  message: newValue.newMessage,
37
37
  }
@@ -40,6 +40,7 @@ const UpdateNotifyScript = ({
40
40
  actionsList[updateIndex].notify_script = {
41
41
  title: newValue.newTitle,
42
42
  message: newValue.newMessage,
43
+ unit_name: unit_name,
43
44
  };
44
45
  setActionList(actionsList);
45
46
  onClosePopup();
@@ -56,7 +57,8 @@ const UpdateNotifyScript = ({
56
57
  setActionList,
57
58
  setNeedRefresh,
58
59
  t,
59
- unitId,
60
+ unit_id,
61
+ unit_name,
60
62
  updateIndex,
61
63
  ]);
62
64
 
@@ -123,6 +123,7 @@ const UpdateReceiverEmailScript = ({ route }) => {
123
123
  lineWidth={4}
124
124
  value={listUser.includes(id)}
125
125
  onValueChange={onValueChange(id)}
126
+ style={styles.checkbox}
126
127
  />
127
128
  <View style={styles.paddingLeft16}>
128
129
  {avatar ? (
@@ -124,7 +124,7 @@ const EditActionsList = () => {
124
124
  onLongPress={onPressUpdate}
125
125
  accessibilityLabel={AccessibilityLabel.BUTTON_UPDATE}
126
126
  >
127
- {icon}
127
+ <View style={styles.icon}>{icon}</View>
128
128
  <View style={styles.contentItem}>{content}</View>
129
129
  <TouchableOpacity
130
130
  accessibilityLabel={AccessibilityLabel.BUTTON_REMOVE_EDIT_ACTION_LIST}
@@ -183,7 +183,7 @@ const EditActionsList = () => {
183
183
  }
184
184
 
185
185
  if (notify_script) {
186
- const { title, message } = notify_script;
186
+ const { title, message, unit_name } = notify_script;
187
187
 
188
188
  return (
189
189
  <CommonItem
@@ -201,6 +201,9 @@ const EditActionsList = () => {
201
201
  <Text numberOfLines={1} type="H4" color={Colors.Gray9}>
202
202
  {message}
203
203
  </Text>
204
+ <Text numberOfLines={1} type="H4" color={Colors.Gray9}>
205
+ {unit_name}
206
+ </Text>
204
207
  </>
205
208
  }
206
209
  onPress={() => onPressRemove(item)}
@@ -89,6 +89,8 @@ export default StyleSheet.create({
89
89
  paddingHorizontal: 16,
90
90
  marginLeft: 4,
91
91
  flexDirection: 'row',
92
+ justifyContent: 'center',
93
+ alignItems: 'center',
92
94
  },
93
95
  leftItem: {
94
96
  width: 41,
@@ -179,5 +181,7 @@ export default StyleSheet.create({
179
181
  height: 35,
180
182
  marginTop: 6,
181
183
  marginRight: 15,
184
+ justifyContent: 'center',
185
+ alignItems: 'center',
182
186
  },
183
187
  });
@@ -447,7 +447,7 @@ const Item = ({ item, index, enableScript, t }) => {
447
447
  </View>
448
448
  );
449
449
  } else if (notify_script) {
450
- const { title, message } = notify_script;
450
+ const { title, message, unit_name } = notify_script;
451
451
  return (
452
452
  <View style={styles.wrapItem}>
453
453
  <View style={styles.leftItem}>
@@ -469,6 +469,9 @@ const Item = ({ item, index, enableScript, t }) => {
469
469
  </Text>
470
470
  </View>
471
471
  </View>
472
+ <Text numberOfLines={1} type="H4" color={color}>
473
+ {unit_name}
474
+ </Text>
472
475
  </View>
473
476
  </View>
474
477
  );
@@ -481,7 +484,7 @@ const Item = ({ item, index, enableScript, t }) => {
481
484
  {paddedIndex}
482
485
  </Text>
483
486
  </View>
484
- <View style={styles.rightItem}>
487
+ <View style={styles.rightItemAction}>
485
488
  <View style={styles.iconEndDevice}>
486
489
  <Delay />
487
490
  </View>
@@ -1,33 +1,41 @@
1
- import React, { useCallback, useEffect } from 'react';
2
- import { IconOutline } from '@ant-design/icons-react-native';
3
- import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
4
- import { useNavigation, useIsFocused } from '@react-navigation/native';
1
+ import React, {
2
+ Fragment,
3
+ useCallback,
4
+ useEffect,
5
+ useMemo,
6
+ useState,
7
+ } from 'react';
5
8
  import { StyleSheet, TouchableOpacity, View } from 'react-native';
6
- import { useTranslations } from '../../hooks/Common/useTranslations';
9
+ import { useDataMember, useStateAlertAction } from './hooks';
10
+ import { useIsFocused, useNavigation } from '@react-navigation/native';
7
11
 
12
+ import { AccessibilityLabel } from '../../configs/Constants';
13
+ import AlertAction from '../../commons/AlertAction';
8
14
  import { Colors } from '../../configs';
9
- import Routes from '../../utils/Route';
15
+ import { HeaderCustom } from '../../commons';
16
+ import { IconOutline } from '@ant-design/icons-react-native';
17
+ import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
10
18
  import MemberList from '../../commons/Sharing/MemberList';
11
- import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
19
+ import Routes from '../../utils/Route';
20
+ import { Search } from '../../commons/DevMode';
21
+ import { ToastBottomHelper } from '../../utils/Utils';
22
+ import { convertToSlug } from '../../utils/Functions/Search';
23
+ import { useBackendPermission } from '../../utils/Permission/backend';
12
24
  import { useIsOwnerOfUnit } from '../../hooks/Common';
13
- import AlertAction from '../../commons/AlertAction';
14
-
15
- import { useDataMember, useStateAlertAction } from './hooks';
16
- import { AccessibilityLabel } from '../../configs/Constants';
17
25
  import { useSCContextSelector } from '../../context';
18
- import { useBackendPermission } from '../../utils/Permission/backend';
19
- import { ToastBottomHelper } from '../../utils/Utils';
26
+ import { useTranslations } from '../../hooks/Common/useTranslations';
20
27
 
21
28
  const UnitMemberList = ({ route }) => {
22
29
  const t = useTranslations();
23
30
  const { navigate } = useNavigation();
24
31
  const isFocused = useIsFocused();
25
32
  const account = useSCContextSelector((state) => state.auth.account);
26
- const { unitId, unit } = route?.params || {};
33
+ const { unitId, unit } = route?.params;
27
34
  const { dataMembers, isRefresh, onRefresh, leaveUnit, loading } =
28
35
  useDataMember(unitId, unit?.user_id);
29
36
  const { isOwner } = useIsOwnerOfUnit(unit?.user_id);
30
37
  const permissions = useBackendPermission();
38
+ const [searchText, setSearchText] = useState('');
31
39
 
32
40
  const { stateAlertSharingMenu, hideStateAlertSharingMenu, stateLeaveUnit } =
33
41
  useStateAlertAction();
@@ -71,45 +79,59 @@ const UnitMemberList = ({ route }) => {
71
79
  }, [hideStateAlertSharingMenu, isOwner, leaveUnit, unit.name]);
72
80
 
73
81
  useEffect(() => {
74
- if (isFocused) {
75
- onRefresh();
76
- }
82
+ isFocused && onRefresh();
77
83
  }, [isFocused, onRefresh]);
78
84
 
79
- const rightHeader = (
80
- <TouchableOpacity
81
- accessibilityLabel={AccessibilityLabel.MEMBER_LIST_RIGHT_HEADER_TOUCH}
82
- onPress={onPressRightHeader}
83
- style={styles.rightHeader}
84
- >
85
- {isOwner ? (
86
- <IconOutline name={'plus'} size={27} color={Colors.Black} />
87
- ) : (
88
- <MaterialIcons name={'more-vert'} size={27} color={Colors.Black} />
89
- )}
90
- </TouchableOpacity>
85
+ const matchedMembers = useMemo(() => {
86
+ return dataMembers.filter((member) => {
87
+ const text = convertToSlug(searchText);
88
+ const isPhoneMatch = convertToSlug(member.phone_number ?? '').includes(
89
+ text
90
+ );
91
+ const isNameMatch = convertToSlug(member.name ?? '').includes(text);
92
+ return isPhoneMatch || isNameMatch;
93
+ });
94
+ }, [dataMembers, searchText]);
95
+ const rightComponent = useMemo(
96
+ () => (
97
+ <TouchableOpacity
98
+ accessibilityLabel={AccessibilityLabel.MEMBER_LIST_RIGHT_HEADER_TOUCH}
99
+ onPress={onPressRightHeader}
100
+ >
101
+ {isOwner ? (
102
+ <IconOutline name={'plus'} size={27} color={Colors.Black} />
103
+ ) : (
104
+ <MaterialIcons name={'more-vert'} size={27} color={Colors.Black} />
105
+ )}
106
+ </TouchableOpacity>
107
+ ),
108
+ [isOwner, onPressRightHeader]
91
109
  );
92
110
 
93
111
  return (
94
112
  <View style={styles.container}>
95
- <WrapHeaderScrollable
113
+ <HeaderCustom
96
114
  title={t('unit_member')}
97
- rightComponent={rightHeader}
98
- loading={isRefresh}
99
- onRefresh={onRefresh}
100
- headerAniStyle={styles.headerAniStyle}
101
- styleScrollView={{ backgroundColor: Colors.White }}
102
- >
115
+ isShowSeparator
116
+ rightComponent={rightComponent}
117
+ titleStyles={styles.headerTitle}
118
+ />
119
+ <View style={styles.content}>
103
120
  {!loading && (
104
- <MemberList
105
- accessibilityLabel={AccessibilityLabel.SHARING_MEMBER}
106
- dataMember={dataMembers}
107
- unit={unit}
108
- ownerId={unit.user_id}
109
- currentUserId={account.user.id}
110
- />
121
+ <Fragment>
122
+ <Search onSearch={setSearchText} />
123
+ <MemberList
124
+ accessibilityLabel={AccessibilityLabel.SHARING_MEMBER}
125
+ dataMember={matchedMembers}
126
+ unit={unit}
127
+ ownerId={unit.user_id}
128
+ currentUserId={account.user.id}
129
+ isRefresh={isRefresh}
130
+ onRefresh={onRefresh}
131
+ />
132
+ </Fragment>
111
133
  )}
112
- </WrapHeaderScrollable>
134
+ </View>
113
135
  <AlertAction
114
136
  visible={stateAlertSharingMenu.visible}
115
137
  hideModal={hideStateAlertSharingMenu}
@@ -130,18 +152,19 @@ export default UnitMemberList;
130
152
  const styles = StyleSheet.create({
131
153
  container: {
132
154
  flex: 1,
133
- backgroundColor: Colors.Gray2,
155
+ backgroundColor: Colors.White,
134
156
  },
135
- rightHeader: {
136
- alignItems: 'center',
137
- width: 44,
138
- justifyContent: 'center',
157
+ content: {
139
158
  flex: 1,
140
- },
141
- headerAniStyle: {
142
- borderBottomWidth: 0,
159
+ marginHorizontal: 16,
143
160
  },
144
161
  rightButtonStyle: {
145
162
  color: Colors.Red,
146
163
  },
164
+ headerTitle: {
165
+ alignSelf: 'flex-start',
166
+ marginLeft: 0,
167
+ fontSize: 20,
168
+ lineHeight: 28,
169
+ },
147
170
  });
@@ -1,25 +1,23 @@
1
- import React from 'react';
2
- import { create, act } from 'react-test-renderer';
1
+ import { act, create } from 'react-test-renderer';
3
2
 
4
- import UnitMemberList from '../UnitMemberList';
3
+ import { API } from '../../../configs';
4
+ import { AccessibilityLabel } from '../../../configs/Constants';
5
5
  import { AlertAction } from '../../../commons';
6
+ import MemberList from '../../../commons/Sharing/MemberList';
7
+ import MockAdapter from 'axios-mock-adapter';
8
+ import React from 'react';
9
+ import Routes from '../../../utils/Route';
6
10
  import { SCProvider } from '../../../context';
7
- import { mockSCStore } from '../../../context/mockStore';
11
+ import { Search } from '../../../commons/DevMode';
12
+ import { ToastBottomHelper } from '../../../utils/Utils';
8
13
  import { TouchableOpacity } from 'react-native';
9
- import Routes from '../../../utils/Route';
10
- import MockAdapter from 'axios-mock-adapter';
14
+ import UnitMemberList from '../UnitMemberList';
11
15
  import api from '../../../utils/Apis/axios';
12
- import { useNavigation } from '@react-navigation/native';
13
- import { ToastBottomHelper } from '../../../utils/Utils';
14
16
  import { getTranslate } from '../../../utils/I18n';
17
+ import { mockSCStore } from '../../../context/mockStore';
18
+ import { useNavigation } from '@react-navigation/native';
15
19
 
16
- new MockAdapter(api.axiosInstance);
17
-
18
- jest.mock('../../../hooks/Common', () => {
19
- return {
20
- useIsOwnerOfUnit: () => ({ isOwner: true }),
21
- };
22
- });
20
+ const mockAxios = new MockAdapter(api.axiosInstance);
23
21
 
24
22
  const wrapComponent = (route, state = {}) => (
25
23
  <SCProvider initState={mockSCStore(state)}>
@@ -29,21 +27,17 @@ const wrapComponent = (route, state = {}) => (
29
27
 
30
28
  describe('test MemberList', () => {
31
29
  let route;
32
- let localState = {
33
- auth: {
34
- account: {
35
- user: {
36
- id: 2,
37
- },
38
- },
39
- },
40
- };
41
-
42
- const mockedNavigate = useNavigation().navigate;
30
+ let localState;
43
31
 
32
+ const mockNavigate = useNavigation().navigate;
33
+ const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
34
+ const spyToastSuccess = jest.spyOn(ToastBottomHelper, 'success');
44
35
  beforeEach(() => {
45
- mockedNavigate.mockClear();
46
-
36
+ mockNavigate.mockClear();
37
+ mockAxios.reset();
38
+ spyToastError.mockClear();
39
+ spyToastSuccess.mockClear();
40
+ jest.clearAllMocks();
47
41
  route = {
48
42
  params: {
49
43
  unitId: 1,
@@ -54,6 +48,16 @@ describe('test MemberList', () => {
54
48
  },
55
49
  },
56
50
  };
51
+
52
+ localState = {
53
+ auth: {
54
+ account: {
55
+ user: {
56
+ id: 2,
57
+ },
58
+ },
59
+ },
60
+ };
57
61
  });
58
62
 
59
63
  it('AlertAction rightButtonClick', async () => {
@@ -70,7 +74,7 @@ describe('test MemberList', () => {
70
74
  await act(async () => {
71
75
  await memberListButtons[1].props.onPress();
72
76
  });
73
- expect(global.mockedNavigate).toBeCalledWith(Routes.AddMemberStack, {
77
+ expect(mockNavigate).toHaveBeenCalledWith(Routes.AddMemberStack, {
74
78
  screen: Routes.SelectShareDevice,
75
79
  params: { unit: { id: 1 } },
76
80
  });
@@ -84,6 +88,7 @@ describe('test MemberList', () => {
84
88
  auth: {
85
89
  account: {
86
90
  user: {
91
+ id: 2,
87
92
  permissions: {
88
93
  max_members_per_unit: 0,
89
94
  },
@@ -94,16 +99,108 @@ describe('test MemberList', () => {
94
99
  );
95
100
  });
96
101
  const instance = tree.root;
97
- const spyToastError = jest.spyOn(ToastBottomHelper, 'error');
98
102
  const memberListButtons = instance.findAllByType(TouchableOpacity);
99
103
  await act(async () => {
100
104
  await memberListButtons[1].props.onPress();
101
105
  });
102
- expect(global.mockedNavigate).not.toBeCalled();
103
- expect(spyToastError).toBeCalledWith(
106
+ expect(mockNavigate).not.toHaveBeenCalled();
107
+ expect(spyToastError).toHaveBeenCalledWith(
104
108
  getTranslate('en', 'reach_max_members_per_unit', { length: 0 }),
105
109
  '',
106
110
  7000
107
111
  );
108
112
  });
113
+
114
+ it('test member leaves unit', async () => {
115
+ mockAxios.onDelete(API.SHARE.UNITS_MEMBER_DETAIL(1, 'me')).reply(200);
116
+
117
+ localState = {
118
+ auth: {
119
+ account: {
120
+ user: {
121
+ id: 5,
122
+ },
123
+ },
124
+ },
125
+ };
126
+
127
+ let tree;
128
+ await act(async () => {
129
+ tree = await create(wrapComponent(route, localState));
130
+ });
131
+ const instance = tree.root;
132
+
133
+ const alertAction = instance.findByType(AlertAction);
134
+ await act(async () => {
135
+ alertAction.props.rightButtonClick();
136
+ });
137
+
138
+ const rightHeaderButton = instance.find(
139
+ (el) =>
140
+ el.type === TouchableOpacity &&
141
+ el.props.accessibilityLabel ===
142
+ AccessibilityLabel.MEMBER_LIST_RIGHT_HEADER_TOUCH
143
+ );
144
+ await act(async () => {
145
+ await rightHeaderButton.props.onPress();
146
+ });
147
+ expect(mockNavigate).toHaveBeenCalledWith(Routes.Dashboard);
148
+ expect(spyToastSuccess).toHaveBeenCalledTimes(1);
149
+ });
150
+
151
+ it('test search member by name and phone', async () => {
152
+ const dataMember = [
153
+ {
154
+ id: 1,
155
+ name: 'user 1',
156
+ avatar: 'https://image1.jpg',
157
+ phone_number: '0933123456',
158
+ },
159
+ {
160
+ id: 2,
161
+ name: 'user 2',
162
+ avatar: 'https://image1.jpg',
163
+ phone_number: '0933777111',
164
+ },
165
+ {
166
+ id: 3,
167
+ name: null,
168
+ avatar: 'https://image1.jpg',
169
+ phone_number: null,
170
+ },
171
+ ];
172
+
173
+ mockAxios.onGet(API.SHARE.UNITS_MEMBERS(1)).reply(200, dataMember);
174
+
175
+ let tree;
176
+ await act(async () => {
177
+ tree = await create(wrapComponent(route, localState));
178
+ });
179
+ const instance = tree.root;
180
+
181
+ const search = instance.findByType(Search);
182
+ const memberList = instance.findByType(MemberList);
183
+ await act(async () => {
184
+ search.props.onSearch('user 1');
185
+ });
186
+
187
+ expect(memberList.props.dataMember).toEqual([dataMember[0]]);
188
+
189
+ await act(async () => {
190
+ search.props.onSearch('3777');
191
+ });
192
+
193
+ expect(memberList.props.dataMember).toEqual([dataMember[1]]);
194
+
195
+ await act(async () => {
196
+ search.props.onSearch('');
197
+ });
198
+
199
+ //move owner to top
200
+ expect(memberList.props.dataMember).toEqual([
201
+ dataMember[1],
202
+ dataMember[0],
203
+ dataMember[2],
204
+ ]);
205
+ });
109
206
  });
@@ -1,12 +1,13 @@
1
- import React from 'react';
2
1
  import { act, renderHook } from '@testing-library/react-hooks';
3
- import MockAdapter from 'axios-mock-adapter';
4
- import { useDataMember } from '..';
2
+
5
3
  import API from '../../../../configs/API';
6
- import api from '../../../../utils/Apis/axios';
4
+ import MockAdapter from 'axios-mock-adapter';
5
+ import React from 'react';
6
+ import Routes from '../../../../utils/Route';
7
7
  import { SCProvider } from '../../../../context';
8
+ import api from '../../../../utils/Apis/axios';
8
9
  import { mockSCStore } from '../../../../context/mockStore';
9
- import Routes from '../../../../utils/Route';
10
+ import { useDataMember } from '..';
10
11
 
11
12
  const mock = new MockAdapter(api.axiosInstance);
12
13
 
@@ -1,12 +1,13 @@
1
+ import { axiosDelete, axiosGet } from '../../../utils/Apis/axios';
1
2
  import { useCallback, useState } from 'react';
2
- import { useTranslations } from '../../../hooks/Common/useTranslations';
3
- import { useNavigation } from '@react-navigation/native';
3
+
4
4
  import { API } from '../../../configs';
5
5
  import Routes from '../../../utils/Route';
6
- import { axiosDelete, axiosGet } from '../../../utils/Apis/axios';
7
6
  import { ToastBottomHelper } from '../../../utils/Utils';
8
- import { useSCContextSelector } from '../../../context';
9
7
  import { useIsOwnerOfUnit } from '../../../hooks/Common';
8
+ import { useNavigation } from '@react-navigation/native';
9
+ import { useSCContextSelector } from '../../../context';
10
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
10
11
 
11
12
  const useDataMember = (unitId, userUnitId = undefined) => {
12
13
  const t = useTranslations();
@@ -1,18 +1,19 @@
1
+ import { Image, TouchableOpacity, View } from 'react-native';
1
2
  import React, { useEffect } from 'react';
2
- import { View, TouchableOpacity, Image } from 'react-native';
3
3
  import { useIsFocused, useNavigation } from '@react-navigation/native';
4
+
5
+ import { AccessibilityLabel } from '../../configs/Constants';
4
6
  import { Colors } from '../../configs';
5
- import { useTranslations } from '../../hooks/Common/useTranslations';
6
- import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
7
- import Text from '../../commons/Text';
8
- import styles from './ManageSubUnitStyles';
9
7
  import { IconOutline } from '@ant-design/icons-react-native';
10
8
  import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
11
- import Routes from '../../utils/Route';
12
9
  import NoSubUnitImage from '../../../assets/images/Illustrations.svg';
13
- import useManageSubUnit from './hooks/useManageSubUnit';
14
- import { AccessibilityLabel } from '../../configs/Constants';
10
+ import Routes from '../../utils/Route';
15
11
  import { RowItem } from '../../commons/RowItem';
12
+ import Text from '../../commons/Text';
13
+ import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
14
+ import styles from './ManageSubUnitStyles';
15
+ import useManageSubUnit from './hooks/useManageSubUnit';
16
+ import { useTranslations } from '../../hooks/Common/useTranslations';
16
17
 
17
18
  const RightComponent = ({ onAddSubUnit, onRearrangeSubUnit }) => (
18
19
  <View style={styles.rightComponent}>
@@ -50,7 +51,9 @@ const StationList = ({ stations, onEditSubUnit }) => {
50
51
  />
51
52
  }
52
53
  text={item.name}
53
- subtext={`${item.devices?.length} ${t('devices').toLowerCase()}`}
54
+ subtext={`${item.devices?.length || 0} ${t(
55
+ 'devices'
56
+ ).toLowerCase()}`}
54
57
  onPress={() => onEditSubUnit(item)}
55
58
  rightComponent={
56
59
  <IconOutline name="right" size={20} color={Colors.Gray6} />
@@ -1,15 +1,16 @@
1
1
  import React, { useState } from 'react';
2
- import { View, TouchableOpacity } from 'react-native';
3
- import { isEqual } from 'lodash';
2
+ import { TouchableOpacity, View } from 'react-native';
3
+
4
4
  import { API } from '../../configs';
5
- import { axiosPost } from '../../utils/Apis/axios';
6
- import styles from './RearrrageSubUnitStyle';
7
- import Text from '../../commons/Text';
8
5
  import FlatListDnD from '../../commons/FlatListDnD';
9
- import ViewButtonBottom from '../../commons/ViewButtonBottom';
10
6
  import { HeaderCustom } from '../../commons/Header';
11
7
  import Rearrange from '../../../assets/images/Rearrange.svg';
8
+ import Text from '../../commons/Text';
12
9
  import { ToastBottomHelper } from '../../utils/Utils';
10
+ import ViewButtonBottom from '../../commons/ViewButtonBottom';
11
+ import { axiosPost } from '../../utils/Apis/axios';
12
+ import { isEqual } from 'lodash';
13
+ import styles from './RearrrageSubUnitStyle';
13
14
  import { useNavigation } from '@react-navigation/native';
14
15
  import { useTranslations } from '../../hooks/Common/useTranslations';
15
16
 
@@ -55,7 +56,7 @@ const RearrangeSubUnit = ({ route }) => {
55
56
  >
56
57
  <Text style={styles.indexText}>{item.name}</Text>
57
58
  <Text style={styles.deviceText}>
58
- {`${item.devices.length} ${t('devices').toLowerCase()}`}
59
+ {`${item.devices?.length || 0} ${t('devices').toLowerCase()}`}
59
60
  </Text>
60
61
  </View>
61
62
  </View>