Skip to content

Commit 4009890

Browse files
committed
fix(pretty): pretty it
1 parent 3df395b commit 4009890

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

src/components/features/list-editor.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const ListEditor: FunctionComponent<ListEditorProps> = (props) => {
2727
const onItemChange = (itemValue: any, itemIndex: number) => {
2828
const newListValue = [...currentValue];
2929
if (typeof itemValue === 'object') {
30-
itemValue = {...currentValue[itemIndex], ...itemValue}
30+
itemValue = { ...currentValue[itemIndex], ...itemValue };
3131
}
3232
newListValue[itemIndex] = itemValue;
3333
replaceList(newListValue);

src/components/features/list/list.tsx

+19-23
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,32 @@ interface State {
1111
value: any[];
1212
}
1313

14-
type Props = BaseFeatureProps<ListFeature> & { parentFeatures: (CompositeFeature | GenericExposedFeature)[] } & WithTranslation<'list'>;
14+
type Props = BaseFeatureProps<ListFeature> & {
15+
parentFeatures: (CompositeFeature | GenericExposedFeature)[];
16+
} & WithTranslation<'list'>;
1517

1618
class List extends Component<Props, State> {
1719
constructor(props: Props) {
1820
super(props);
19-
const {deviceState, feature} = this.props;
20-
const {property} = feature;
21-
const value = (property ? ((deviceState[property] ?? []) as any[]) : []);;
22-
this.state = {value}
21+
const { deviceState, feature } = this.props;
22+
const { property } = feature;
23+
const value = property ? ((deviceState[property] ?? []) as any[]) : [];
24+
this.state = { value };
2325
}
2426

2527
onChange = (value: any[]): void => {
26-
const {endpoint, property} = this.props.feature;
27-
this.setState({value});
28+
const { endpoint, property } = this.props.feature;
29+
this.setState({ value });
2830
if (!this.isListRoot()) {
2931
this.props.onChange(endpoint as Endpoint, property ? { [property]: value } : value);
3032
}
31-
}
33+
};
3234

3335
onApply = () => {
34-
const {value} = this.state;
35-
const {endpoint, property} = this.props.feature;
36+
const { value } = this.state;
37+
const { endpoint, property } = this.props.feature;
3638
this.props.onChange(endpoint as Endpoint, property ? { [property]: value } : value);
37-
}
39+
};
3840

3941
isListRoot = (): boolean => {
4042
return this.props.parentFeatures?.length === 1;
@@ -45,34 +47,28 @@ class List extends Component<Props, State> {
4547
const { access = FeatureAccessMode.ACCESS_WRITE, item_type: itemType } = feature;
4648
if (access & FeatureAccessMode.ACCESS_WRITE) {
4749
if (itemType == 'number') {
48-
return (
49-
<RangeListEditor
50-
onChange={this.onChange}
51-
value={this.state.value}
52-
minimal={minimal}
53-
/>
54-
);
50+
return <RangeListEditor onChange={this.onChange} value={this.state.value} minimal={minimal} />;
5551
} else {
5652
const result = [
5753
<ListEditor
58-
key='1'
54+
key="1"
5955
feature={itemType}
6056
parentFeatures={[...parentFeatures, feature]}
6157
onChange={this.onChange}
6258
value={this.state.value}
63-
/>
59+
/>,
6460
];
6561

6662
if (this.isListRoot()) {
6763
result.push(
68-
<div key='2'>
64+
<div key="2">
6965
<Button
7066
className={cx('btn btn-primary float-end', { 'btn-sm': minimal })}
7167
onClick={this.onApply}
7268
>
7369
{t('common:apply')}
7470
</Button>
75-
</div>
71+
</div>,
7672
);
7773
}
7874

@@ -84,6 +80,6 @@ class List extends Component<Props, State> {
8480
return <NoAccessError {...this.props} />;
8581
}
8682
}
87-
};
83+
}
8884

8985
export default withTranslation(['list', 'common'])(React.memo(List));

0 commit comments

Comments
 (0)