@eohjsc/react-native-smart-city 0.2.19 → 0.2.23

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 (242) hide show
  1. package/assets/images/Add.svg +5 -0
  2. package/assets/images/AddLocationMaps/Point.svg +3 -0
  3. package/assets/images/CheckCircle.svg +4 -0
  4. package/assets/images/Close.svg +3 -0
  5. package/assets/images/Event.svg +9 -0
  6. package/assets/images/HowToStart.svg +14 -0
  7. package/assets/images/OneTap.svg +14 -0
  8. package/assets/images/Rearrange.svg +3 -0
  9. package/assets/images/Schedule.svg +39 -0
  10. package/assets/images/WeatherChange.svg +49 -0
  11. package/index.js +2 -0
  12. package/package.json +7 -4
  13. package/src/Images/Common/ActiveButton.png +0 -0
  14. package/src/Images/Common/ActiveButton@2x.png +0 -0
  15. package/src/Images/Common/ActiveButton@3x.png +0 -0
  16. package/src/Images/Common/file@2x.png +0 -0
  17. package/src/Images/Common/file@3x.png +0 -0
  18. package/src/Images/Common/fullscreen@2x.png +0 -0
  19. package/src/Images/Common/fullscreen@3x.png +0 -0
  20. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +6 -3
  21. package/src/commons/ActionGroup/StatesGridActionTemplate.js +10 -1
  22. package/src/commons/ActionGroup/ThreeButtonTemplate.js +13 -6
  23. package/src/commons/ActionGroup/ThreeButtonTemplateStyle.js +1 -1
  24. package/src/commons/ActionGroup/TimerActionTemplate.js +158 -33
  25. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +2 -1
  26. package/src/commons/ActionGroup/hooks/useDropdownAction.js +2 -1
  27. package/src/commons/Automate/ItemAddNewScriptAction.js +30 -0
  28. package/src/commons/Automate/ItemAddNewScriptActionStyles.js +38 -0
  29. package/src/commons/Automate/ItemAutomate.js +63 -0
  30. package/src/commons/Automate/ItemAutomateStyles.js +30 -0
  31. package/src/commons/Automate/ItemScriptAction.js +41 -0
  32. package/src/commons/Automate/ItemScriptActionStyles.js +38 -0
  33. package/src/commons/BottomScrollPicker/index.js +58 -0
  34. package/src/commons/BottomScrollPicker/styles.js +13 -0
  35. package/src/commons/BottomSheet/index.js +36 -0
  36. package/src/commons/BottomSheet/styles.js +37 -0
  37. package/src/commons/Button/index.js +6 -1
  38. package/src/commons/CameraDevice/index.js +22 -10
  39. package/src/commons/ChartLoading/index.js +2 -1
  40. package/src/commons/DateTimeRangeChange/index.js +2 -1
  41. package/src/commons/Device/ConnectedViewHeader.js +3 -1
  42. package/src/commons/Device/DeviceAlertStatus.js +2 -1
  43. package/src/commons/Device/DisconnectedView.js +34 -26
  44. package/src/commons/Device/Emergency/EmergencyButton.js +2 -1
  45. package/src/commons/Device/Emergency/EmergencyDetail.js +2 -1
  46. package/src/commons/Device/FlatListItems.js +2 -1
  47. package/src/commons/Device/FooterInfo.js +2 -1
  48. package/src/commons/Device/HistoryChart.js +2 -1
  49. package/src/commons/Device/HorizontalBarChart.js +3 -3
  50. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +7 -2
  51. package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -1
  52. package/src/commons/Device/RainningSensor/CurrentRainSensor.js +3 -1
  53. package/src/commons/Device/SensorConnectedStatus.js +2 -1
  54. package/src/commons/Device/WindDirection/Compass/index.js +1 -1
  55. package/src/commons/Device/WindSpeed/LinearChart/index.js +2 -1
  56. package/src/commons/Device/__test__/DeviceAlertStatus.test.js +2 -1
  57. package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -1
  58. package/src/commons/EmergencyButton/AlertSent.js +3 -2
  59. package/src/commons/Explore/CityItem/index.js +2 -1
  60. package/src/commons/Explore/HeaderExplore/index.js +2 -1
  61. package/src/commons/Explore/HeaderLabel/index.js +2 -1
  62. package/src/commons/Explore/SearchBox/index.js +2 -1
  63. package/src/commons/Header/HeaderCustom.js +36 -10
  64. package/src/commons/Header/Styles/HeaderCustomStyles.js +8 -3
  65. package/src/commons/HeaderAni/index.js +6 -3
  66. package/src/commons/IconComponent/index.js +18 -3
  67. package/src/commons/ImagePicker/index.js +3 -1
  68. package/src/commons/MediaPlayer/index.js +118 -62
  69. package/src/commons/MediaPlayer/styles.js +56 -0
  70. package/src/commons/MediaPlayerDetail/MediaPlayerDetailStyles.js +15 -0
  71. package/src/commons/MediaPlayerDetail/index.js +149 -64
  72. package/src/commons/MenuActionAddnew/index.js +2 -1
  73. package/src/commons/Modal/ModalCustom.js +22 -0
  74. package/src/commons/Modal/ModalFullVideo.js +48 -0
  75. package/src/commons/Modal/Styles/ModalFullVideoStyles.js +26 -0
  76. package/src/commons/Modal/index.js +4 -0
  77. package/src/commons/NavBar/index.js +2 -2
  78. package/src/commons/Sharing/DevicePermissionsCheckbox.js +2 -1
  79. package/src/commons/Sharing/MemberList.js +3 -1
  80. package/src/commons/Sharing/RowMember.js +3 -2
  81. package/src/commons/Sharing/StationDevicePermissions.js +2 -1
  82. package/src/commons/SubUnit/OneTap/ItemOneTap.js +86 -0
  83. package/src/commons/SubUnit/OneTap/ItemOneTapStyles.js +41 -0
  84. package/src/commons/SubUnit/OneTap/OneTapStyles.js +36 -0
  85. package/src/commons/SubUnit/OneTap/index.js +29 -0
  86. package/src/commons/SubUnit/ShortDetail.js +3 -1
  87. package/src/commons/Today/index.js +2 -1
  88. package/src/commons/Unit/SharedUnit.js +2 -1
  89. package/src/commons/UnitSummary/AirQuality/SegmentedRoundDisplay/index.js +1 -2
  90. package/src/commons/UnitSummary/AirQuality/index.js +5 -120
  91. package/src/commons/UnitSummary/AirQuality/styles.js +112 -0
  92. package/src/commons/UnitSummary/TotalPowerConsumption/index.js +2 -1
  93. package/src/commons/WheelDateTimePicker/Picker.js +57 -0
  94. package/src/commons/WheelDateTimePicker/index.js +160 -0
  95. package/src/commons/WheelDateTimePicker/styles.js +21 -0
  96. package/src/configs/API.js +25 -3
  97. package/src/configs/Colors.js +1 -0
  98. package/src/configs/Constants.js +4 -0
  99. package/src/configs/Images.js +4 -0
  100. package/src/configs/SCConfig.js +94 -0
  101. package/src/context/SCContext.tsx +5 -11
  102. package/src/context/reducer.ts +2 -0
  103. package/src/hooks/Common/useStatusBar.js +3 -0
  104. package/src/hooks/Common/useTranslations.ts +34 -0
  105. package/src/iot/Monitor.js +2 -1
  106. package/src/iot/RemoteControl/Bluetooth.js +2 -6
  107. package/src/iot/RemoteControl/GoogleHome.js +1 -1
  108. package/src/iot/RemoteControl/Internet.js +1 -1
  109. package/src/iot/RemoteControl/LG.js +57 -15
  110. package/src/iot/RemoteControl/__test__/Bluetooth.test.js +2 -1
  111. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +2 -1
  112. package/src/iot/RemoteControl/__test__/Internet.test.js +2 -1
  113. package/src/iot/RemoteControl/__test__/index.test.js +2 -1
  114. package/src/iot/RemoteControl/index.js +1 -1
  115. package/src/iot/states.js +1 -0
  116. package/src/navigations/AddGatewayStack.js +5 -0
  117. package/src/navigations/AddNewActionStack.js +23 -0
  118. package/src/navigations/SharedStack.js +2 -1
  119. package/src/navigations/UnitStack.js +72 -1
  120. package/src/screens/AQIGuide/index.js +2 -2
  121. package/src/screens/ActivityLog/hooks/index.js +1 -1
  122. package/src/screens/ActivityLog/index.js +2 -1
  123. package/src/screens/AddCommon/SelectSubUnit.js +143 -0
  124. package/src/screens/AddCommon/SelectSubUnitStyles.js +55 -0
  125. package/src/screens/AddCommon/SelectUnit.js +3 -2
  126. package/src/screens/AddLocationMaps/index.js +2 -1
  127. package/src/screens/AddNewAction/Device/DeviceStyles.js +43 -0
  128. package/src/screens/AddNewAction/Device/index.js +33 -0
  129. package/src/screens/AddNewAction/SelectDevice.js +106 -0
  130. package/src/screens/AddNewAction/Styles/SelectDeviceStyles.js +36 -0
  131. package/src/screens/AddNewDevice/ConnectDevices.js +2 -1
  132. package/src/screens/AddNewDevice/ConnectingDevices.js +2 -1
  133. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +2 -1
  134. package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +2 -1
  135. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +2 -1
  136. package/src/screens/AddNewDevice/hooks/useStateAlertRename.js +2 -1
  137. package/src/screens/AddNewDevice/index.js +23 -4
  138. package/src/screens/AddNewGateway/AddNewGatewayStyles.js +29 -0
  139. package/src/screens/AddNewGateway/ConnectedGateway.js +2 -1
  140. package/src/screens/AddNewGateway/ConnectingGateway.js +100 -25
  141. package/src/screens/AddNewGateway/ConnectingGatewayStyles.js +92 -0
  142. package/src/screens/AddNewGateway/SetupGatewayWifi.js +25 -3
  143. package/src/screens/AddNewGateway/SetupGatewayWifiStyles.js +6 -1
  144. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +2 -1
  145. package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +2 -1
  146. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +2 -1
  147. package/src/screens/AddNewGateway/hooks/useStateAlertRename.js +2 -1
  148. package/src/screens/AddNewGateway/index.js +28 -110
  149. package/src/screens/AddNewOneTap/AddNewOneTapStyles.js +43 -0
  150. package/src/screens/AddNewOneTap/index.js +67 -0
  151. package/src/screens/AddNewScriptAction/AddNewScriptActionStyles.js +27 -0
  152. package/src/screens/AddNewScriptAction/index.js +92 -0
  153. package/src/screens/AllCamera/Styles/index.js +101 -0
  154. package/src/screens/AllCamera/index.js +208 -0
  155. package/src/screens/Device/HeaderDevice/styles.js +2 -2
  156. package/src/screens/Device/__test__/detail.test.js +2 -1
  157. package/src/screens/Device/detail.js +66 -23
  158. package/src/screens/Device/hooks/useEmergencyButton.js +7 -6
  159. package/src/screens/Device/styles.js +3 -0
  160. package/src/screens/DeviceInfo/index.js +3 -2
  161. package/src/screens/EditActionsList/Styles/indexStyles.js +73 -0
  162. package/src/screens/EditActionsList/index.js +122 -0
  163. package/src/screens/EmergencyContacts/EmergencyContactsAddNew.js +3 -2
  164. package/src/screens/EmergencyContacts/EmergencyContactsList.js +9 -2
  165. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +2 -1
  166. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +2 -1
  167. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +2 -1
  168. package/src/screens/EmergencyContacts/hook.js +3 -2
  169. package/src/screens/Explore/index.js +3 -2
  170. package/src/screens/GuestInfo/components/AccessScheduleItem.js +27 -0
  171. package/src/screens/GuestInfo/components/AccessScheduleSheet.js +193 -0
  172. package/src/screens/GuestInfo/components/HeaderGuestInfo.js +31 -0
  173. package/src/screens/GuestInfo/components/RecurringDetail.js +99 -0
  174. package/src/screens/GuestInfo/components/RowGuestInfo.js +31 -0
  175. package/src/screens/GuestInfo/components/TemporaryDetail.js +46 -0
  176. package/src/screens/GuestInfo/constant.js +59 -0
  177. package/src/screens/GuestInfo/index.js +151 -0
  178. package/src/screens/GuestInfo/styles/AccessScheduleDetailStyles.js +31 -0
  179. package/src/screens/GuestInfo/styles/AccessScheduleItemStyles.js +22 -0
  180. package/src/screens/GuestInfo/styles/HeaderGuestInfoStyles.js +31 -0
  181. package/src/screens/GuestInfo/styles/indexStyles.js +38 -0
  182. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +82 -0
  183. package/src/screens/ManageAccess/hooks/index.js +32 -0
  184. package/src/screens/ManageAccess/index.js +126 -0
  185. package/src/screens/ManageAccess/styles/ManageAccessStyles.js +72 -0
  186. package/src/screens/PlayBackCamera/Styles/TimerStyles.js +22 -0
  187. package/src/screens/PlayBackCamera/Styles/index.js +81 -0
  188. package/src/screens/PlayBackCamera/Timer.js +127 -0
  189. package/src/screens/PlayBackCamera/index.js +233 -0
  190. package/src/screens/ScanChipQR/components/QRScan/index.js +2 -1
  191. package/src/screens/ScanChipQR/hooks/index.js +4 -11
  192. package/src/screens/ScriptDetail/Styles/indexStyles.js +140 -0
  193. package/src/screens/ScriptDetail/index.js +241 -0
  194. package/src/screens/SharedUnit/TabHeader.js +2 -1
  195. package/src/screens/SharedUnit/index.js +3 -2
  196. package/src/screens/Sharing/MemberList.js +2 -1
  197. package/src/screens/Sharing/SelectPermission.js +2 -1
  198. package/src/screens/Sharing/SelectUser.js +3 -2
  199. package/src/screens/Sharing/__test__/MemberList.test.js +2 -1
  200. package/src/screens/Sharing/__test__/SelectUser.test.js +2 -1
  201. package/src/screens/Sharing/hooks/index.js +22 -17
  202. package/src/screens/SubUnit/AddSubUnit.js +14 -72
  203. package/src/screens/SubUnit/AddSubUnitStyles.js +66 -0
  204. package/src/screens/SubUnit/Detail.js +5 -63
  205. package/src/screens/SubUnit/DetailStyles.js +46 -0
  206. package/src/screens/SubUnit/ManageSubUnit.js +5 -4
  207. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +2 -1
  208. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +2 -1
  209. package/src/screens/SyncLGDevice/AddLGDevice.js +3 -2
  210. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +2 -1
  211. package/src/screens/TDSGuide/index.js +2 -1
  212. package/src/screens/UVIndexGuide/index.js +2 -1
  213. package/src/screens/Unit/AddMenu.js +3 -2
  214. package/src/screens/Unit/Detail.js +75 -20
  215. package/src/screens/Unit/ManageUnit/index.js +4 -3
  216. package/src/screens/Unit/ManageUnit.js +4 -3
  217. package/src/screens/Unit/MoreMenu.js +3 -2
  218. package/src/screens/Unit/SelectLocation.js +10 -2
  219. package/src/screens/Unit/SelectLocationStyles.js +11 -0
  220. package/src/screens/Unit/components/Header/index.js +2 -1
  221. package/src/screens/Unit/components/ListMyAllUnit/index.js +2 -1
  222. package/src/screens/Unit/components/MyUnit/index.js +2 -1
  223. package/src/screens/Unit/components/SearchLocation/index.js +2 -1
  224. package/src/screens/Unit/components/SharedUnit/index.js +2 -1
  225. package/src/screens/Unit/styles.js +4 -0
  226. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +2 -1
  227. package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -1
  228. package/src/screens/UnitSummary/components/Temperature/index.js +2 -1
  229. package/src/screens/UnitSummary/components/TotalPowerConsumption/index.js +2 -1
  230. package/src/screens/UnitSummary/components/UvIndex/index.js +2 -1
  231. package/src/screens/UnitSummary/components/WaterQuality/index.js +2 -1
  232. package/src/screens/UnitSummary/index.js +2 -1
  233. package/src/screens/WaterQualityGuide/index.js +2 -1
  234. package/src/utils/Converter/__test__/time.test.js +3 -1
  235. package/src/utils/Converter/array.js +4 -0
  236. package/src/utils/Converter/time.js +29 -4
  237. package/src/utils/I18n/index.ts +6 -0
  238. package/src/utils/I18n/translations/en.json +51 -2
  239. package/src/utils/I18n/translations/vi.json +48 -1
  240. package/src/utils/I18n/translations.ts +45 -0
  241. package/src/utils/Route/index.js +11 -0
  242. package/src/utils/I18n/index.js +0 -19
@@ -0,0 +1,241 @@
1
+ import React, {
2
+ useCallback,
3
+ useMemo,
4
+ useState,
5
+ useRef,
6
+ useEffect,
7
+ } from 'react';
8
+ import { View, TouchableOpacity, Image } from 'react-native';
9
+ import { IconFill, IconOutline } from '@ant-design/icons-react-native';
10
+ import { Icon } from '@ant-design/react-native';
11
+
12
+ import { useTranslations } from '../../hooks/Common/useTranslations';
13
+ import styles from './Styles/indexStyles';
14
+ import Text from '../../commons/Text';
15
+ import HowToStart from '../../../assets/images/HowToStart.svg';
16
+ import WrapHeaderScrollable from '../../commons/Sharing/WrapHeaderScrollable';
17
+ import { API, Colors, Images } from '../../configs';
18
+ import { usePopover } from '../../hooks/Common';
19
+ import MenuActionMore from '../../commons/MenuActionMore';
20
+ import Add from '../../../assets/images/Add.svg';
21
+ import { useNavigation, useRoute } from '@react-navigation/core';
22
+ import { axiosGet, axiosPost } from '../../utils/Apis/axios';
23
+ import FImage from '../../commons/FImage';
24
+ import Routes from '../../utils/Route';
25
+ import { ToastBottomHelper } from '../../utils/Utils';
26
+
27
+ const ScriptDetail = () => {
28
+ const { navigate } = useNavigation();
29
+ const { params = {} } = useRoute();
30
+ const refMenuAction = useRef();
31
+ const { childRef, showingPopover, showPopoverWithRef, hidePopover } =
32
+ usePopover();
33
+ const t = useTranslations();
34
+ const { id, name = '' } = params;
35
+ const [isFavourite, setIsFavourite] = useState(false);
36
+ const [data, setData] = useState([]);
37
+
38
+ const listMenuItem = [
39
+ { text: 'Rename' },
40
+ { text: 'Activity Log' },
41
+ { text: 'Delete Script' },
42
+ ];
43
+
44
+ const onPressFavourite = useCallback(() => {
45
+ setIsFavourite(!isFavourite);
46
+ }, [isFavourite]);
47
+
48
+ const handleShowMenuAction = useCallback(
49
+ () => showPopoverWithRef(refMenuAction),
50
+ // eslint-disable-next-line react-hooks/exhaustive-deps
51
+ []
52
+ );
53
+
54
+ const onItemClick = useCallback((item) => {
55
+ // eslint-disable-next-line no-alert
56
+ alert(t('feature_under_development'));
57
+ // eslint-disable-next-line react-hooks/exhaustive-deps
58
+ }, []);
59
+
60
+ const onPressAdd = useCallback(() => {
61
+ // eslint-disable-next-line no-alert
62
+ alert(t('feature_under_development'));
63
+ // eslint-disable-next-line react-hooks/exhaustive-deps
64
+ }, []);
65
+
66
+ const getOneTapDetail = useCallback(async () => {
67
+ const { success, data } = await axiosGet(API.AUTOMATE.ONE_TAP_DETAIL(id));
68
+ success && setData(data?.script_actions || []);
69
+ }, [id]);
70
+
71
+ const onPressEdit = useCallback(() => {
72
+ navigate(Routes.EditActionsList, { data, id, setData });
73
+ // eslint-disable-next-line react-hooks/exhaustive-deps
74
+ }, [data]);
75
+
76
+ const onPressAddAction = useCallback(() => {
77
+ navigate(Routes.SelectDevice, {
78
+ unitId: 5,
79
+ });
80
+ }, [navigate]);
81
+
82
+ const handleScriptAction = useCallback(async () => {
83
+ const { success } = await axiosPost(API.AUTOMATE.ACTION_ONE_TAP(id));
84
+ if (success) {
85
+ ToastBottomHelper.success(t('Activated successfully.'));
86
+ } else {
87
+ ToastBottomHelper.error(t('Activation failed.'));
88
+ }
89
+ // eslint-disable-next-line react-hooks/exhaustive-deps
90
+ }, [id]);
91
+
92
+ const Item = useCallback(({ item, index }) => {
93
+ return (
94
+ <View style={styles.wrapItem}>
95
+ <View style={styles.leftItem}>
96
+ <Text color={Colors.Gray9} type="H4" semibold>
97
+ {index + 1 < 10 ? '0' + (index + 1) : index + 1}
98
+ </Text>
99
+ </View>
100
+ <View style={styles.rightItem}>
101
+ <FImage
102
+ source={{ uri: item?.sensor_icon_kit }}
103
+ style={styles.iconItem}
104
+ />
105
+ <View style={styles.contentItem}>
106
+ <Text numberOfLines={1} type="Label" color={Colors.Gray7}>
107
+ {item?.station_name}
108
+ </Text>
109
+ <Text numberOfLines={1} type="H4" color={Colors.Gray9} semibold>
110
+ {item?.sensor_name}
111
+ </Text>
112
+ <Text numberOfLines={1} type="H4" color={Colors.Gray9}>
113
+ {item?.action_name}
114
+ </Text>
115
+ </View>
116
+ </View>
117
+ </View>
118
+ );
119
+ }, []);
120
+
121
+ const ItemAdd = useCallback(({ item, index }) => {
122
+ return (
123
+ <View style={styles.wrapItem}>
124
+ <View style={styles.leftItemAdd}>
125
+ <Text style={styles.number} type="H4" semibold color={Colors.Gray7}>
126
+ {index + 1 < 10 ? '0' + (index + 1) : index + 1}
127
+ </Text>
128
+ </View>
129
+ <TouchableOpacity
130
+ onPress={onPressAddAction}
131
+ style={[styles.rightItemAdd]}
132
+ >
133
+ <Add />
134
+ <Text type="H4" color={Colors.Gray8} style={styles.addAction}>
135
+ {t('add_action')}
136
+ </Text>
137
+ </TouchableOpacity>
138
+ </View>
139
+ );
140
+ // eslint-disable-next-line react-hooks/exhaustive-deps
141
+ }, []);
142
+
143
+ const renderButtonStar = useMemo(() => {
144
+ return (
145
+ <TouchableOpacity
146
+ style={[styles.buttonStar, styles.headerButton]}
147
+ onPress={onPressFavourite}
148
+ >
149
+ {isFavourite ? (
150
+ <IconFill name="star" size={25} color={Colors.Yellow6} />
151
+ ) : (
152
+ <IconOutline name="star" size={25} />
153
+ )}
154
+ </TouchableOpacity>
155
+ );
156
+ // eslint-disable-next-line react-hooks/exhaustive-deps
157
+ }, [isFavourite]);
158
+
159
+ const rightComponent = useMemo(
160
+ () => (
161
+ <View style={styles.rightComponent}>
162
+ {renderButtonStar}
163
+ <TouchableOpacity onPress={onPressAdd} style={styles.headerButton}>
164
+ <Icon name={'plus'} size={27} color={Colors.Black} />
165
+ </TouchableOpacity>
166
+ <TouchableOpacity
167
+ onPress={handleShowMenuAction}
168
+ ref={refMenuAction}
169
+ style={[styles.headerButton, styles.moreButton]}
170
+ >
171
+ <Icon name={'more'} size={27} color={Colors.Black} />
172
+ </TouchableOpacity>
173
+ </View>
174
+ ),
175
+ // eslint-disable-next-line react-hooks/exhaustive-deps
176
+ [isFavourite]
177
+ );
178
+
179
+ useEffect(() => {
180
+ getOneTapDetail();
181
+ // eslint-disable-next-line react-hooks/exhaustive-deps
182
+ }, [id]);
183
+
184
+ return (
185
+ <View style={styles.wrap}>
186
+ <WrapHeaderScrollable
187
+ title={name}
188
+ headerAniStyle={styles.headerAniStyle}
189
+ rightComponent={rightComponent}
190
+ >
191
+ <View style={styles.wrapContent}>
192
+ <Text type="H3" semibold>
193
+ {t('how_to_start')}
194
+ </Text>
195
+ <View style={styles.box}>
196
+ <HowToStart />
197
+ <View style={styles.wrapText}>
198
+ <Text type="H4" color={Colors.Gray9} semibold>
199
+ {t('launch_one_tap')}
200
+ </Text>
201
+ <Text type="Label" color={Colors.Gray8}>
202
+ {t('des_launch_one_tap')}
203
+ </Text>
204
+ </View>
205
+ </View>
206
+ <TouchableOpacity
207
+ onPress={handleScriptAction}
208
+ style={styles.activeButton}
209
+ >
210
+ <Image source={Images.activeButton} />
211
+ </TouchableOpacity>
212
+ <View style={styles.row}>
213
+ <Text type="H3" color={Colors.Gray9} semibold>
214
+ {t('active_list')}
215
+ </Text>
216
+ <TouchableOpacity onPress={onPressEdit} style={styles.editButton}>
217
+ <Text type="Label" hilight>
218
+ {t('edit')}
219
+ </Text>
220
+ </TouchableOpacity>
221
+ </View>
222
+ {data.map((item, index) => (
223
+ <Item key={item?.id} item={item} index={index} />
224
+ ))}
225
+ <ItemAdd index={data.length} />
226
+ </View>
227
+ </WrapHeaderScrollable>
228
+ <MenuActionMore
229
+ isVisible={showingPopover}
230
+ hideMore={hidePopover}
231
+ listMenuItem={listMenuItem}
232
+ childRef={childRef}
233
+ onItemClick={onItemClick}
234
+ isTextCenter={false}
235
+ wrapStyle={styles.wrapStyle}
236
+ />
237
+ </View>
238
+ );
239
+ };
240
+
241
+ export default ScriptDetail;
@@ -1,13 +1,14 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import { View, TouchableOpacity } from 'react-native';
3
3
  import { IconOutline } from '@ant-design/icons-react-native';
4
- import { t } from 'i18n-js';
4
+ import { useTranslations } from '../../hooks/Common/useTranslations';
5
5
 
6
6
  import Text from '../../commons/Text';
7
7
 
8
8
  import styles from './styles';
9
9
 
10
10
  const TabHeader = ({ current, getCurrentTab, showModal, textFilter }) => {
11
+ const t = useTranslations();
11
12
  const [currentTab, setCurrentTabState] = useState(current);
12
13
 
13
14
  useEffect(() => {
@@ -3,7 +3,7 @@ import { View, TouchableOpacity, FlatList, RefreshControl } from 'react-native';
3
3
  import { useNavigation } from '@react-navigation/native';
4
4
  import Modal from 'react-native-modal';
5
5
  import { axiosGet } from '../../utils/Apis/axios';
6
- import { t } from 'i18n-js';
6
+ import { useTranslations } from '../../hooks/Common/useTranslations';
7
7
 
8
8
  import { API } from '../../configs';
9
9
  import Text from '../../commons/Text';
@@ -21,6 +21,7 @@ import { useSCContextSelector } from '../../context';
21
21
  const Shared = () => {
22
22
  useBlockBackAndroid();
23
23
  useTitleHeader(t('text_shared_with_me'));
24
+ const t = useTranslations();
24
25
  const navigation = useNavigation();
25
26
  const [tab, setTabActiveState] = useState(0);
26
27
 
@@ -102,7 +103,7 @@ const Shared = () => {
102
103
  textFilter: t('text_can_edit'),
103
104
  },
104
105
  ],
105
- []
106
+ [t]
106
107
  );
107
108
 
108
109
  return (
@@ -7,7 +7,7 @@ import {
7
7
  View,
8
8
  ActivityIndicator,
9
9
  } from 'react-native';
10
- import { t } from 'i18n-js';
10
+ import { useTranslations } from '../../hooks/Common/useTranslations';
11
11
 
12
12
  import { Colors } from '../../configs';
13
13
  import Routes from '../../utils/Route';
@@ -21,6 +21,7 @@ import { TESTID } from '../../configs/Constants';
21
21
  import { useSCContextSelector } from '../../context';
22
22
 
23
23
  const MemberList = ({ route }) => {
24
+ const t = useTranslations();
24
25
  const { navigate } = useNavigation();
25
26
  const account = useSCContextSelector((state) => state.auth.account);
26
27
  const { unitId, unit } = route.params;
@@ -8,7 +8,7 @@ import {
8
8
  Platform,
9
9
  } from 'react-native';
10
10
  import { useNavigation } from '@react-navigation/native';
11
- import { t } from 'i18n-js';
11
+ import { useTranslations } from '../../hooks/Common/useTranslations';
12
12
 
13
13
  import { API, Colors } from '../../configs';
14
14
  import ViewButtonBottom from '../../commons/ViewButtonBottom';
@@ -23,6 +23,7 @@ import { TESTID } from '../../configs/Constants';
23
23
  let dataStationTemp = [];
24
24
 
25
25
  const SelectPermission = ({ route }) => {
26
+ const t = useTranslations();
26
27
  const { unit } = route.params;
27
28
  const navigation = useNavigation();
28
29
  const [dataStations, setDataStations] = useState([]);
@@ -7,7 +7,7 @@ import {
7
7
  SafeAreaView,
8
8
  } from 'react-native';
9
9
  import { useNavigation } from '@react-navigation/native';
10
- import { t } from 'i18n-js';
10
+ import { useTranslations } from '../../hooks/Common/useTranslations';
11
11
 
12
12
  import { API, Colors, Theme } from '../../configs';
13
13
  import AccountList from '../../commons/Auth/AccountList';
@@ -22,6 +22,7 @@ import { TESTID } from '../../configs/Constants';
22
22
  import Text from '../../commons/Text';
23
23
 
24
24
  const SelectUser = ({ route }) => {
25
+ const t = useTranslations();
25
26
  const navigation = useNavigation();
26
27
  const { unit, permissions } = route.params;
27
28
  const [errorText, setErrorText] = useState('');
@@ -64,7 +65,7 @@ const SelectUser = ({ route }) => {
64
65
  }
65
66
  setErrorText('');
66
67
  sharePermissions(phone, email);
67
- }, [content, sharePermissions]);
68
+ }, [content, sharePermissions, t]);
68
69
 
69
70
  const onPressNext = useCallback(() => {
70
71
  navigation.dangerouslyGetParent().goBack();
@@ -8,7 +8,7 @@ import MemberList from '../MemberList';
8
8
  import { AlertAction } from '../../../commons';
9
9
  import SharingMembers from '../../../commons/Sharing/MemberList';
10
10
  import API from '../../../configs/API';
11
- import { t } from 'i18n-js';
11
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
12
12
  import { TESTID } from '../../../configs/Constants';
13
13
  import { TouchableOpacity } from 'react-native';
14
14
  import Routes from '../../../utils/Route';
@@ -42,6 +42,7 @@ jest.mock('react-redux', () => {
42
42
  });
43
43
 
44
44
  describe('test MemberList', () => {
45
+ const t = useTranslations();
45
46
  let route;
46
47
  let account;
47
48
 
@@ -3,7 +3,7 @@ import { create, act } from 'react-test-renderer';
3
3
  import axios from 'axios';
4
4
 
5
5
  import SelectUser from '../SelectUser';
6
- import { t } from 'i18n-js';
6
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
7
7
  import { TESTID } from '../../../configs/Constants';
8
8
  import { ViewButtonBottom, Button } from '../../../commons';
9
9
  import _TextInput from '../../../commons/Form/TextInput';
@@ -40,6 +40,7 @@ jest.mock('@react-navigation/native', () => {
40
40
  });
41
41
 
42
42
  describe('test SelectUser container', () => {
43
+ const t = useTranslations();
43
44
  let tree;
44
45
  let route;
45
46
 
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useState } from 'react';
2
2
  import { useNavigation } from '@react-navigation/native';
3
- import { t } from 'i18n-js';
3
+ import { useTranslations } from '../../../hooks/Common/useTranslations';
4
4
 
5
5
  import { API } from '../../../configs';
6
6
  import Routes from '../../../utils/Route';
@@ -8,6 +8,7 @@ import { axiosDelete, axiosGet } from '../../../utils/Apis/axios';
8
8
  import { ToastBottomHelper } from '../../../utils/Utils';
9
9
 
10
10
  const useDataMember = (unitId) => {
11
+ const t = useTranslations();
11
12
  const { navigate, addListener } = useNavigation();
12
13
  const [dataMembers, setDataMembers] = useState([]);
13
14
  const [loading, setLoading] = useState(false);
@@ -30,7 +31,7 @@ const useDataMember = (unitId) => {
30
31
  );
31
32
  setDataMembers(dataMembers.filter((item) => item.share_id !== id));
32
33
  },
33
- [dataMembers, unitId]
34
+ [dataMembers, t, unitId]
34
35
  );
35
36
  const leaveUnit = useCallback(
36
37
  (unitName) => async () => {
@@ -39,7 +40,7 @@ const useDataMember = (unitId) => {
39
40
  setDataMembers([]);
40
41
  navigate(Routes.Dashboard);
41
42
  },
42
- [navigate, unitId]
43
+ [navigate, t, unitId]
43
44
  );
44
45
 
45
46
  const onRefresh = useCallback(async () => {
@@ -74,6 +75,7 @@ const useDataMember = (unitId) => {
74
75
  };
75
76
 
76
77
  const useStateAlertAction = () => {
78
+ const t = useTranslations();
77
79
  const [stateAlertAction, setStateAlertAction] = useState({
78
80
  visible: false,
79
81
  title: '',
@@ -85,19 +87,22 @@ const useStateAlertAction = () => {
85
87
  const hideAlertAction = useCallback(() => {
86
88
  setStateAlertAction({ ...stateAlertAction, visible: false });
87
89
  }, [stateAlertAction]);
88
- const onPressRemoveUser = useCallback((member) => {
89
- setStateAlertAction((action) => {
90
- let name = member.name || 'N/A';
91
- return {
92
- ...action,
93
- visible: true,
94
- title: t('sharing_remove_user', { name: name }),
95
- message: t('sharing_remove_user_message', { name: name }),
96
- rightButton: t('remove'),
97
- member: member,
98
- };
99
- });
100
- }, []);
90
+ const onPressRemoveUser = useCallback(
91
+ (member) => {
92
+ setStateAlertAction((action) => {
93
+ let name = member.name || 'N/A';
94
+ return {
95
+ ...action,
96
+ visible: true,
97
+ title: t('sharing_remove_user', { name: name }),
98
+ message: t('sharing_remove_user_message', { name: name }),
99
+ rightButton: t('remove'),
100
+ member: member,
101
+ };
102
+ });
103
+ },
104
+ [t]
105
+ );
101
106
  const stateLeaveUnit = useCallback(() => {
102
107
  setStateAlertAction((action) => {
103
108
  return {
@@ -109,7 +114,7 @@ const useStateAlertAction = () => {
109
114
  member: null,
110
115
  };
111
116
  });
112
- }, []);
117
+ }, [t]);
113
118
 
114
119
  return {
115
120
  stateAlertAction,
@@ -2,15 +2,14 @@ import React, { useState, useCallback, useMemo, useEffect } from 'react';
2
2
  import {
3
3
  View,
4
4
  Image,
5
- StyleSheet,
6
5
  Keyboard,
7
6
  TouchableWithoutFeedback,
8
7
  SafeAreaView,
9
8
  } from 'react-native';
10
9
  import { useNavigation } from '@react-navigation/native';
11
- import { t } from 'i18n-js';
10
+ import { useTranslations } from '../../hooks/Common/useTranslations';
12
11
 
13
- import { API, Colors, Theme } from '../../configs';
12
+ import { API, Colors } from '../../configs';
14
13
  import { ViewButtonBottom, ImagePicker } from '../../commons';
15
14
  import Text from '../../commons/Text';
16
15
  import _TextInput from '../../commons/Form/TextInput';
@@ -18,10 +17,12 @@ import Routes from '../../utils/Route';
18
17
  import { axiosPost, createFormData } from '../../utils/Apis/axios';
19
18
  import { ToastBottomHelper } from '../../utils/Utils';
20
19
  import { TESTID } from '../../configs/Constants';
20
+ import styles from './AddSubUnitStyles';
21
21
 
22
22
  const AddSubUnit = ({ route }) => {
23
+ const t = useTranslations();
23
24
  const navigation = useNavigation();
24
- const { unit } = route.params;
25
+ const { unit, addType } = route.params;
25
26
  const [roomName, setRoomName] = useState('');
26
27
  const [wallpaper, setWallpaper] = useState('');
27
28
  const [imageUrl, setImageUrl] = useState('');
@@ -38,8 +39,14 @@ const AddSubUnit = ({ route }) => {
38
39
  }
39
40
  );
40
41
  if (success) {
41
- //TODO remove redux
42
- //dispatch(createSubUnit(data));
42
+ ToastBottomHelper.success(t('text_create_sub_unit_success'));
43
+
44
+ if (addType === 'AddNewGateway') {
45
+ navigation.navigate(Routes.AddCommonSelectSubUnit, {
46
+ ...route.params,
47
+ });
48
+ return;
49
+ }
43
50
  navigation.navigate(Routes.UnitStack, {
44
51
  screen: Routes.SubUnitDetail,
45
52
  params: {
@@ -47,11 +54,10 @@ const AddSubUnit = ({ route }) => {
47
54
  station: data,
48
55
  },
49
56
  });
50
- ToastBottomHelper.success(t('text_create_sub_unit_success'));
51
57
  } else {
52
58
  ToastBottomHelper.error(t('text_create_sub_unit_fail'));
53
59
  }
54
- }, [navigation, roomName, unit, wallpaper]);
60
+ }, [addType, navigation, roomName, route.params, t, unit, wallpaper]);
55
61
 
56
62
  const onChoosePhoto = useCallback(() => {
57
63
  setShowImagePicker(true);
@@ -132,68 +138,4 @@ const AddSubUnit = ({ route }) => {
132
138
  );
133
139
  };
134
140
 
135
- const styles = StyleSheet.create({
136
- commonWrap: {
137
- flex: 1,
138
- },
139
- wrap: {
140
- flex: 1,
141
- backgroundColor: Colors.Gray2,
142
- },
143
- padding: {
144
- paddingHorizontal: 16,
145
- },
146
- title: {
147
- fontSize: 20,
148
- marginTop: 20,
149
- lineHeight: 28,
150
- marginBottom: 16,
151
- },
152
- textInput: {
153
- marginTop: 0,
154
- },
155
- formWrapper: {
156
- ...Theme.whiteBoxRadius,
157
- paddingTop: 0,
158
- paddingBottom: 24,
159
- },
160
- roomName: {
161
- borderWidth: 0,
162
- borderBottomWidth: 1,
163
- borderBottomColor: Colors.Primary,
164
- paddingLeft: 0,
165
- fontSize: 16,
166
- lineHeight: 24,
167
- margin: 0,
168
- padding: 0,
169
- },
170
- wrapWallpaper: {
171
- marginTop: 6,
172
- borderBottomWidth: 1,
173
- borderColor: Colors.Gray4,
174
- flexDirection: 'row',
175
- justifyContent: 'space-between',
176
- alignItems: 'center',
177
- },
178
- addWallpaper: {
179
- fontSize: 16,
180
- lineHeight: 24,
181
- paddingBottom: 14,
182
- paddingTop: 14,
183
- },
184
- wallpaper: {
185
- width: 32,
186
- height: 32,
187
- borderRadius: 16,
188
- marginRight: 8,
189
- },
190
- wallpaperEmpty: {
191
- width: 32,
192
- height: 32,
193
- borderRadius: 16,
194
- marginRight: 8,
195
- backgroundColor: Colors.Pink1,
196
- },
197
- });
198
-
199
141
  export default AddSubUnit;
@@ -0,0 +1,66 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { Colors, Theme } from '../../configs';
3
+
4
+ export default StyleSheet.create({
5
+ commonWrap: {
6
+ flex: 1,
7
+ },
8
+ wrap: {
9
+ flex: 1,
10
+ backgroundColor: Colors.Gray2,
11
+ },
12
+ padding: {
13
+ paddingHorizontal: 16,
14
+ },
15
+ title: {
16
+ fontSize: 20,
17
+ marginTop: 20,
18
+ lineHeight: 28,
19
+ marginBottom: 16,
20
+ },
21
+ textInput: {
22
+ marginTop: 0,
23
+ },
24
+ formWrapper: {
25
+ ...Theme.whiteBoxRadius,
26
+ paddingTop: 0,
27
+ paddingBottom: 24,
28
+ },
29
+ roomName: {
30
+ borderWidth: 0,
31
+ borderBottomWidth: 1,
32
+ borderBottomColor: Colors.Primary,
33
+ paddingLeft: 0,
34
+ fontSize: 16,
35
+ lineHeight: 24,
36
+ margin: 0,
37
+ padding: 0,
38
+ },
39
+ wrapWallpaper: {
40
+ marginTop: 6,
41
+ borderBottomWidth: 1,
42
+ borderColor: Colors.Gray4,
43
+ flexDirection: 'row',
44
+ justifyContent: 'space-between',
45
+ alignItems: 'center',
46
+ },
47
+ addWallpaper: {
48
+ fontSize: 16,
49
+ lineHeight: 24,
50
+ paddingBottom: 14,
51
+ paddingTop: 14,
52
+ },
53
+ wallpaper: {
54
+ width: 32,
55
+ height: 32,
56
+ borderRadius: 16,
57
+ marginRight: 8,
58
+ },
59
+ wallpaperEmpty: {
60
+ width: 32,
61
+ height: 32,
62
+ borderRadius: 16,
63
+ marginRight: 8,
64
+ backgroundColor: Colors.Pink1,
65
+ },
66
+ });