@eohjsc/react-native-smart-city 0.3.30 → 0.3.31

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 (75) hide show
  1. package/package.json +1 -1
  2. package/src/Images/DevMode/close.png +0 -0
  3. package/src/Images/DevMode/close@2x.png +0 -0
  4. package/src/Images/DevMode/close@3x.png +0 -0
  5. package/src/Images/DevMode/plus.png +0 -0
  6. package/src/Images/DevMode/plus@2x.png +0 -0
  7. package/src/Images/DevMode/plus@3x.png +0 -0
  8. package/src/Images/DevMode/remove_circle.png +0 -0
  9. package/src/Images/DevMode/remove_circle@2x.png +0 -0
  10. package/src/Images/DevMode/remove_circle@3x.png +0 -0
  11. package/src/commons/ActionGroup/ColorPickerTemplate.js +36 -17
  12. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +13 -8
  13. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +37 -44
  14. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLockStyle.js +1 -0
  15. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +5 -4
  16. package/src/commons/ActionGroup/OnOffTemplate/index.js +2 -2
  17. package/src/commons/ActionGroup/OneBigButtonTemplate.js +4 -4
  18. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +28 -18
  19. package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -2
  20. package/src/commons/ActionGroup/ThreeButtonTemplate.js +48 -58
  21. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +134 -132
  22. package/src/commons/ActionGroup/__test__/index.test.js +2 -2
  23. package/src/commons/ActionGroup/index.js +35 -10
  24. package/src/commons/DevMode/CardDevMode.js +42 -0
  25. package/src/commons/DevMode/EmptyComponent.js +18 -0
  26. package/src/commons/DevMode/Item.js +21 -0
  27. package/src/commons/DevMode/Styles/CardStyles.js +40 -0
  28. package/src/commons/DevMode/Styles/EmptyComponentStyles.js +15 -0
  29. package/src/commons/DevMode/Styles/ItemStyles.js +27 -0
  30. package/src/commons/DevMode/Styles/TextWithLabelStyles.js +36 -0
  31. package/src/commons/DevMode/TextWithLabel.js +30 -0
  32. package/src/commons/DevMode/index.js +5 -1
  33. package/src/commons/Device/DeviceAlertStatus.js +1 -1
  34. package/src/commons/Device/Emergency/EmergencyDetail.js +1 -1
  35. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +1 -1
  36. package/src/commons/Device/RainningSensor/CurrentRainSensor.js +1 -1
  37. package/src/commons/Device/WindDirection/Compass/index.js +1 -1
  38. package/src/commons/Device/WindSpeed/Anemometer/index.js +1 -1
  39. package/src/commons/Header/HeaderCustom.js +8 -2
  40. package/src/commons/MenuActionMore/index.js +3 -1
  41. package/src/commons/Sharing/WrapHeaderScrollable.js +4 -2
  42. package/src/configs/API.js +6 -0
  43. package/src/configs/Colors.js +4 -0
  44. package/src/configs/Images.js +3 -0
  45. package/src/context/actionType.ts +12 -0
  46. package/src/context/mockStore.ts +12 -0
  47. package/src/context/reducer.ts +43 -1
  48. package/src/navigations/Main.js +26 -2
  49. package/src/screens/AddNewGateway/hooks/__Tests__/index.test.js +27 -0
  50. package/src/screens/Device/components/DetailHistoryChart.js +7 -5
  51. package/src/screens/Device/components/SensorDisplayItem.js +49 -24
  52. package/src/screens/Device/detail.js +3 -1
  53. package/src/screens/Drawer/index.js +9 -4
  54. package/src/screens/Template/EditTemplate.js +151 -0
  55. package/src/screens/Template/GatewayList.js +51 -0
  56. package/src/screens/Template/Information.js +41 -0
  57. package/src/screens/Template/Styles/EditTemplateStyle.js +109 -0
  58. package/src/screens/Template/Styles/GatewayStyles.js +46 -0
  59. package/src/screens/Template/Styles/InformationStyles.js +16 -0
  60. package/src/screens/Template/Styles/detailStyles.js +35 -0
  61. package/src/screens/Template/Styles/indexStyles.js +2 -33
  62. package/src/screens/Template/__test__/EditTemplate.test.js +89 -0
  63. package/src/screens/Template/__test__/GatewayList.test.js +26 -0
  64. package/src/screens/Template/__test__/Information.test.js +16 -0
  65. package/src/screens/Template/__test__/detail.test.js +60 -0
  66. package/src/screens/Template/__test__/index.test.js +26 -1
  67. package/src/screens/Template/detail.js +154 -0
  68. package/src/screens/Template/index.js +39 -32
  69. package/src/screens/Unit/SmartAccount.js +1 -1
  70. package/src/screens/Unit/Station/__test__/index.test.js +18 -2
  71. package/src/screens/Unit/__test__/Detail.test.js +73 -43
  72. package/src/screens/Unit/__test__/SmartAccount.test.js +42 -25
  73. package/src/utils/I18n/translations/en.json +11 -1
  74. package/src/utils/I18n/translations/vi.json +9 -1
  75. package/src/utils/Route/index.js +6 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eohjsc/react-native-smart-city",
3
3
  "title": "React Native Smart Home",
4
- "version": "0.3.30",
4
+ "version": "0.3.31",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,41 +1,55 @@
1
- import React, { memo, useState, useEffect } from 'react';
1
+ import React, {
2
+ memo,
3
+ useState,
4
+ useEffect,
5
+ useContext,
6
+ useCallback,
7
+ } from 'react';
2
8
  import { View } from 'react-native';
3
9
  import styles from './ColorPickerTemplateStyles';
4
10
  import ColorPicker from 'react-native-wheel-color-picker';
5
11
  import { useConfigGlobalState } from '../../iot/states';
12
+ import { SCContext } from '../../context';
13
+ import { Action } from '../../context/actionType';
6
14
 
7
- let isFirstTime = true;
8
-
9
- const WheelColorPicker = ({ valueColor, onChangeColor }) => {
15
+ const WheelColorPicker = ({ valueColor, onChangeColor, onStart }) => {
10
16
  return (
11
17
  <ColorPicker
12
18
  style={styles.colorPicker}
13
19
  sliderHidden={true}
14
20
  swatches={false}
15
21
  color={valueColor}
22
+ onInteractionStart={onStart}
16
23
  onColorChangeComplete={onChangeColor}
17
24
  thumbSize={16}
18
25
  />
19
26
  );
20
27
  };
21
28
 
22
- const ColorPickerTemplate = memo(({ actionGroup, doAction, sensor }) => {
23
- const { configuration } = actionGroup;
29
+ let isFirstTime = true;
30
+ const ColorPickerTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
31
+ const { configuration = {} } = actionGroup;
24
32
  const [valueColorComplete, setValueColorComplete] = useState('');
25
33
  const [configValues] = useConfigGlobalState('configValues');
34
+ const { setAction } = useContext(SCContext);
26
35
 
27
- const onChangeColor = (color) => {
28
- const to = setTimeout(() => {
29
- isFirstTime = false;
30
- clearTimeout(to);
31
- }, 1000);
36
+ const onChangeColor = useCallback(
37
+ (color) => {
38
+ setAction(Action.SET_LOCK_VIEW_PICK_COLOR, false);
39
+ const to = setTimeout(() => {
40
+ isFirstTime = false;
41
+ clearTimeout(to);
42
+ }, 1000);
32
43
 
33
- !isFirstTime &&
34
- doAction(
35
- configuration?.action_color_data,
36
- JSON.stringify({ value: color })
37
- );
38
- };
44
+ !isFirstTime &&
45
+ doAction(
46
+ configuration?.action_color_data,
47
+ JSON.stringify({ value: color })
48
+ );
49
+ },
50
+ // eslint-disable-next-line react-hooks/exhaustive-deps
51
+ [configuration?.action_color_data, doAction]
52
+ );
39
53
 
40
54
  useEffect(() => {
41
55
  const { config } = configuration;
@@ -50,11 +64,16 @@ const ColorPickerTemplate = memo(({ actionGroup, doAction, sensor }) => {
50
64
  return () => (isFirstTime = true);
51
65
  }, []);
52
66
 
67
+ const onStartPickColor = useCallback(() => {
68
+ setAction(Action.SET_LOCK_VIEW_PICK_COLOR, true);
69
+ }, [setAction]);
70
+
53
71
  return (
54
72
  <View style={styles.viewPickColor}>
55
73
  <WheelColorPicker
56
74
  valueColor={valueColorComplete}
57
75
  onChangeColor={onChangeColor}
76
+ onStart={onStartPickColor}
58
77
  />
59
78
  </View>
60
79
  );
@@ -10,16 +10,21 @@ import styles from './NumberUpDownActionTemplateStyle';
10
10
  import { watchMultiConfigs } from '../../iot/Monitor';
11
11
  import { DEVICE_TYPE, TESTID } from '../../configs/Constants';
12
12
 
13
- const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
14
- const { configuration, title } = actionGroup;
13
+ const NumberUpDownActionTemplate = ({
14
+ actionGroup = {},
15
+ doAction,
16
+ sensor = {},
17
+ }) => {
18
+ const { configuration = {}, title } = actionGroup;
15
19
  const {
16
20
  action_data,
17
21
  max_value,
18
22
  min_value,
19
- text_format,
23
+ text_format = '',
20
24
  config,
21
25
  allow_config_store_value,
22
26
  } = configuration;
27
+ const { device_type, is_managed_by_backend } = sensor;
23
28
 
24
29
  // eslint-disable-next-line no-unused-vars
25
30
  const [configValues, setConfigValues] = useConfigGlobalState('configValues');
@@ -41,7 +46,7 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
41
46
  const doActionAndWatchConfig = useCallback(
42
47
  async (actionData, actionValue) => {
43
48
  let data = actionValue;
44
- if (sensor.device_type !== DEVICE_TYPE.GOOGLE_HOME) {
49
+ if (device_type !== DEVICE_TYPE.GOOGLE_HOME) {
45
50
  data = { temperature: actionValue };
46
51
  if (allow_config_store_value && config) {
47
52
  data.config_id = config;
@@ -50,7 +55,7 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
50
55
  data = JSON.stringify(data);
51
56
  }
52
57
  await doAction(actionData, data);
53
- if (!sensor?.is_managed_by_backend) {
58
+ if (!is_managed_by_backend) {
54
59
  return;
55
60
  }
56
61
  if (!config) {
@@ -58,13 +63,13 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
58
63
  }
59
64
 
60
65
  config &&
61
- sensor.device_type === DEVICE_TYPE.LG_THINQ &&
66
+ device_type === DEVICE_TYPE.LG_THINQ &&
62
67
  watchMultiConfigs([config]);
63
68
  },
64
69
  [
65
70
  doAction,
66
- sensor?.is_managed_by_backend,
67
- sensor.device_type,
71
+ is_managed_by_backend,
72
+ device_type,
68
73
  allow_config_store_value,
69
74
  config,
70
75
  ]
@@ -1,7 +1,6 @@
1
1
  import React, { memo, useCallback, useEffect, useState } from 'react';
2
- import { SafeAreaView, TouchableOpacity, View } from 'react-native';
2
+ import { TouchableOpacity, View } from 'react-native';
3
3
  import { useTranslations } from '../../../hooks/Common/useTranslations';
4
- import { Section } from '../../Section';
5
4
  import Text from '../../Text';
6
5
  import styles from './OnOffSmartLockStyle';
7
6
  import ButtonLock from '../../../../assets/images/Device/button-lock.svg';
@@ -11,10 +10,12 @@ import { useUnwatchLGDeviceConfigControl } from '../../../hooks/IoT';
11
10
  import { watchMultiConfigs } from '../../../iot/Monitor';
12
11
  import { DEVICE_TYPE, TESTID } from '../../../configs/Constants';
13
12
 
14
- const OnOffSmartLock = memo(({ actionGroup, doAction, sensor }) => {
13
+ const OnOffSmartLock = memo(({ actionGroup = {}, doAction, sensor = {} }) => {
15
14
  const t = useTranslations();
16
- const { configuration } = actionGroup;
17
- const { action_on_data, action_off_data } = configuration;
15
+ const { configuration = {} } = actionGroup;
16
+ const { action_on_data, action_off_data, config, is_on_value } =
17
+ configuration;
18
+ const { is_managed_by_backend, device_type } = sensor;
18
19
  const [isUnlock, setisUnlock] = useState(true);
19
20
  const [configValues] = useConfigGlobalState('configValues');
20
21
 
@@ -27,10 +28,10 @@ const OnOffSmartLock = memo(({ actionGroup, doAction, sensor }) => {
27
28
  const dataUnlock = { door_lock: 1 };
28
29
  await doAction(action_off_data, JSON.stringify(dataUnlock));
29
30
  }
30
- if (sensor?.is_managed_by_backend) {
31
- configuration.config &&
32
- sensor.device_type === DEVICE_TYPE.LG_THINQ &&
33
- watchMultiConfigs([configuration.config]);
31
+ if (is_managed_by_backend) {
32
+ config &&
33
+ device_type === DEVICE_TYPE.LG_THINQ &&
34
+ watchMultiConfigs([config]);
34
35
  }
35
36
  }
36
37
  }, [
@@ -38,54 +39,46 @@ const OnOffSmartLock = memo(({ actionGroup, doAction, sensor }) => {
38
39
  action_on_data,
39
40
  doAction,
40
41
  isUnlock,
41
- configuration,
42
- sensor?.is_managed_by_backend,
43
- sensor.device_type,
42
+ config,
43
+ is_managed_by_backend,
44
+ device_type,
44
45
  ]);
45
46
 
46
- useUnwatchLGDeviceConfigControl(sensor, [configuration.config]);
47
+ useUnwatchLGDeviceConfigControl(sensor, [config]);
47
48
 
48
49
  useEffect(() => {
49
- const { is_on_value, config } = configuration;
50
50
  const configValue = configValues[config];
51
51
  if (is_on_value && is_on_value.length) {
52
52
  setisUnlock(is_on_value.includes(configValue?.value));
53
53
  } else {
54
54
  setisUnlock(configValue?.value);
55
55
  }
56
- }, [configValues, configuration]);
56
+ }, [config, configValues, configuration, is_on_value]);
57
57
 
58
58
  return (
59
- <SafeAreaView style={styles.container}>
60
- <View style={styles.wrap}>
61
- <Section style={styles.section}>
62
- <View style={styles.wrapController}>
63
- <Text style={styles.textController}>{t('controller')}</Text>
64
- </View>
65
- <View>
66
- <TouchableOpacity
67
- onPress={handleActionSmartLock}
68
- testID={TESTID.BUTTON_ON_OFF}
69
- style={styles.wrapButtonSmartLock}
70
- >
71
- {isUnlock ? (
72
- <ButtonLock style={styles.buttonSmartLock} />
73
- ) : (
74
- <ButtonUnLock style={styles.buttonSmartLock} />
75
- )}
76
- <Text style={styles.textSmartLock}>
77
- {t(isUnlock ? 'lock' : 'unlock')}
78
- </Text>
79
- </TouchableOpacity>
80
- </View>
81
- <View style={styles.wrapStatus}>
82
- <Text style={styles.textStatus}>
83
- {t(isUnlock ? 'door_is_open' : 'door_is_close')}
84
- </Text>
85
- </View>
86
- </Section>
59
+ <>
60
+ <View>
61
+ <TouchableOpacity
62
+ onPress={handleActionSmartLock}
63
+ testID={TESTID.BUTTON_ON_OFF}
64
+ style={styles.wrapButtonSmartLock}
65
+ >
66
+ {isUnlock ? (
67
+ <ButtonLock style={styles.buttonSmartLock} />
68
+ ) : (
69
+ <ButtonUnLock style={styles.buttonSmartLock} />
70
+ )}
71
+ <Text style={styles.textSmartLock}>
72
+ {t(isUnlock ? 'lock' : 'unlock')}
73
+ </Text>
74
+ </TouchableOpacity>
87
75
  </View>
88
- </SafeAreaView>
76
+ <View style={styles.wrapStatus}>
77
+ <Text style={styles.textStatus}>
78
+ {t(isUnlock ? 'door_is_open' : 'door_is_close')}
79
+ </Text>
80
+ </View>
81
+ </>
89
82
  );
90
83
  });
91
84
 
@@ -28,6 +28,7 @@ export default StyleSheet.create({
28
28
  borderRadius: 10,
29
29
  borderColor: Colors.Gray4,
30
30
  borderWidth: 1,
31
+ marginTop: 10,
31
32
  },
32
33
  buttonSmartLock: {
33
34
  marginTop: 14,
@@ -8,8 +8,9 @@ import styles from './OnOffButtonTemplateStyle';
8
8
  import { TESTID } from '../../../configs/Constants';
9
9
 
10
10
  const OnOffButtonTemplate = memo(
11
- ({ isOn, triggerAction, actionGroup, isLight = false }) => {
12
- const { configuration, id } = actionGroup;
11
+ ({ isOn, triggerAction, actionGroup = {}, isLight = false }) => {
12
+ const { configuration = {}, id } = actionGroup;
13
+ const { icon_on, icon_off, text_on, text_off } = configuration;
13
14
 
14
15
  return (
15
16
  <>
@@ -22,7 +23,7 @@ const OnOffButtonTemplate = memo(
22
23
  >
23
24
  <View style={styles.smallCircle}>
24
25
  <Icon
25
- name={isOn ? configuration.icon_on : configuration.icon_off}
26
+ name={isOn ? icon_on : icon_off}
26
27
  size={44}
27
28
  color={isOn ? Colors.Green7 : Colors.Gray6}
28
29
  />
@@ -34,7 +35,7 @@ const OnOffButtonTemplate = memo(
34
35
  testID={`${TESTID.SENSOR_STATUS}-${id}`}
35
36
  accessibilityLabel={`${TESTID.SENSOR_STATUS}-${id}`}
36
37
  >
37
- {isOn ? configuration.text_on : configuration.text_off}
38
+ {isOn ? text_on : text_off}
38
39
  </Text>
39
40
  </View>
40
41
  </TouchableOpacity>
@@ -20,8 +20,8 @@ const getComponent = (template) => {
20
20
  }
21
21
  };
22
22
 
23
- const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
24
- const { configuration } = actionGroup;
23
+ const OnOffTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
24
+ const { configuration = {} } = actionGroup;
25
25
  const { action_data, action_on_data, action_off_data } = configuration;
26
26
 
27
27
  // eslint-disable-next-line no-unused-vars
@@ -6,9 +6,9 @@ import Text from '../Text';
6
6
  import { Colors } from '../../configs';
7
7
  import styles from './OneBigButtonTemplateStyle';
8
8
 
9
- const OneBigButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
10
- const { configuration } = actionGroup;
11
- const { text, action_data } = configuration || {};
9
+ const OneBigButtonTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
10
+ const { configuration = {} } = actionGroup;
11
+ const { text, action_data, icon } = configuration;
12
12
 
13
13
  const onPressDoAction = useCallback(() => {
14
14
  doAction(action_data, null);
@@ -19,7 +19,7 @@ const OneBigButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
19
19
  <View style={styles.barrierControlContainer}>
20
20
  <TouchableOpacity style={styles.bigCircle} onPress={onPressDoAction}>
21
21
  <View style={styles.smallCircle}>
22
- <Icon name={configuration.icon} size={44} color={Colors.Green7} />
22
+ <Icon name={icon} size={44} color={Colors.Green7} />
23
23
  <Text style={styles.textBig}>{text}</Text>
24
24
  </View>
25
25
  </TouchableOpacity>
@@ -24,38 +24,48 @@ function getOptionValue(option) {
24
24
  return option.value_int;
25
25
  }
26
26
 
27
- const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
27
+ const OptionsDropdownActionTemplate = ({
28
+ actionGroup = {},
29
+ doAction,
30
+ sensor = {},
31
+ }) => {
28
32
  const t = useTranslations();
29
- const { configuration, title } = actionGroup;
30
- const { action_data, options, icon_kit_data, icon, icon_outlined } =
31
- configuration;
33
+ const { configuration = {}, title } = actionGroup;
34
+ const {
35
+ action_data,
36
+ options = [],
37
+ icon_kit_data,
38
+ icon,
39
+ icon_outlined,
40
+ config,
41
+ } = configuration;
32
42
  // eslint-disable-next-line no-unused-vars
33
43
  const [configValues, setConfigValues] = useConfigGlobalState('configValues');
34
44
  const checkIcon = /\d/.test(icon); // to do check icon svg and icon antDesign
35
45
  const selectedOption = useMemo(() => {
36
- const currentValue = configValues[configuration.config]?.value;
46
+ const currentValue = configValues[config]?.value;
37
47
  if (currentValue === null || currentValue === undefined) {
38
- return configuration.options[0];
48
+ return options[0];
39
49
  }
40
50
 
41
- for (let i = 0; i < configuration.options.length; i++) {
42
- const option = configuration.options[i];
51
+ for (let i = 0; i < options.length; i++) {
52
+ const option = options[i];
43
53
  const value = getOptionValue(option);
44
54
  if (value === currentValue) {
45
55
  return option;
46
56
  }
47
57
  }
48
- return configuration.options[0];
49
- }, [configValues, configuration.config, configuration.options]);
58
+ return options[0];
59
+ }, [configValues, config, options]);
50
60
 
51
61
  const { stateAlert, hideAlertAction, onShowAlert } = useDropdownAction();
52
62
  const [selectedIndex, setSelectedIndex] = useState(
53
- configuration.options.indexOf(selectedOption)
63
+ options.indexOf(selectedOption)
54
64
  );
55
65
 
56
66
  useEffect(() => {
57
- setSelectedIndex(configuration.options.indexOf(selectedOption));
58
- }, [configuration.options, selectedOption]);
67
+ setSelectedIndex(options.indexOf(selectedOption));
68
+ }, [options, selectedOption]);
59
69
 
60
70
  const onDone = useCallback(() => {
61
71
  const newOption = options[selectedIndex];
@@ -68,14 +78,14 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
68
78
 
69
79
  doAction(action_data, data);
70
80
  if (sensor?.is_managed_by_backend) {
71
- configuration.config &&
81
+ config &&
72
82
  sensor.device_type === DEVICE_TYPE.LG_THINQ &&
73
- watchMultiConfigs([configuration.config]);
83
+ watchMultiConfigs([config]);
74
84
  }
75
85
  hideAlertAction();
76
86
  }, [
77
87
  action_data,
78
- configuration.config,
88
+ config,
79
89
  doAction,
80
90
  hideAlertAction,
81
91
  options,
@@ -89,11 +99,11 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
89
99
  const iconKit = !!icon_kit_data && icon_kit_data.icon;
90
100
 
91
101
  const displaySelected = useMemo(() => {
92
- if (!configuration.config) {
102
+ if (!config) {
93
103
  return t('not_available');
94
104
  }
95
105
  return selectedOption.text;
96
- }, [configuration?.config, selectedOption?.text, t]);
106
+ }, [config, selectedOption?.text, t]);
97
107
 
98
108
  const iconSvg = useMemo(() => {
99
109
  switch (icon) {
@@ -8,9 +8,9 @@ import SvgBrightness from '../../../assets/images/brightness.svg';
8
8
  import SliderRange from 'react-native-slider';
9
9
  import { useConfigGlobalState } from '../../iot/states';
10
10
 
11
- const SliderRangeTemplate = memo(({ actionGroup, doAction, sensor }) => {
11
+ const SliderRangeTemplate = memo(({ actionGroup = {}, doAction }) => {
12
12
  const t = useTranslations();
13
- const { configuration } = actionGroup;
13
+ const { configuration = {} } = actionGroup;
14
14
  const [valueBrightness, setValueBrightness] = useState(0);
15
15
  const [valueBrightnessTemp, setValueBrightnessTemp] = useState(0);
16
16
  const [isFirstTime, setIsFirstTime] = useState(true);
@@ -1,15 +1,12 @@
1
1
  import React, { memo, useCallback, useState } from 'react';
2
2
  import { TouchableOpacity, View, Switch } from 'react-native';
3
3
  import { Icon } from '@ant-design/react-native';
4
- import { useTranslations } from '../../hooks/Common/useTranslations';
5
4
  import styles from './ThreeButtonTemplateStyle';
6
5
  import Text from '../Text';
7
6
  import { TESTID } from '../../configs/Constants';
8
7
  import { Colors } from '../../configs';
9
- import { Card } from '../../commons/CardShadow';
10
8
 
11
- const ThreeButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
12
- const t = useTranslations();
9
+ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
13
10
  const { configuration } = actionGroup;
14
11
  const {
15
12
  text1,
@@ -20,7 +17,12 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
20
17
  action3_data,
21
18
  action_off_data,
22
19
  action_on_data,
23
- } = configuration;
20
+ icon1,
21
+ icon2,
22
+ icon3,
23
+ text_door_lock,
24
+ is_display_lock,
25
+ } = configuration || {};
24
26
  const [lock, setLock] = useState(false);
25
27
  const iconCustom = (icon) => {
26
28
  return icon === 'stop' ? (
@@ -60,7 +62,7 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
60
62
  style={styles.textLockDoor}
61
63
  testID={TESTID.TEXT_DOOR_LOOK_ON_OFF}
62
64
  >
63
- {configuration.text_door_lock}{' '}
65
+ {`${text_door_lock} `}
64
66
  </Text>
65
67
  </View>
66
68
  <Switch
@@ -75,60 +77,48 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
75
77
  };
76
78
  return (
77
79
  <>
78
- <Card title={actionGroup.title ? actionGroup.title : t('controller')}>
79
- <View style={styles.wrap}>
80
- <TouchableOpacity
81
- testID={TESTID.BUTTON_TEMPLATE_1}
82
- style={styles.buttonActionDoor}
83
- onPress={onButton1Press}
84
- underlayColor={Colors.Gray2}
85
- >
86
- <View style={styles.imageButton}>
87
- <Icon
88
- name={configuration.icon1}
89
- size={30}
90
- color={Colors.Primary}
91
- />
92
- </View>
93
- <Text style={styles.text}>{text1}</Text>
94
- </TouchableOpacity>
80
+ <View style={styles.wrap}>
81
+ <TouchableOpacity
82
+ testID={TESTID.BUTTON_TEMPLATE_1}
83
+ style={styles.buttonActionDoor}
84
+ onPress={onButton1Press}
85
+ underlayColor={Colors.Gray2}
86
+ >
87
+ <View style={styles.imageButton}>
88
+ <Icon name={icon1} size={30} color={Colors.Primary} />
89
+ </View>
90
+ <Text style={styles.text}>{text1}</Text>
91
+ </TouchableOpacity>
95
92
 
96
- <TouchableOpacity
97
- testID={TESTID.BUTTON_TEMPLATE_2}
98
- style={styles.buttonActionDoor}
99
- onPress={onButton2Press}
100
- underlayColor={Colors.Gray2}
101
- >
102
- <View style={styles.imageButton}>
103
- {iconCustom(configuration.icon2)}
104
- </View>
105
- <Text style={styles.text}>{text2}</Text>
106
- </TouchableOpacity>
93
+ <TouchableOpacity
94
+ testID={TESTID.BUTTON_TEMPLATE_2}
95
+ style={styles.buttonActionDoor}
96
+ onPress={onButton2Press}
97
+ underlayColor={Colors.Gray2}
98
+ >
99
+ <View style={styles.imageButton}>{iconCustom(icon2)}</View>
100
+ <Text style={styles.text}>{text2}</Text>
101
+ </TouchableOpacity>
107
102
 
108
- <TouchableOpacity
109
- testID={TESTID.BUTTON_TEMPLATE_3}
110
- style={styles.buttonActionDoor}
111
- onPress={onButton3Press}
112
- underlayColor={Colors.Gray2}
113
- >
114
- <View style={styles.imageButton}>
115
- <Icon
116
- name={configuration.icon3}
117
- size={30}
118
- color={Colors.Primary}
119
- />
120
- </View>
121
- <Text style={styles.text}>{text3}</Text>
122
- </TouchableOpacity>
123
- </View>
124
- <View style={styles.lockSwitch}>
125
- {configuration.is_display_lock &&
126
- itemLock(
127
- lock ? 'lock' : 'unlock',
128
- lock ? Colors.Primary : Colors.Gray6
129
- )}
130
- </View>
131
- </Card>
103
+ <TouchableOpacity
104
+ testID={TESTID.BUTTON_TEMPLATE_3}
105
+ style={styles.buttonActionDoor}
106
+ onPress={onButton3Press}
107
+ underlayColor={Colors.Gray2}
108
+ >
109
+ <View style={styles.imageButton}>
110
+ <Icon name={icon3} size={30} color={Colors.Primary} />
111
+ </View>
112
+ <Text style={styles.text}>{text3}</Text>
113
+ </TouchableOpacity>
114
+ </View>
115
+ <View style={styles.lockSwitch}>
116
+ {is_display_lock &&
117
+ itemLock(
118
+ lock ? 'lock' : 'unlock',
119
+ lock ? Colors.Primary : Colors.Gray6
120
+ )}
121
+ </View>
132
122
  </>
133
123
  );
134
124
  });