@eohjsc/react-native-smart-city 0.2.53 → 0.2.57
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/assets/images/SonosSpeaker/buttonpause-active.svg +3 -0
- package/assets/images/SonosSpeaker/buttonpause-notactive.svg +3 -0
- package/assets/images/SonosSpeaker/picture-main-notactive.svg +5 -0
- package/assets/images/SonosSpeaker/picture-main.svg +6 -0
- package/assets/images/SonosSpeaker/picture-volume.svg +3 -0
- package/package.json +2 -1
- package/src/commons/AlertAction/index.js +3 -3
- package/src/commons/DateTimeRangeChange/index.js +2 -2
- package/src/commons/Device/HistoryChart.js +9 -39
- package/src/commons/Device/HorizontalBarChart.js +1 -1
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +1 -1
- package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +2 -1
- package/src/commons/Device/SonosSpeaker/__test__/SonosSpeaker.test.js +57 -0
- package/src/commons/Device/SonosSpeaker/index.js +88 -0
- package/src/commons/Device/SonosSpeaker/styles.js +57 -0
- package/src/commons/Form/CurrencyInput.js +163 -0
- package/src/commons/Form/__test__/CurrencyInput.test.js +65 -0
- package/src/commons/Sharing/RowMember.js +3 -0
- package/src/commons/ThreeButtonHistory/__test__/ThreeButtonHistory.test.js +17 -8
- package/src/commons/ThreeButtonHistory/index.js +52 -23
- package/src/configs/Constants.js +2 -2
- package/src/screens/ActivityLog/ItemLog.js +9 -0
- package/src/screens/ActivityLog/__test__/ItemLog.test.js +43 -0
- package/src/screens/AddCommon/SelectSubUnit.js +1 -1
- package/src/screens/SubUnit/AddSubUnit.js +78 -59
- package/src/screens/Unit/Detail.js +7 -1
- package/src/screens/Unit/ManageUnit.js +3 -4
- package/src/screens/Unit/SmartAccount.js +2 -3
- package/src/screens/Unit/SmartAccountItem.js +1 -1
- package/src/screens/Unit/SmartAccountStyles.js +1 -1
- package/src/screens/Unit/Summaries.js +5 -1
- package/src/screens/Unit/hook/useStateAlertRemove.js +3 -1
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +1 -1
- package/src/screens/UnitSummary/components/PowerConsumption/index.js +1 -1
- package/src/screens/UnitSummary/components/UvIndex/index.js +10 -2
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +1 -3
- package/src/screens/UnitSummary/index.js +3 -2
- package/src/utils/I18n/translations/en.json +6 -2
- package/src/utils/I18n/translations/vi.json +7 -3
|
@@ -214,18 +214,27 @@ describe('test ThreeButtonHistory', () => {
|
|
|
214
214
|
await calendar.props.onDayPress({ dateString: date });
|
|
215
215
|
});
|
|
216
216
|
};
|
|
217
|
-
|
|
218
|
-
await selectDate('2021-09-
|
|
219
|
-
await selectDate('2021-09-
|
|
220
|
-
await selectDate('2021-09-
|
|
221
|
-
await selectDate('2021-09-05');
|
|
222
|
-
await selectDate('2021-09-
|
|
223
|
-
await selectDate('2021-09-
|
|
217
|
+
// 2 -> 9
|
|
218
|
+
await selectDate('2021-09-20'); // 2 -> 20
|
|
219
|
+
await selectDate('2021-09-01'); // 1 -> 20
|
|
220
|
+
await selectDate('2021-09-15'); // 1 -> 15
|
|
221
|
+
await selectDate('2021-09-05'); // 5 -> 15
|
|
222
|
+
await selectDate('2021-09-15'); // 5 -> null
|
|
223
|
+
await selectDate('2021-09-05'); // null -> null
|
|
224
|
+
await selectDate('2021-09-10'); // 10 -> null
|
|
225
|
+
await selectDate('2021-09-05'); // 5 -> 10
|
|
226
|
+
await selectDate('2021-09-10'); // 5 -> null
|
|
227
|
+
await selectDate('2021-09-20'); // 5 -> 20
|
|
228
|
+
await selectDate('2021-09-05'); // null -> 20
|
|
229
|
+
await selectDate('2021-09-25'); // 20 -> 25
|
|
230
|
+
await selectDate('2021-09-20'); // null -> 25
|
|
231
|
+
await selectDate('2021-09-10'); // 10 -> 25
|
|
232
|
+
|
|
224
233
|
const viewButtonBottom = instance.findByType(ViewButtonBottom);
|
|
225
234
|
await act(async () => {
|
|
226
235
|
await viewButtonBottom.props.onRightClick();
|
|
227
236
|
});
|
|
228
237
|
expect(mockSetStartDate).toBeCalledWith(moment('2021-09-10').valueOf());
|
|
229
|
-
expect(mockSetEndDate).toBeCalledWith(moment('2021-09-
|
|
238
|
+
expect(mockSetEndDate).toBeCalledWith(moment('2021-09-25').valueOf());
|
|
230
239
|
});
|
|
231
240
|
});
|
|
@@ -20,7 +20,7 @@ const ThreeButtonHistory = memo(
|
|
|
20
20
|
const t = useTranslations();
|
|
21
21
|
const calendarRef = useRef();
|
|
22
22
|
const [selectedIndex, setSelectedIndex] = useState(2);
|
|
23
|
-
const [
|
|
23
|
+
const [showCalendar, setShowCalendar] = useState(false);
|
|
24
24
|
const [selectedStart, setSelectedStart] = useState(
|
|
25
25
|
moment(startDate).format('YYYY-MM-DD')
|
|
26
26
|
);
|
|
@@ -57,15 +57,15 @@ const ThreeButtonHistory = memo(
|
|
|
57
57
|
[selectedIndex]
|
|
58
58
|
);
|
|
59
59
|
|
|
60
|
-
const
|
|
60
|
+
const onCalendarCancel = useCallback(() => {
|
|
61
61
|
if (showSelectMonth) {
|
|
62
62
|
setShowSelectMonth(false);
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
setShowCalendar(false);
|
|
66
66
|
}, [showSelectMonth, setShowSelectMonth]);
|
|
67
67
|
|
|
68
|
-
const
|
|
68
|
+
const onCalendarDone = useCallback(() => {
|
|
69
69
|
if (showSelectMonth) {
|
|
70
70
|
setShowSelectMonth(false);
|
|
71
71
|
return;
|
|
@@ -73,7 +73,7 @@ const ThreeButtonHistory = memo(
|
|
|
73
73
|
if (selectedStart === null || selectedEnd === null) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
setShowCalendar(false);
|
|
77
77
|
setStartDate(moment(selectedStart).valueOf());
|
|
78
78
|
setEndDate(moment(selectedEnd).valueOf());
|
|
79
79
|
}, [
|
|
@@ -85,9 +85,12 @@ const ThreeButtonHistory = memo(
|
|
|
85
85
|
setShowSelectMonth,
|
|
86
86
|
]);
|
|
87
87
|
|
|
88
|
-
const
|
|
88
|
+
const onDateSelected = useCallback(
|
|
89
89
|
(date) => {
|
|
90
90
|
const selectedDate = date.dateString;
|
|
91
|
+
const mmSelectedDate = moment(selectedDate);
|
|
92
|
+
onMonthSelected(mmSelectedDate);
|
|
93
|
+
|
|
91
94
|
if (selectedDate === selectedStart) {
|
|
92
95
|
setSelectedStart(null);
|
|
93
96
|
return;
|
|
@@ -96,25 +99,54 @@ const ThreeButtonHistory = memo(
|
|
|
96
99
|
setSelectedEnd(null);
|
|
97
100
|
return;
|
|
98
101
|
}
|
|
99
|
-
|
|
102
|
+
|
|
103
|
+
if (!!selectedStart && !!selectedEnd) {
|
|
104
|
+
if (mmSelectedDate.isAfter(selectedEnd, 'date')) {
|
|
105
|
+
setSelectedEnd(selectedDate);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (mmSelectedDate.isBefore(selectedStart, 'date')) {
|
|
109
|
+
setSelectedStart(selectedDate);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (
|
|
113
|
+
Math.abs(mmSelectedDate.diff(selectedStart, 'days')) <=
|
|
114
|
+
Math.abs(mmSelectedDate.diff(selectedEnd, 'days'))
|
|
115
|
+
) {
|
|
116
|
+
setSelectedStart(selectedDate);
|
|
117
|
+
} else {
|
|
118
|
+
setSelectedEnd(selectedDate);
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (selectedStart) {
|
|
124
|
+
if (mmSelectedDate.isBefore(selectedStart, 'date')) {
|
|
125
|
+
setSelectedStart(selectedDate);
|
|
126
|
+
setSelectedEnd(selectedStart);
|
|
127
|
+
} else {
|
|
128
|
+
setSelectedEnd(selectedDate);
|
|
129
|
+
}
|
|
100
130
|
return;
|
|
101
131
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (moment(selectedDate).isAfter(selectedEnd, 'date')) {
|
|
132
|
+
|
|
133
|
+
if (selectedEnd) {
|
|
134
|
+
if (mmSelectedDate.isAfter(selectedEnd, 'date')) {
|
|
106
135
|
setSelectedStart(selectedEnd);
|
|
107
136
|
setSelectedEnd(selectedDate);
|
|
108
137
|
} else {
|
|
109
138
|
setSelectedStart(selectedDate);
|
|
110
139
|
}
|
|
140
|
+
return;
|
|
111
141
|
}
|
|
142
|
+
|
|
143
|
+
setSelectedStart(selectedDate);
|
|
112
144
|
},
|
|
113
|
-
[selectedStart, selectedEnd]
|
|
145
|
+
[selectedStart, selectedEnd, onMonthSelected]
|
|
114
146
|
);
|
|
115
147
|
|
|
116
148
|
const onPressItemButton = useCallback(
|
|
117
|
-
(index) => {
|
|
149
|
+
(index) => () => {
|
|
118
150
|
switch (index) {
|
|
119
151
|
case 0:
|
|
120
152
|
setGroupBy('week');
|
|
@@ -124,9 +156,7 @@ const ThreeButtonHistory = memo(
|
|
|
124
156
|
break;
|
|
125
157
|
case 2:
|
|
126
158
|
setGroupBy('date');
|
|
127
|
-
|
|
128
|
-
setIsShowDate(true);
|
|
129
|
-
}
|
|
159
|
+
selectedIndex === 2 && setShowCalendar(true);
|
|
130
160
|
}
|
|
131
161
|
setSelectedIndex(index);
|
|
132
162
|
},
|
|
@@ -212,7 +242,6 @@ const ThreeButtonHistory = memo(
|
|
|
212
242
|
},
|
|
213
243
|
},
|
|
214
244
|
selected: true,
|
|
215
|
-
disableTouchEvent: true,
|
|
216
245
|
color: Colors.Gray4,
|
|
217
246
|
};
|
|
218
247
|
}
|
|
@@ -228,15 +257,15 @@ const ThreeButtonHistory = memo(
|
|
|
228
257
|
<ItemButton
|
|
229
258
|
key={index}
|
|
230
259
|
dateTitle={item.dateTitle}
|
|
231
|
-
onPress={
|
|
260
|
+
onPress={onPressItemButton(index)}
|
|
232
261
|
isSelected={selectedIndex === index}
|
|
233
262
|
/>
|
|
234
263
|
);
|
|
235
264
|
})}
|
|
236
265
|
</View>
|
|
237
266
|
<BottomSheet
|
|
238
|
-
isVisible={
|
|
239
|
-
onBackdropPress={
|
|
267
|
+
isVisible={showCalendar}
|
|
268
|
+
onBackdropPress={onCalendarCancel}
|
|
240
269
|
style={styles.modal}
|
|
241
270
|
>
|
|
242
271
|
<View style={styles.calendar}>
|
|
@@ -257,7 +286,7 @@ const ThreeButtonHistory = memo(
|
|
|
257
286
|
current={currentMonth.format('YYYY-MM-DD')}
|
|
258
287
|
style={showSelectMonth && styles.displayNone}
|
|
259
288
|
markingType={'custom'}
|
|
260
|
-
onDayPress={
|
|
289
|
+
onDayPress={onDateSelected}
|
|
261
290
|
maxDate={moment().format('YYYY-MM-DD')}
|
|
262
291
|
markedDates={markedDates}
|
|
263
292
|
hideArrows={true}
|
|
@@ -267,9 +296,9 @@ const ThreeButtonHistory = memo(
|
|
|
267
296
|
<View style={styles.separator} />
|
|
268
297
|
<ViewButtonBottom
|
|
269
298
|
leftTitle={t('cancel')}
|
|
270
|
-
onLeftClick={
|
|
299
|
+
onLeftClick={onCalendarCancel}
|
|
271
300
|
rightTitle={t('done')}
|
|
272
|
-
onRightClick={
|
|
301
|
+
onRightClick={onCalendarDone}
|
|
273
302
|
/>
|
|
274
303
|
</View>
|
|
275
304
|
</BottomSheet>
|
package/src/configs/Constants.js
CHANGED
|
@@ -116,13 +116,13 @@ export const AUTOMATES = {
|
|
|
116
116
|
value_change: {
|
|
117
117
|
value: AUTOMATE_TYPE.VALUE_CHANGE,
|
|
118
118
|
title: 'value_change',
|
|
119
|
-
explanation: '
|
|
119
|
+
explanation: 'setup_the_conditions',
|
|
120
120
|
icon: ValueChange,
|
|
121
121
|
},
|
|
122
122
|
schedule: {
|
|
123
123
|
value: AUTOMATE_TYPE.SCHEDULE,
|
|
124
124
|
title: 'schedule',
|
|
125
|
-
explanation: '
|
|
125
|
+
explanation: 'setup_the_schedule',
|
|
126
126
|
icon: Schedule,
|
|
127
127
|
},
|
|
128
128
|
};
|
|
@@ -39,6 +39,15 @@ const DetailLog = ({ item }) => {
|
|
|
39
39
|
<Text style={styles.name}>{item.name || item.params?.username}</Text>
|
|
40
40
|
</Text>
|
|
41
41
|
);
|
|
42
|
+
default:
|
|
43
|
+
return (
|
|
44
|
+
<Text style={styles.text}>
|
|
45
|
+
{item.action_name
|
|
46
|
+
? `${item.action_name} ${t('by')} `
|
|
47
|
+
: `${t('activated_by')} `}
|
|
48
|
+
<Text style={styles.name}>{item.name || item.params?.username}</Text>
|
|
49
|
+
</Text>
|
|
50
|
+
);
|
|
42
51
|
}
|
|
43
52
|
};
|
|
44
53
|
|
|
@@ -60,6 +60,49 @@ test('test ItemLog one tap', () => {
|
|
|
60
60
|
expect(texts[2].props.children).toBe(props.item.params.username);
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
test('test ItemLog script update', () => {
|
|
64
|
+
let tree;
|
|
65
|
+
let props = {
|
|
66
|
+
item: {
|
|
67
|
+
content_code: 'SCRIPT_UPDATED_BY',
|
|
68
|
+
params: {
|
|
69
|
+
username: 'username',
|
|
70
|
+
},
|
|
71
|
+
created_at: '2021-07-02T15:48:24.917932Z',
|
|
72
|
+
},
|
|
73
|
+
type: 'automate',
|
|
74
|
+
length: 2,
|
|
75
|
+
index: 1,
|
|
76
|
+
};
|
|
77
|
+
act(() => {
|
|
78
|
+
tree = create(wrapComponent(props));
|
|
79
|
+
});
|
|
80
|
+
const instance = tree.root;
|
|
81
|
+
const texts = instance.findAllByType(Text);
|
|
82
|
+
expect(texts[2].props.children).toBe(props.item.params.username);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('test ItemLog no content_code', () => {
|
|
86
|
+
let tree;
|
|
87
|
+
let props = {
|
|
88
|
+
item: {
|
|
89
|
+
params: {
|
|
90
|
+
username: 'username',
|
|
91
|
+
},
|
|
92
|
+
created_at: '2021-07-02T15:48:24.917932Z',
|
|
93
|
+
},
|
|
94
|
+
type: 'action',
|
|
95
|
+
length: 2,
|
|
96
|
+
index: 1,
|
|
97
|
+
};
|
|
98
|
+
act(() => {
|
|
99
|
+
tree = create(wrapComponent(props));
|
|
100
|
+
});
|
|
101
|
+
const instance = tree.root;
|
|
102
|
+
const texts = instance.findAllByType(Text);
|
|
103
|
+
expect(texts[2].props.children).toBe(props.item.params.username);
|
|
104
|
+
});
|
|
105
|
+
|
|
63
106
|
describe('test ItemLog emergency event', () => {
|
|
64
107
|
let tree;
|
|
65
108
|
let props;
|
|
@@ -86,7 +86,7 @@ const AddCommonSelectSubUnit = ({ route }) => {
|
|
|
86
86
|
const addSubUnit = useCallback(() => {
|
|
87
87
|
navigation.navigate(Routes.AddSubUnitStack, {
|
|
88
88
|
screen: Routes.AddSubUnit,
|
|
89
|
-
params: { unit, ...route.params },
|
|
89
|
+
params: { unit, ...route.params, addType: 'AddHassiDevice' },
|
|
90
90
|
});
|
|
91
91
|
}, [navigation, unit, route.params]);
|
|
92
92
|
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useState,
|
|
3
|
+
useCallback,
|
|
4
|
+
useMemo,
|
|
5
|
+
useEffect,
|
|
6
|
+
useRef,
|
|
7
|
+
} from 'react';
|
|
2
8
|
import {
|
|
3
9
|
View,
|
|
4
10
|
Image,
|
|
@@ -42,80 +48,93 @@ const prepareImageToUpload = async (image) => {
|
|
|
42
48
|
|
|
43
49
|
const AddSubUnit = ({ route }) => {
|
|
44
50
|
const t = useTranslations();
|
|
45
|
-
const
|
|
51
|
+
const { navigate, goBack } = useNavigation();
|
|
46
52
|
const { unit, addType, isAddUnit, location = '' } = route?.params;
|
|
47
53
|
const [roomName, setRoomName] = useState('');
|
|
48
54
|
const [wallpaper, setWallpaper] = useState('');
|
|
49
55
|
const [imageUrl, setImageUrl] = useState('');
|
|
50
56
|
const [showImagePicker, setShowImagePicker] = useState(false);
|
|
57
|
+
let awaitCreate = useRef(false);
|
|
51
58
|
|
|
52
59
|
const goDone = useCallback(async () => {
|
|
53
60
|
if (isAddUnit) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
if (!awaitCreate.current) {
|
|
62
|
+
awaitCreate.current = true;
|
|
63
|
+
const dataObj = {
|
|
64
|
+
name: roomName,
|
|
65
|
+
address: location,
|
|
66
|
+
background: wallpaper,
|
|
67
|
+
};
|
|
68
|
+
dataObj.background = await prepareImageToUpload(dataObj.background);
|
|
69
|
+
const formData = createFormData(dataObj, ['background']);
|
|
70
|
+
const { success, data } = await axiosPost(
|
|
71
|
+
API.UNIT.CREATE_UNIT(),
|
|
72
|
+
formData,
|
|
73
|
+
{
|
|
74
|
+
headers: { 'Content-Type': 'multipart/form-data' },
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
if (success) {
|
|
78
|
+
navigate(Routes.UnitStack, {
|
|
79
|
+
screen: Routes.UnitDetail,
|
|
80
|
+
params: {
|
|
81
|
+
unitId: data?.id,
|
|
82
|
+
routeName: Routes.DashboardStack,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
} else {
|
|
86
|
+
awaitCreate.current = false;
|
|
87
|
+
ToastBottomHelper.error(t('text_create_unit_fail'));
|
|
66
88
|
}
|
|
67
|
-
);
|
|
68
|
-
if (success) {
|
|
69
|
-
navigation.navigate(Routes.UnitStack, {
|
|
70
|
-
screen: Routes.UnitDetail,
|
|
71
|
-
params: {
|
|
72
|
-
unitId: data?.id,
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
} else {
|
|
76
|
-
ToastBottomHelper.error(t('text_create_unit_fail'));
|
|
77
89
|
}
|
|
78
90
|
} else {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
if (!awaitCreate.current) {
|
|
92
|
+
awaitCreate.current = true;
|
|
93
|
+
const dataObj = { name: roomName, background: wallpaper };
|
|
94
|
+
dataObj.background = await prepareImageToUpload(dataObj.background);
|
|
95
|
+
const formData = createFormData(dataObj, ['background']);
|
|
96
|
+
const { success, data } = await axiosPost(
|
|
97
|
+
API.SUB_UNIT.CREATE_SUB_UNIT(unit.id),
|
|
98
|
+
formData,
|
|
99
|
+
{
|
|
100
|
+
headers: { 'Content-Type': 'multipart/form-data' },
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
if (success) {
|
|
104
|
+
ToastBottomHelper.success(t('text_create_sub_unit_success'));
|
|
105
|
+
if (addType === 'AddHassiDevice') {
|
|
106
|
+
goBack();
|
|
107
|
+
return;
|
|
108
|
+
} else if (addType === 'AddNewGateway') {
|
|
109
|
+
navigate(Routes.AddCommonSelectSubUnit, {
|
|
110
|
+
...route.params,
|
|
111
|
+
});
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
navigate(Routes.UnitStack, {
|
|
115
|
+
screen: Routes.SubUnitDetail,
|
|
116
|
+
params: {
|
|
117
|
+
unit: unit,
|
|
118
|
+
station: data,
|
|
119
|
+
},
|
|
95
120
|
});
|
|
96
|
-
|
|
121
|
+
} else {
|
|
122
|
+
awaitCreate.current = false;
|
|
123
|
+
ToastBottomHelper.error(t('text_create_sub_unit_fail'));
|
|
97
124
|
}
|
|
98
|
-
navigation.navigate(Routes.UnitStack, {
|
|
99
|
-
screen: Routes.SubUnitDetail,
|
|
100
|
-
params: {
|
|
101
|
-
unit: unit,
|
|
102
|
-
station: data,
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
} else {
|
|
106
|
-
ToastBottomHelper.error(t('text_create_sub_unit_fail'));
|
|
107
125
|
}
|
|
108
126
|
}
|
|
109
127
|
}, [
|
|
110
|
-
|
|
111
|
-
navigation,
|
|
128
|
+
isAddUnit,
|
|
112
129
|
roomName,
|
|
113
|
-
|
|
130
|
+
location,
|
|
131
|
+
wallpaper,
|
|
132
|
+
navigate,
|
|
114
133
|
t,
|
|
115
134
|
unit,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
135
|
+
addType,
|
|
136
|
+
goBack,
|
|
137
|
+
route.params,
|
|
119
138
|
]);
|
|
120
139
|
|
|
121
140
|
const onChoosePhoto = useCallback(() => {
|
|
@@ -144,8 +163,8 @@ const AddSubUnit = ({ route }) => {
|
|
|
144
163
|
}, [roomName, wallpaper, location, isAddUnit]);
|
|
145
164
|
|
|
146
165
|
const onChooseLocation = useCallback(() => {
|
|
147
|
-
|
|
148
|
-
}, [
|
|
166
|
+
navigate(Routes.AddLocationMaps);
|
|
167
|
+
}, [navigate]);
|
|
149
168
|
|
|
150
169
|
return (
|
|
151
170
|
<SafeAreaView style={styles.wrap}>
|
|
@@ -211,7 +230,7 @@ const AddSubUnit = ({ route }) => {
|
|
|
211
230
|
</View>
|
|
212
231
|
<ViewButtonBottom
|
|
213
232
|
leftTitle={t('cancel')}
|
|
214
|
-
onLeftClick={() =>
|
|
233
|
+
onLeftClick={() => goBack()}
|
|
215
234
|
rightTitle={t('done')}
|
|
216
235
|
rightDisabled={validateData}
|
|
217
236
|
onRightClick={goDone}
|
|
@@ -30,7 +30,7 @@ import { AUTOMATE_TYPE } from '../../configs/Constants';
|
|
|
30
30
|
|
|
31
31
|
const UnitDetail = ({ route }) => {
|
|
32
32
|
const t = useTranslations();
|
|
33
|
-
const { unitId, unitData, isOneTap } = route.params;
|
|
33
|
+
const { unitId, unitData, isOneTap, routeName } = route.params;
|
|
34
34
|
const isFocused = useIsFocused();
|
|
35
35
|
const { stateData, setAction } = useContext(SCContext);
|
|
36
36
|
const { navigate } = useNavigation();
|
|
@@ -274,6 +274,11 @@ const UnitDetail = ({ route }) => {
|
|
|
274
274
|
);
|
|
275
275
|
}
|
|
276
276
|
};
|
|
277
|
+
|
|
278
|
+
const onBack = useCallback(() => {
|
|
279
|
+
navigate(routeName);
|
|
280
|
+
}, [navigate, routeName]);
|
|
281
|
+
|
|
277
282
|
return (
|
|
278
283
|
<WrapParallaxScrollView
|
|
279
284
|
uriImg={unit.background}
|
|
@@ -286,6 +291,7 @@ const UnitDetail = ({ route }) => {
|
|
|
286
291
|
onAdd={setShowAdd}
|
|
287
292
|
onMore={showPopoverWithRef}
|
|
288
293
|
hideRightPlus={!isOwner}
|
|
294
|
+
onBack={routeName && onBack}
|
|
289
295
|
>
|
|
290
296
|
<View style={styles.container}>
|
|
291
297
|
<Summaries unit={unit} />
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
axiosPatch,
|
|
12
12
|
axiosDelete,
|
|
13
13
|
} from '../../utils/Apis/axios';
|
|
14
|
-
import { navigate } from '../../navigations/utils';
|
|
15
14
|
import useBoolean from '../../hooks/Common/useBoolean';
|
|
16
15
|
import useKeyboardAnimated from '../../hooks/Explore/useKeyboardAnimated';
|
|
17
16
|
|
|
@@ -134,11 +133,11 @@ const ManageUnit = ({ route }) => {
|
|
|
134
133
|
const goRemove = useCallback(async () => {
|
|
135
134
|
const { success } = await axiosDelete(API.UNIT.MANAGE_UNIT(unit.id));
|
|
136
135
|
if (success) {
|
|
137
|
-
|
|
136
|
+
setHideRemove(true);
|
|
138
137
|
ToastBottomHelper.success(t('unit_deleted_successfully'));
|
|
139
|
-
navigate(Routes.Dashboard);
|
|
138
|
+
navigation.navigate(Routes.Dashboard);
|
|
140
139
|
}
|
|
141
|
-
}, [unit.id,
|
|
140
|
+
}, [unit.id, setHideRemove, t, navigation]);
|
|
142
141
|
|
|
143
142
|
const goToManageSubUnit = useCallback(() => {
|
|
144
143
|
navigation.navigate(Routes.UnitStack, {
|
|
@@ -95,7 +95,6 @@ const ListSmartAccount = ({ route }) => {
|
|
|
95
95
|
},
|
|
96
96
|
[navigate, unitId]
|
|
97
97
|
);
|
|
98
|
-
|
|
99
98
|
return (
|
|
100
99
|
<View style={styles.wrap}>
|
|
101
100
|
<WrapHeaderScrollable
|
|
@@ -116,7 +115,7 @@ const ListSmartAccount = ({ route }) => {
|
|
|
116
115
|
})}
|
|
117
116
|
</View>
|
|
118
117
|
<AlertAction
|
|
119
|
-
visible={stateAlertRemove.visible && lockShowing}
|
|
118
|
+
visible={stateAlertRemove.visible && !lockShowing}
|
|
120
119
|
hideModal={hideAlertAction}
|
|
121
120
|
title={stateAlertRemove.title}
|
|
122
121
|
message={stateAlertRemove.message}
|
|
@@ -131,7 +130,7 @@ const ListSmartAccount = ({ route }) => {
|
|
|
131
130
|
listMenuItem={listMenuItem}
|
|
132
131
|
childRef={childRef}
|
|
133
132
|
onItemClick={onItemClick}
|
|
134
|
-
|
|
133
|
+
hideComplete={releaseLockShowing}
|
|
135
134
|
/>
|
|
136
135
|
</WrapHeaderScrollable>
|
|
137
136
|
</View>
|
|
@@ -31,7 +31,7 @@ export const SmartAccountItem = memo(
|
|
|
31
31
|
/>
|
|
32
32
|
<View style={styles.wrap}>
|
|
33
33
|
<Text numberOfLines={1} type="H4">
|
|
34
|
-
{item?.brand}
|
|
34
|
+
{item?.brand === 'google_home' ? 'Điện Quang' : item?.brand}
|
|
35
35
|
</Text>
|
|
36
36
|
<Text numberOfLines={2} type="Body" color={Colors.Gray7}>
|
|
37
37
|
{item?.username}
|
|
@@ -20,7 +20,11 @@ const Summaries = memo(({ unit }) => {
|
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const { success, data } = await axiosGet(
|
|
23
|
+
const { success, data } = await axiosGet(
|
|
24
|
+
API.UNIT.UNIT_SUMMARY(unit.id),
|
|
25
|
+
{},
|
|
26
|
+
true
|
|
27
|
+
);
|
|
24
28
|
if (success && data.length) {
|
|
25
29
|
setUnitSummaries(data);
|
|
26
30
|
}
|
|
@@ -22,7 +22,9 @@ export const useStateAlertRemove = () => {
|
|
|
22
22
|
setStateAlertRemove((state) => ({
|
|
23
23
|
...state,
|
|
24
24
|
visible: true,
|
|
25
|
-
message: `${t('are_you_sure_want_to_delete', {
|
|
25
|
+
message: `${t('are_you_sure_want_to_delete', {
|
|
26
|
+
text: brand === 'google_home' ? 'Điện Quang' : brand,
|
|
27
|
+
})}`,
|
|
26
28
|
}));
|
|
27
29
|
},
|
|
28
30
|
[t]
|
|
@@ -239,7 +239,7 @@ const ThreePhasePowerConsumption = memo(({ unit, summary, summaryDetail }) => {
|
|
|
239
239
|
</Section>
|
|
240
240
|
|
|
241
241
|
<Section type={'border'}>
|
|
242
|
-
<Text semibold style={styles.textIndoor}
|
|
242
|
+
<Text type="H3" semibold style={styles.textIndoor}>
|
|
243
243
|
{t('text_total_power_consumption')}
|
|
244
244
|
</Text>
|
|
245
245
|
|
|
@@ -145,7 +145,7 @@ const PowerConsumption = memo(({ summaryDetail }) => {
|
|
|
145
145
|
</Section>
|
|
146
146
|
|
|
147
147
|
<Section type={'border'}>
|
|
148
|
-
<Text semibold style={styles.textIndoor}
|
|
148
|
+
<Text type="H3" semibold style={styles.textIndoor}>
|
|
149
149
|
{t('text_total_power_consumption')}
|
|
150
150
|
</Text>
|
|
151
151
|
|
|
@@ -43,7 +43,12 @@ const UvIndex = memo(({ summaryDetail }) => {
|
|
|
43
43
|
/>
|
|
44
44
|
<View style={styles.boxHealth}>
|
|
45
45
|
<IconOutline name="alert" size={20} style={styles.iconMargin} />
|
|
46
|
-
<Text
|
|
46
|
+
<Text
|
|
47
|
+
semibold
|
|
48
|
+
color={Colors.Gray9}
|
|
49
|
+
type="H4"
|
|
50
|
+
style={styles.textTitle}
|
|
51
|
+
>
|
|
47
52
|
{t('Protection advices:')}
|
|
48
53
|
</Text>
|
|
49
54
|
</View>
|
|
@@ -56,7 +61,7 @@ const UvIndex = memo(({ summaryDetail }) => {
|
|
|
56
61
|
{ backgroundColor: summaryDetail.uv_color },
|
|
57
62
|
]}
|
|
58
63
|
/>
|
|
59
|
-
<Text color={Colors.Gray7}
|
|
64
|
+
<Text color={Colors.Gray7} type="Body">
|
|
60
65
|
{item}
|
|
61
66
|
</Text>
|
|
62
67
|
</View>
|
|
@@ -119,4 +124,7 @@ const styles = StyleSheet.create({
|
|
|
119
124
|
iconMargin: {
|
|
120
125
|
marginRight: 8,
|
|
121
126
|
},
|
|
127
|
+
textTitle: {
|
|
128
|
+
lineHeight: 28,
|
|
129
|
+
},
|
|
122
130
|
});
|
|
@@ -35,9 +35,7 @@ const Item = memo((props) => {
|
|
|
35
35
|
<Text size={24} color={color || Colors.Gray9} style={styles.textValue}>
|
|
36
36
|
{value}
|
|
37
37
|
</Text>
|
|
38
|
-
<Text
|
|
39
|
-
{des}
|
|
40
|
-
</Text>
|
|
38
|
+
<Text color={Colors.Gray8}>{des}</Text>
|
|
41
39
|
<View style={styles.boxSvg}>
|
|
42
40
|
<Text>{svgMain}</Text>
|
|
43
41
|
</View>
|