@eohjsc/react-native-smart-city 0.2.47 → 0.2.48
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 +23 -3
- package/src/commons/Dashboard/MyPinnedSharedUnit/styles.js +1 -1
- package/src/screens/ActivityLog/__test__/ItemLog.test.js +0 -20
- package/src/screens/ScriptDetail/index.js +18 -9
- package/src/screens/SetSchedule/components/SelectWeekday.js +13 -7
- package/src/screens/SubUnit/AddSubUnit.js +2 -2
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +1 -0
- package/src/screens/Unit/SmartAccount.js +1 -1
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.
|
|
4
|
+
"version": "0.2.48",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -39,12 +39,16 @@
|
|
|
39
39
|
"reset-cache": "react-native start --reset-cache",
|
|
40
40
|
"merge_conflict": "yarn jest && yarn update_coverage_result && yarn check_coverage_config",
|
|
41
41
|
"jest": "jest --detectOpenHandles",
|
|
42
|
-
"postinstall": "patch-package",
|
|
42
|
+
"postinstall": "patch-package && npx husky install",
|
|
43
43
|
"example": "yarn --cwd example",
|
|
44
44
|
"pods": "cd example && pod-install --quiet",
|
|
45
45
|
"bootstrap": "yarn example && yarn && yarn pods",
|
|
46
46
|
"build": "sync-files ./src ../EohMobile/node_modules/@eohjsc/react-native-smart-city/src",
|
|
47
|
-
"watch": "sync-files --watch ./src ../EohMobile/node_modules/@eohjsc/react-native-smart-city/src"
|
|
47
|
+
"watch": "sync-files --watch ./src ../EohMobile/node_modules/@eohjsc/react-native-smart-city/src",
|
|
48
|
+
"test:code-formatter": "prettier src/**/**/*.js --write",
|
|
49
|
+
"test:code-formatter-step-1": "prettier --check src/**/*.js",
|
|
50
|
+
"test:code-formatter-step-2": "prettier --check src/**/**/*.js",
|
|
51
|
+
"test:code-formatter-step-3": "prettier --check src/**/**/**/*.js"
|
|
48
52
|
},
|
|
49
53
|
"repository": {
|
|
50
54
|
"type": "git",
|
|
@@ -159,6 +163,7 @@
|
|
|
159
163
|
"react-native-gesture-handler": "^1.7.0",
|
|
160
164
|
"react-native-get-location": "^2.0.0",
|
|
161
165
|
"react-native-image-picker": "^3.1.4",
|
|
166
|
+
"react-native-image-resizer": "^1.4.5",
|
|
162
167
|
"react-native-input-credit-card": "^0.5.5",
|
|
163
168
|
"react-native-iphone-x-helper": "^1.2.1",
|
|
164
169
|
"react-native-keyboard-aware-scroll-view": "^0.9.2",
|
|
@@ -201,6 +206,21 @@
|
|
|
201
206
|
"validator": "^13.1.1",
|
|
202
207
|
"victory-native": "^35.0.1"
|
|
203
208
|
},
|
|
209
|
+
"husky": {
|
|
210
|
+
"hooks": {
|
|
211
|
+
"pre-commit": "lint-staged",
|
|
212
|
+
"pre-push": "yarn jest"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"lint-staged": {
|
|
216
|
+
"*.{js, ts}": [
|
|
217
|
+
"yarn lint",
|
|
218
|
+
"yarn test:code-formatter",
|
|
219
|
+
"yarn test:code-formatter-step-1",
|
|
220
|
+
"yarn test:code-formatter-step-2",
|
|
221
|
+
"yarn test:code-formatter-step-3"
|
|
222
|
+
]
|
|
223
|
+
},
|
|
204
224
|
"bugs": {
|
|
205
225
|
"url": "https://github.com/github_account/react-native-smart-city/issues"
|
|
206
226
|
},
|
|
@@ -19,26 +19,6 @@ jest.mock('react', () => {
|
|
|
19
19
|
};
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
test('test ItemLog action', () => {
|
|
23
|
-
let tree;
|
|
24
|
-
let props = {
|
|
25
|
-
item: {
|
|
26
|
-
action_name: 'action',
|
|
27
|
-
name: 'name',
|
|
28
|
-
created_at: '2021-07-02T15:48:24.917932Z',
|
|
29
|
-
},
|
|
30
|
-
type: 'action',
|
|
31
|
-
length: 1,
|
|
32
|
-
index: 0,
|
|
33
|
-
};
|
|
34
|
-
act(() => {
|
|
35
|
-
tree = create(wrapComponent(props));
|
|
36
|
-
});
|
|
37
|
-
const instance = tree.root;
|
|
38
|
-
const texts = instance.findAllByType(Text);
|
|
39
|
-
expect(texts[2].props.children).toBe(props.item.name);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
22
|
test('test ItemLog smart assistant', () => {
|
|
43
23
|
let tree;
|
|
44
24
|
let props = {
|
|
@@ -363,7 +363,6 @@ const ScriptDetail = ({ route }) => {
|
|
|
363
363
|
time_repeat,
|
|
364
364
|
weekday_repeat,
|
|
365
365
|
} = automate;
|
|
366
|
-
|
|
367
366
|
if (type === AUTOMATE_TYPE.VALUE_CHANGE) {
|
|
368
367
|
let textCondition;
|
|
369
368
|
if (condition === '>') {
|
|
@@ -381,13 +380,13 @@ const ScriptDetail = ({ route }) => {
|
|
|
381
380
|
: time_repeat;
|
|
382
381
|
const date = date_repeat.split('-').reverse().join('/');
|
|
383
382
|
const weekday = {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
383
|
+
1: t('mon'),
|
|
384
|
+
2: t('tue'),
|
|
385
|
+
3: t('wed'),
|
|
386
|
+
4: t('thu'),
|
|
387
|
+
5: t('fri'),
|
|
388
|
+
6: t('sat'),
|
|
389
|
+
0: t('sun'),
|
|
391
390
|
};
|
|
392
391
|
|
|
393
392
|
if (repeat === REPEAT_OPTIONS.ONCE) {
|
|
@@ -395,7 +394,17 @@ const ScriptDetail = ({ route }) => {
|
|
|
395
394
|
} else if (repeat === REPEAT_OPTIONS.EVERYDAY) {
|
|
396
395
|
return `${t('every_day_at', { time })}`;
|
|
397
396
|
} else if (repeat === REPEAT_OPTIONS.EVERYWEEK) {
|
|
398
|
-
|
|
397
|
+
//sort 0 is last number, exp: [1,3,5,0]
|
|
398
|
+
const newWeekdayRepeat = weekday_repeat.map((item) => parseInt(item));
|
|
399
|
+
const sortWeekday = newWeekdayRepeat.sort((a, b) => {
|
|
400
|
+
if (a !== 0 && b === 0) {
|
|
401
|
+
return -1;
|
|
402
|
+
}
|
|
403
|
+
if (a === 0 && b !== 0) {
|
|
404
|
+
return 1;
|
|
405
|
+
}
|
|
406
|
+
return a - b;
|
|
407
|
+
});
|
|
399
408
|
const textWeekday = sortWeekday.map((item) => weekday[item]).join(', ');
|
|
400
409
|
return `${textWeekday} ${t('at')} ${time}`;
|
|
401
410
|
}
|
|
@@ -5,7 +5,15 @@ import { Colors } from '../../../configs';
|
|
|
5
5
|
import styles from '../styles/SelectWeekdayStyles';
|
|
6
6
|
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
7
7
|
|
|
8
|
-
const WEEKDAY_ITEMS = [
|
|
8
|
+
const WEEKDAY_ITEMS = [
|
|
9
|
+
{ day: 'Mon', value: 1 },
|
|
10
|
+
{ day: 'Tue', value: 2 },
|
|
11
|
+
{ day: 'Wed', value: 3 },
|
|
12
|
+
{ day: 'Thu', value: 4 },
|
|
13
|
+
{ day: 'Fri', value: 5 },
|
|
14
|
+
{ day: 'Sat', value: 6 },
|
|
15
|
+
{ day: 'Sun', value: 0 },
|
|
16
|
+
];
|
|
9
17
|
|
|
10
18
|
const SelectWeekday = ({ weekday, setWeekday }) => {
|
|
11
19
|
const t = useTranslations();
|
|
@@ -23,11 +31,10 @@ const SelectWeekday = ({ weekday, setWeekday }) => {
|
|
|
23
31
|
);
|
|
24
32
|
|
|
25
33
|
const WeekdayItem = useCallback(
|
|
26
|
-
({ item,
|
|
34
|
+
({ item, isSelected }) => {
|
|
27
35
|
return (
|
|
28
36
|
<TouchableOpacity
|
|
29
|
-
|
|
30
|
-
onPress={() => onSetWeekday(`${index}`)}
|
|
37
|
+
onPress={() => onSetWeekday(`${item?.value}`)}
|
|
31
38
|
style={[styles.item, isSelected && styles.selected]}
|
|
32
39
|
>
|
|
33
40
|
<Text
|
|
@@ -36,7 +43,7 @@ const SelectWeekday = ({ weekday, setWeekday }) => {
|
|
|
36
43
|
style={styles.text}
|
|
37
44
|
semibold
|
|
38
45
|
>
|
|
39
|
-
{item}
|
|
46
|
+
{item?.day}
|
|
40
47
|
</Text>
|
|
41
48
|
</TouchableOpacity>
|
|
42
49
|
);
|
|
@@ -54,8 +61,7 @@ const SelectWeekday = ({ weekday, setWeekday }) => {
|
|
|
54
61
|
<WeekdayItem
|
|
55
62
|
key={index}
|
|
56
63
|
item={item}
|
|
57
|
-
|
|
58
|
-
isSelected={weekday.includes(`${index}`)}
|
|
64
|
+
isSelected={weekday.includes(`${item?.value}`)}
|
|
59
65
|
/>
|
|
60
66
|
))}
|
|
61
67
|
</View>
|
|
@@ -20,7 +20,7 @@ import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
|
20
20
|
import { useStateAlertRemove } from '../Unit/hook/useStateAlertRemove';
|
|
21
21
|
|
|
22
22
|
const ListSmartAccount = ({ route }) => {
|
|
23
|
-
const { unitId } = route
|
|
23
|
+
const { unitId } = route?.params || {};
|
|
24
24
|
const t = useTranslations();
|
|
25
25
|
const [data, setData] = useState([]);
|
|
26
26
|
const smartAccountRef = useRef(null);
|